Class: LlmGateway::Proxy::Adapter
- Defined in:
- lib/llm_gateway/proxy/adapter.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(client) ⇒ Adapter
constructor
A new instance of Adapter.
- #stream(message, tools: nil, system: nil, **options, &block) ⇒ Object
Constructor Details
#initialize(client) ⇒ Adapter
Returns a new instance of Adapter.
8 9 10 |
# File 'lib/llm_gateway/proxy/adapter.rb', line 8 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/llm_gateway/proxy/adapter.rb', line 6 def client @client end |
Instance Method Details
#stream(message, tools: nil, system: nil, **options, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/llm_gateway/proxy/adapter.rb', line 12 def stream(, tools: nil, system: nil, **, &block) target_adapter = LlmGateway.build_provider(client.target_config.merge(provider: client.target_provider)) mapper_class = target_adapter.stream_mapper_class raise LlmGateway::Errors::MissingMapperForProvider, "No stream_mapper configured" unless mapper_class mapper = mapper_class.new( provider: LlmGateway::Client.provider_id_from_client(target_adapter.client), api: target_adapter.stream_api_name ) client.stream((), tools: tools, system: normalize_system(system), **) do |chunk| mapper.map(chunk, &block) end mapper.result end |