Class: RubyBots::OpenAIChatBot
- Inherits:
-
OpenAIBot
- Object
- Tool
- OpenAITool
- OpenAIBot
- RubyBots::OpenAIChatBot
- Includes:
- Chattable
- Defined in:
- lib/ruby_bots/bots/openai_chat_bot.rb
Constant Summary collapse
- DEFAULT_DESCRIPTION =
'This bot will use OpenAI to determine the appropriate tool and use it. It will also chat responses to the user to clarify their request.'.freeze
Instance Attribute Summary
Attributes inherited from OpenAIBot
Attributes inherited from Tool
Instance Method Summary collapse
-
#initialize(tools:, name: 'OpenAI chat bot', description: DEFAULT_DESCRIPTION) ⇒ OpenAIChatBot
constructor
A new instance of OpenAIChatBot.
- #system_instructions ⇒ Object
Methods included from Chattable
Methods inherited from OpenAITool
Methods inherited from Tool
#response, validate_input, validate_output
Constructor Details
#initialize(tools:, name: 'OpenAI chat bot', description: DEFAULT_DESCRIPTION) ⇒ OpenAIChatBot
Returns a new instance of OpenAIChatBot.
7 8 9 |
# File 'lib/ruby_bots/bots/openai_chat_bot.rb', line 7 def initialize(tools:, name: 'OpenAI chat bot', description: DEFAULT_DESCRIPTION) super(tools:, name:, description:) end |
Instance Method Details
#system_instructions ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruby_bots/bots/openai_chat_bot.rb', line 11 def system_instructions <<~PROMPT You are an assistant that is chatting with a user and also using tools. You can use the following tools (name - description): #{tools.map { |t| "#{t.name} - #{t.description}" }.join('\n')} Select from the following tools (name - description): #{tools.map { |t| "#{t.name} - #{t.description}" }.join('\n')} If it is clear that a tool best fits the user's request, return only the tool name and nothing more. If no tool clearly matches the user's request respond with questions to help you clarify the user's response. PROMPT end |