Module: Legion::Extensions::Llamacpp::Helpers::Client

Included in:
Client, Runners::Chat, Runners::Completions, Runners::Embeddings, Runners::Health, Runners::Models, Runners::Slots, Runners::Tokenize
Defined in:
lib/legion/extensions/llamacpp/helpers/client.rb

Constant Summary collapse

DEFAULT_HOST =
'http://localhost:8080'

Instance Method Summary collapse

Instance Method Details

#client(host: DEFAULT_HOST) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/legion/extensions/llamacpp/helpers/client.rb', line 12

def client(host: DEFAULT_HOST, **)
  Faraday.new(url: host) do |conn|
    conn.request :json
    conn.response :json, content_type: /\bjson$/
    conn.headers['Content-Type'] = 'application/json'
    conn.options.timeout = 300
    conn.options.open_timeout = 10
  end
end

#streaming_client(host: DEFAULT_HOST) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/legion/extensions/llamacpp/helpers/client.rb', line 22

def streaming_client(host: DEFAULT_HOST, **)
  Faraday.new(url: host) do |conn|
    conn.request :json
    conn.headers['Content-Type'] = 'application/json'
    conn.options.timeout = 300
    conn.options.open_timeout = 10
  end
end