Class: OmniAI::Llama::Client
- Inherits:
-
Client
- Object
- Client
- OmniAI::Llama::Client
- Defined in:
- lib/omniai/llama/client.rb
Overview
Constant Summary collapse
- VERSION =
"v1"
Instance Method Summary collapse
- #chat(messages = nil, model: Chat::DEFAULT_MODEL, temperature: nil, format: nil, stream: nil, tools: nil) {|prompt| ... } ⇒ OmniAI::Chat::Completion
- #connection ⇒ HTTP::Client
-
#initialize(api_key: OmniAI::Llama.config.api_key, host: OmniAI::Llama.config.host, logger: OmniAI::Llama.config.logger, timeout: OmniAI::Llama.config.timeout) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key: OmniAI::Llama.config.api_key, host: OmniAI::Llama.config.host, logger: OmniAI::Llama.config.logger, timeout: OmniAI::Llama.config.timeout) ⇒ Client
Returns a new instance of Client.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/omniai/llama/client.rb', line 29 def initialize( api_key: OmniAI::Llama.config.api_key, host: OmniAI::Llama.config.host, logger: OmniAI::Llama.config.logger, timeout: OmniAI::Llama.config.timeout ) raise(ArgumentError, %(ENV['LLAMA_API_KEY'] must be defined or `api_key` must be passed)) if api_key.nil? super end |
Instance Method Details
#chat(messages = nil, model: Chat::DEFAULT_MODEL, temperature: nil, format: nil, stream: nil, tools: nil) {|prompt| ... } ⇒ OmniAI::Chat::Completion
62 63 64 |
# File 'lib/omniai/llama/client.rb', line 62 def chat( = nil, model: Chat::DEFAULT_MODEL, temperature: nil, format: nil, stream: nil, tools: nil, &) Chat.process!(, model:, temperature:, format:, stream:, tools:, client: self, &) end |
#connection ⇒ HTTP::Client
41 42 43 44 45 46 47 |
# File 'lib/omniai/llama/client.rb', line 41 def connection @connection ||= begin http = super http = http.auth("Bearer #{@api_key}") if @api_key http end end |