Class: Rixie::LLM::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rixie/llm/client.rb,
lib/rixie/llm/client/resolver.rb

Defined Under Namespace

Classes: Resolver

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model: nil, provider: nil, adapter: nil, stream: false, request_timeout: nil, max_tokens: nil, temperature: nil, parallel_tool_calls: nil) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rixie/llm/client.rb', line 10

def initialize(model: nil, provider: nil, adapter: nil, stream: false, request_timeout: nil, max_tokens: nil, temperature: nil, parallel_tool_calls: nil)
  @model = model
  @provider = provider
  @stream = stream
  @adapter = adapter || Client::Resolver.resolve(
    model: model,
    provider: provider,
    request_timeout: request_timeout,
    max_tokens: max_tokens,
    temperature: temperature,
    parallel_tool_calls: parallel_tool_calls
  )
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



8
9
10
# File 'lib/rixie/llm/client.rb', line 8

def model
  @model
end

#providerObject (readonly)

Returns the value of attribute provider.



8
9
10
# File 'lib/rixie/llm/client.rb', line 8

def provider
  @provider
end

Instance Method Details

#call(messages, tools:, &block) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/rixie/llm/client.rb', line 24

def call(messages, tools:, &block)
  if @stream
    @adapter.stream(messages, tools: tools, &block)
  else
    @adapter.chat(messages, tools: tools)
  end
end