Class: Soka::LLMs::OpenAI
Overview
OpenAI (GPT) LLM provider implementation
Constant Summary collapse
- ENV_KEY =
'OPENAI_API_KEY'
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#initialize, #streaming_chat, #supports_streaming?
Constructor Details
This class inherits a constructor from Soka::LLMs::Base
Instance Method Details
#chat(messages, **params) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/soka/llms/openai.rb', line 9 def chat(, **params) request_params = build_request_params(, params) response = connection.post do |req| req.url '/v1/responses' req.headers['Authorization'] = "Bearer #{api_key}" req.body = request_params end parse_response(response) rescue Faraday::Error => e handle_error(e) end |