completion-kit 0.5.35 → 0.5.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f3189fdba715e4750befcadf517462d0523ae7366611964388309031ad6a4d4f
|
|
4
|
+
data.tar.gz: 322e2dd4847c5e8bd3b8af83b4b09873efcd4238c945d928fdac7c7ffbbaf7de
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f611cfbc07196fd75eb16962bb1acf4a271d759f42473af9b94d049860839a12657223c72bb12aaeaa80a14adfbb29a20c4cb3c4c3176193ce44966bb876b011
|
|
7
|
+
data.tar.gz: 2806d017ce92c625e6c7f83e789d13afe53065107a5a803f0d309cb1eaee65d752a8b1e18734c42e9106fc6c38c2cbbfcc803f76477571d7e2330130ebe8eee1
|
|
@@ -106,14 +106,18 @@ module CompletionKit
|
|
|
106
106
|
|
|
107
107
|
def fetch_ollama_models
|
|
108
108
|
raise DiscoveryError, "Ollama endpoint URL is required" if @api_endpoint.blank?
|
|
109
|
-
base_url =
|
|
110
|
-
response = fetch_connection(base_url).get("/models") do |req|
|
|
109
|
+
base_url = ollama_root_url
|
|
110
|
+
response = fetch_connection(base_url).get("/v1/models") do |req|
|
|
111
111
|
req.headers["Authorization"] = "Bearer #{@api_key}" if @api_key.present?
|
|
112
112
|
end
|
|
113
113
|
raise_fetch_error!(response) unless response.success?
|
|
114
114
|
JSON.parse(response.body).fetch("data", []).map { |e| { id: e["id"], display_name: e["id"] } }
|
|
115
115
|
end
|
|
116
116
|
|
|
117
|
+
def ollama_root_url
|
|
118
|
+
@api_endpoint.to_s.strip.delete_suffix("/").delete_suffix("/v1")
|
|
119
|
+
end
|
|
120
|
+
|
|
117
121
|
def reconcile(discovered)
|
|
118
122
|
api_model_ids = discovered.map { |m| m[:id] }
|
|
119
123
|
meta_by_id = discovered.index_by { |m| m[:id] }
|
|
@@ -336,15 +340,14 @@ module CompletionKit
|
|
|
336
340
|
end
|
|
337
341
|
|
|
338
342
|
def ollama_probe(model_id, input, max_tokens)
|
|
339
|
-
|
|
340
|
-
conn = Faraday.new(url: base_url) do |f|
|
|
343
|
+
conn = Faraday.new(url: ollama_root_url) do |f|
|
|
341
344
|
f.options.timeout = 60
|
|
342
345
|
f.options.open_timeout = 5
|
|
343
346
|
f.request :retry, max: 1, interval: 0.5
|
|
344
347
|
f.adapter Faraday.default_adapter
|
|
345
348
|
end
|
|
346
349
|
conn.post do |req|
|
|
347
|
-
req.url "/chat/completions"
|
|
350
|
+
req.url "/v1/chat/completions"
|
|
348
351
|
req.headers["Content-Type"] = "application/json"
|
|
349
352
|
req.headers["Authorization"] = "Bearer #{@api_key}" if @api_key.present?
|
|
350
353
|
req.body = { model: model_id, messages: [{ role: "user", content: input }], max_tokens: max_tokens }.to_json
|