Class: RubyBots::OpenAITool

Inherits:
Tool
  • Object
show all
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

OpenAIBot, OpenAIChatTool

Constant Summary collapse

DEFAULT_DESCRIPTION =
'This tool will use open ai to determine the output.'.freeze

Instance Attribute Summary

Attributes inherited from Tool

#description, #errors, #name

Instance Method Summary collapse

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

#clientObject



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_paramsObject



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_instructionsObject



24
25
26
# File 'lib/ruby_bots/tools/openai_tool.rb', line 24

def system_instructions
  'You are a helpful assistant.'
end