Class: OmniAgent::Providers::OpenAI
- Defined in:
- lib/omni_agent/providers/openai.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from OmniAgent::Providers::Base
Instance Method Details
#chat(messages:, tools: [], **options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/omni_agent/providers/openai.rb', line 15 def chat(messages:, tools: [], **) openai_tools = tools.map { |tool| format_tool(tool) } payload = { model: model, messages: } payload[:tools] = openai_tools if openai_tools.any? payload.merge!() if .any? response = client.chat.completions.create(**payload) parse_response(response) rescue => e puts "Error during OpenAI chat: #{e.}" end |