Class: Ollama::ChainLink

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama/pipeline.rb

Overview

Internal chain link that wraps middleware around transport

Instance Method Summary collapse

Constructor Details

#initialize(app, middleware) ⇒ ChainLink

Returns a new instance of ChainLink.



155
156
157
158
# File 'lib/ollama/pipeline.rb', line 155

def initialize(app, middleware)
  @app = app
  @middleware = middleware
end

Instance Method Details

#call(request, env = {}) ⇒ Object



160
161
162
163
# File 'lib/ollama/pipeline.rb', line 160

def call(request, env = {})
  # Yielded args let middleware modify the request/env mid-chain (e.g. Fallback).
  @middleware.around(request, env) { |req, e| @app.call(req || request, e || env) }
end

#stream(uri:, request:, &block) ⇒ Object



165
166
167
# File 'lib/ollama/pipeline.rb', line 165

def stream(uri:, request:, &block)
  @app.stream(uri: uri, request: request, &block)
end