ask-core 0.1.1 → 0.1.2
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 +4 -4
- data/lib/ask/models.rb +2 -1
- data/lib/ask/stream.rb +8 -1
- data/lib/ask/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2012b5b5d5214c3378ca4c17fe6a6634f051dc5662d4b2801327d29772bfe84
|
|
4
|
+
data.tar.gz: 1b7956f7da49646219fa3202893af7ee182395506929574ad88a3b4ab46f4b43
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bede0ef124fcb49a35d7a74dd447203fbd21318581bad7b88d39af1b220f59a75994397baadaa41aeaa92eff9483bb26615a7c593d9dd5ceb74324717cc476ff
|
|
7
|
+
data.tar.gz: 8afc76d781a2f95207a2919b8dca11c65925bc8d5575ce81ef25af0039eb662c689408e5ea19212bebe2064e4699e8526a3d85aa72bd6946af802bda149a2f5d
|
data/lib/ask/models.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
|
+
require "timeout"
|
|
4
5
|
require "net/http"
|
|
5
6
|
require "time"
|
|
6
7
|
|
|
@@ -421,7 +422,7 @@ module Ask
|
|
|
421
422
|
http.read_timeout = timeout
|
|
422
423
|
|
|
423
424
|
request = Net::HTTP::Get.new(uri)
|
|
424
|
-
response = http.request(request)
|
|
425
|
+
response = Timeout.timeout(timeout) { http.request(request) }
|
|
425
426
|
|
|
426
427
|
unless response.is_a?(Net::HTTPOK)
|
|
427
428
|
warn "Failed to fetch models.dev: HTTP #{response.code}. Keeping existing models."
|
data/lib/ask/stream.rb
CHANGED
|
@@ -19,12 +19,16 @@ module Ask
|
|
|
19
19
|
# @return [Hash, nil] raw response data from the provider
|
|
20
20
|
attr_reader :raw
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
# @return [String, nil] reasoning/thinking text from the model (e.g. chain-of-thought)
|
|
23
|
+
attr_reader :thinking
|
|
24
|
+
|
|
25
|
+
def initialize(content: nil, tool_calls: nil, finish_reason: nil, usage: nil, raw: nil, thinking: nil)
|
|
23
26
|
@content = content
|
|
24
27
|
@tool_calls = tool_calls
|
|
25
28
|
@finish_reason = finish_reason
|
|
26
29
|
@usage = usage
|
|
27
30
|
@raw = raw
|
|
31
|
+
@thinking = thinking
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
# @return [Boolean] true if this is the final chunk in a stream
|
|
@@ -33,6 +37,9 @@ module Ask
|
|
|
33
37
|
# @return [Boolean] true if this chunk contains tool calls
|
|
34
38
|
def tool_call? = @tool_calls&.any? == true
|
|
35
39
|
|
|
40
|
+
# @return [Boolean] true if this chunk contains thinking/reasoning content
|
|
41
|
+
def thinking? = @thinking.to_s.length > 0
|
|
42
|
+
|
|
36
43
|
# @return [String] text content as a plain string
|
|
37
44
|
def to_s
|
|
38
45
|
@content.to_s
|
data/lib/ask/version.rb
CHANGED