Class: LlmGateway::Adapters::Groq::Client

Inherits:
BaseClient
  • Object
show all
Defined in:
lib/llm_gateway/adapters/groq/client.rb

Instance Attribute Summary

Attributes inherited from BaseClient

#api_key, #base_endpoint, #model_key

Instance Method Summary collapse

Methods inherited from BaseClient

#get, #post, #post_file

Constructor Details

#initialize(model_key: "gemma2-9b-it", api_key: ENV["GROQ_API_KEY"]) ⇒ Client

Returns a new instance of Client.



9
10
11
12
# File 'lib/llm_gateway/adapters/groq/client.rb', line 9

def initialize(model_key: "gemma2-9b-it", api_key: ENV["GROQ_API_KEY"])
  @base_endpoint = "https://api.groq.com/openai/v1"
  super(model_key: model_key, api_key: api_key)
end

Instance Method Details

#chat(messages, response_format: { type: "text" }, tools: nil, system: [], max_completion_tokens: 4096) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/llm_gateway/adapters/groq/client.rb', line 14

def chat(messages, response_format: { type: "text" }, tools: nil, system: [], max_completion_tokens: 4096)
  body = {
    model: model_key,
    messages: system + messages,
    temperature: 0,
    max_completion_tokens: max_completion_tokens,
    response_format: response_format,
    tools: tools
  }

  post("chat/completions", body)
end