Class: RubyBots::OpenAITool
- Defined in:
- lib/ruby_bots/tools/openai_tool.rb
Overview
Tool for connecting to Open AI. Use this tool to connect to Open AI and get a response. the default model is gpt-4, it can be altered by overriding the default_params method.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_DESCRIPTION =
'This tool will use open ai to determine the output.'.freeze
Instance Attribute Summary
Attributes inherited from Tool
Instance Method Summary collapse
- #client ⇒ Object
- #default_params ⇒ Object
-
#initialize(name: 'OpenAI Tool', description: DEFAULT_DESCRIPTION) ⇒ OpenAITool
constructor
A new instance of OpenAITool.
- #system_instructions ⇒ Object
Methods inherited from Tool
#response, validate_input, validate_output
Constructor Details
#initialize(name: 'OpenAI Tool', description: DEFAULT_DESCRIPTION) ⇒ OpenAITool
Returns a new instance of OpenAITool.
9 10 11 |
# File 'lib/ruby_bots/tools/openai_tool.rb', line 9 def initialize(name: 'OpenAI Tool', description: DEFAULT_DESCRIPTION) super(name:, description:) end |
Instance Method Details
#client ⇒ Object
13 14 15 |
# File 'lib/ruby_bots/tools/openai_tool.rb', line 13 def client @client ||= OpenAI::Client.new(access_token: RubyBots.config.openai_api_key) end |
#default_params ⇒ Object
17 18 19 20 21 22 |
# File 'lib/ruby_bots/tools/openai_tool.rb', line 17 def default_params { model: 'gpt-3.5-turbo', temperature: 0 } end |
#system_instructions ⇒ Object
24 25 26 |
# File 'lib/ruby_bots/tools/openai_tool.rb', line 24 def system_instructions 'You are a helpful assistant.' end |