Class: RubyBots::OpenAIBot
- Inherits:
-
OpenAITool
- Object
- Tool
- OpenAITool
- RubyBots::OpenAIBot
- Defined in:
- lib/ruby_bots/bots/openai_bot.rb
Overview
Bot class for OpenAI. This will use open AI to determine which tool to use for the response.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_DESCRIPTION =
'This bot will use OpenAI to determine the appropriate tool.'.freeze
Instance Attribute Summary collapse
-
#tools ⇒ Object
Returns the value of attribute tools.
Attributes inherited from Tool
Instance Method Summary collapse
-
#initialize(tools:, name: 'OpenAI bot', description: DEFAULT_DESCRIPTION) ⇒ OpenAIBot
constructor
A new instance of OpenAIBot.
- #system_instructions ⇒ Object
Methods inherited from OpenAITool
Methods inherited from Tool
#response, validate_input, validate_output
Constructor Details
#initialize(tools:, name: 'OpenAI bot', description: DEFAULT_DESCRIPTION) ⇒ OpenAIBot
Returns a new instance of OpenAIBot.
10 11 12 13 |
# File 'lib/ruby_bots/bots/openai_bot.rb', line 10 def initialize(tools:, name: 'OpenAI bot', description: DEFAULT_DESCRIPTION) @tools = tools super(name:, description:) end |
Instance Attribute Details
#tools ⇒ Object
Returns the value of attribute tools.
4 5 6 |
# File 'lib/ruby_bots/bots/openai_bot.rb', line 4 def tools @tools end |
Instance Method Details
#system_instructions ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ruby_bots/bots/openai_bot.rb', line 15 def system_instructions <<~PROMPT You are an assistant designed to select a tool for a user to use. You are provided with the user's input. Select from the following tools (name - description): #{tools.map { |t| "#{t.name} - #{t.description}" }.join('\n')} Return only the name of the tool that best fits the user's request. If no tools match the user's request respond with "no tool" and nothing more. PROMPT end |