Class: OmniAI::Google::Client
- Inherits:
-
Client
- Object
- Client
- OmniAI::Google::Client
- Defined in:
- lib/omniai/google/client.rb
Overview
Instance Attribute Summary collapse
Instance Method Summary collapse
- #chat(messages = nil, model: Chat::DEFAULT_MODEL, temperature: nil, format: nil, stream: nil, tools: nil) {|prompt| ... } ⇒ OmniAI::Chat::Completion
- #embed(input, model: Embed::DEFAULT_MODEL) ⇒ Object
-
#initialize(api_key: OmniAI::Google.config.api_key, logger: OmniAI::Google.config.logger, host: OmniAI::Google.config.host, version: OmniAI::Google.config.version, timeout: OmniAI::Google.config.timeout) ⇒ Client
constructor
A new instance of Client.
- #path ⇒ String
- #upload(io) ⇒ OmniAI::Google::Upload::File
Constructor Details
#initialize(api_key: OmniAI::Google.config.api_key, logger: OmniAI::Google.config.logger, host: OmniAI::Google.config.host, version: OmniAI::Google.config.version, timeout: OmniAI::Google.config.timeout) ⇒ Client
Returns a new instance of Client.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/omniai/google/client.rb', line 32 def initialize( api_key: OmniAI::Google.config.api_key, logger: OmniAI::Google.config.logger, host: OmniAI::Google.config.host, version: OmniAI::Google.config.version, timeout: OmniAI::Google.config.timeout ) raise(ArgumentError, %(ENV['GOOGLE_API_KEY'] must be defined or `api_key` must be passed)) if api_key.nil? super(api_key:, host:, logger:, timeout:) @version = version end |
Instance Attribute Details
#version ⇒ String?
25 26 27 |
# File 'lib/omniai/google/client.rb', line 25 def version @version end |
Instance Method Details
#chat(messages = nil, model: Chat::DEFAULT_MODEL, temperature: nil, format: nil, stream: nil, tools: nil) {|prompt| ... } ⇒ OmniAI::Chat::Completion
59 60 61 |
# File 'lib/omniai/google/client.rb', line 59 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 |
#embed(input, model: Embed::DEFAULT_MODEL) ⇒ Object
76 77 78 |
# File 'lib/omniai/google/client.rb', line 76 def (input, model: Embed::DEFAULT_MODEL) Embed.process!(input, model:, client: self) end |
#path ⇒ String
81 82 83 84 85 86 87 |
# File 'lib/omniai/google/client.rb', line 81 def path if @project_id "/#{@version}/projects/#{@project_id}/locations/#{@location}/publishers/google" else "/#{@version}" end end |
#upload(io) ⇒ OmniAI::Google::Upload::File
68 69 70 |
# File 'lib/omniai/google/client.rb', line 68 def upload(io) Upload.process!(client: self, io:) end |