ruby_llm-sequel 0.1.2 → 0.1.4
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: 330da9ca4ee162f14bf3279e78c82ec8af719912565a2f89f381cb635ac9f30a
|
|
4
|
+
data.tar.gz: 26e46591377ad3412f1088089cbcd2f7ab46a0dd8c9633c69bb44d1a77b4ec74
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3196bcf05083317ae9d13888ebf4849a8f3cc6f332061d75750b848969f571c6c564d55be559723a22dcdb4d0a0be212c69e01014a8972d37649b30491f96140
|
|
7
|
+
data.tar.gz: b35bae79b504befd0c64c5681653c427bbff4efafeb7cf154476f1197ef6ffc23073109155346c01a41733aae1bb740aa673b677d02750c2803eabd3f2bc9831
|
|
@@ -105,6 +105,11 @@ module RubyLLM
|
|
|
105
105
|
self
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
def with_thinking(...)
|
|
109
|
+
to_llm.with_thinking(...)
|
|
110
|
+
self
|
|
111
|
+
end
|
|
112
|
+
|
|
108
113
|
def on_new_message(&block)
|
|
109
114
|
to_llm
|
|
110
115
|
|
|
@@ -244,6 +249,9 @@ module RubyLLM
|
|
|
244
249
|
if @message.columns.include?(:cache_creation_tokens)
|
|
245
250
|
attrs[:cache_creation_tokens] = message.cache_creation_tokens
|
|
246
251
|
end
|
|
252
|
+
attrs[:thinking_text] = message.thinking&.text if @message.columns.include?(:thinking_text)
|
|
253
|
+
attrs[:thinking_signature] = message.thinking&.signature if @message.columns.include?(:thinking_signature)
|
|
254
|
+
attrs[:thinking_tokens] = message.thinking_tokens if @message.columns.include?(:thinking_tokens)
|
|
247
255
|
|
|
248
256
|
attrs[self.class.model_association_name] = send(self.class.model_association_name)
|
|
249
257
|
|
|
@@ -262,9 +270,13 @@ module RubyLLM
|
|
|
262
270
|
end
|
|
263
271
|
|
|
264
272
|
def persist_tool_calls(tool_calls)
|
|
273
|
+
tool_call_klass = @message.class.tool_call_class.constantize
|
|
274
|
+
supports_thought_signature = tool_call_klass.columns.include?(:thought_signature)
|
|
275
|
+
|
|
265
276
|
tool_calls.each_value do |tool_call|
|
|
266
277
|
attributes = tool_call.to_h
|
|
267
278
|
attributes[:tool_call_id] = attributes.delete(:id)
|
|
279
|
+
attributes.delete(:thought_signature) unless supports_thought_signature
|
|
268
280
|
@message.send("add_#{@message.class.tool_calls_association_name.to_s.singularize}", **attributes)
|
|
269
281
|
end
|
|
270
282
|
end
|
|
@@ -6,16 +6,19 @@ module RubyLLM
|
|
|
6
6
|
def to_llm
|
|
7
7
|
cached = columns.include?(:cached_tokens) ? self[:cached_tokens] : nil
|
|
8
8
|
cache_creation = columns.include?(:cache_creation_tokens) ? self[:cache_creation_tokens] : nil
|
|
9
|
+
thinking_tokens_val = columns.include?(:thinking_tokens) ? self[:thinking_tokens] : nil
|
|
9
10
|
|
|
10
11
|
::RubyLLM::Message.new(
|
|
11
12
|
role: role.to_sym,
|
|
12
13
|
content: extract_content,
|
|
14
|
+
thinking: extract_thinking,
|
|
13
15
|
tool_calls: extract_tool_calls,
|
|
14
16
|
tool_call_id: extract_tool_call_id,
|
|
15
17
|
input_tokens: input_tokens,
|
|
16
18
|
output_tokens: output_tokens,
|
|
17
19
|
cached_tokens: cached,
|
|
18
20
|
cache_creation_tokens: cache_creation,
|
|
21
|
+
thinking_tokens: thinking_tokens_val,
|
|
19
22
|
model_id: model_association&.model_id
|
|
20
23
|
)
|
|
21
24
|
end
|
|
@@ -30,6 +33,13 @@ module RubyLLM
|
|
|
30
33
|
|
|
31
34
|
private
|
|
32
35
|
|
|
36
|
+
def extract_thinking
|
|
37
|
+
text = columns.include?(:thinking_text) ? self[:thinking_text] : nil
|
|
38
|
+
signature = columns.include?(:thinking_signature) ? self[:thinking_signature] : nil
|
|
39
|
+
|
|
40
|
+
::RubyLLM::Thinking.build(text: text, signature: signature)
|
|
41
|
+
end
|
|
42
|
+
|
|
33
43
|
def extract_content
|
|
34
44
|
return ::RubyLLM::Content::Raw.new(content_raw) if columns.include?(:content_raw) && !content_raw.nil?
|
|
35
45
|
|
|
@@ -4,11 +4,14 @@ module RubyLLM
|
|
|
4
4
|
module Sequel
|
|
5
5
|
module ToolCallMethods
|
|
6
6
|
def to_llm
|
|
7
|
-
|
|
7
|
+
attrs = {
|
|
8
8
|
id: tool_call_id,
|
|
9
9
|
name: name,
|
|
10
10
|
arguments: parse_arguments
|
|
11
|
-
|
|
11
|
+
}
|
|
12
|
+
attrs[:thought_signature] = self[:thought_signature] if columns.include?(:thought_signature)
|
|
13
|
+
|
|
14
|
+
::RubyLLM::ToolCall.new(**attrs)
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
def result_message
|
|
@@ -174,8 +174,8 @@ module Sequel
|
|
|
174
174
|
|
|
175
175
|
plugin :association_dependencies
|
|
176
176
|
|
|
177
|
-
many_to_one message, class: message_class, key: :"#{message}_id"
|
|
178
|
-
one_to_one result, class: result_class, key: :tool_call_id
|
|
177
|
+
many_to_one message, class: message_class, key: :"#{message}_id"
|
|
178
|
+
one_to_one result, class: result_class, key: :tool_call_id
|
|
179
179
|
|
|
180
180
|
add_association_dependencies result => :nullify
|
|
181
181
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_llm-sequel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Pasquale
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '1.
|
|
18
|
+
version: '1.10'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '1.
|
|
25
|
+
version: '1.10'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: sequel
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|