Class: RubyBots::RouterBot
- Inherits:
-
OpenAIBot
- Object
- Tool
- OpenAITool
- OpenAIBot
- RubyBots::RouterBot
- Defined in:
- lib/ruby_bots/bots/router_bot.rb
Overview
Class to provide a router to different tools. This bot connects to the OpenAI API and uses gpt-3.5-turbo by default to choose a proper tool to route the user’s input. The bot will only select and use one tool by default.
Constant Summary collapse
- DEFAULT_DESCRIPTION =
"This bot will route the user's input to the appropriate tool. It will only select and use one tool.\"\n".strip_heredoc
Instance Attribute Summary
Attributes inherited from OpenAIBot
Attributes inherited from Tool
Instance Method Summary collapse
-
#initialize(tools:, name: 'Router bot', description: DEFAULT_DESCRIPTION) ⇒ RouterBot
constructor
A new instance of RouterBot.
- #system_instructions ⇒ Object
Methods inherited from OpenAITool
Methods inherited from Tool
#response, validate_input, validate_output
Constructor Details
#initialize(tools:, name: 'Router bot', description: DEFAULT_DESCRIPTION) ⇒ RouterBot
Returns a new instance of RouterBot.
10 11 12 |
# File 'lib/ruby_bots/bots/router_bot.rb', line 10 def initialize(tools:, name: 'Router bot', description: DEFAULT_DESCRIPTION) super(tools:, name:, description:) end |
Instance Method Details
#system_instructions ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_bots/bots/router_bot.rb', line 14 def system_instructions " You are an assistant helping to route a user's input to the correct tool.\n You can use the following tools (name - description):\n \#{tools.map { |t| \"\#{t.name} - \#{t.description}\" }.join('\\n')}\n\n Return only the name of the tool that best fits the user's request.\n PROMPT\nend\n" |