omniai 2.4.2 → 2.5.0
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/omniai/chat/tool_call_result.rb +18 -5
- data/lib/omniai/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: 89f3eb0b1c62e35bc437833ad64c2c48504ead7bab049b1fc13cbdde30f5c6fe
|
4
|
+
data.tar.gz: bd8f3e7692996e622e245bd82f4fccc86df703836062d9542d59ec8119e09fe7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb4748a2dc375e1e36dc096605adacd9822e9f7217ffb5a5c0516bbd21f18228dfdcc329346308ccc9b7a114bc24ee2a5abf04e3c09e06ee50cceac72f8f6d09
|
7
|
+
data.tar.gz: 6c814845c8fed1e20a042abe94c9ba74227f671a00b9551c79b1b12faedac2a7a998e9a325c942e8b07bdc1ebe55f62ef13563eb982b07ef27b9046695b00295
|
@@ -4,13 +4,15 @@ module OmniAI
|
|
4
4
|
class Chat
|
5
5
|
# The result of a tool call.
|
6
6
|
class ToolCallResult
|
7
|
-
#
|
7
|
+
# @!attribute [rw] content
|
8
|
+
# @return [Object]
|
8
9
|
attr_accessor :content
|
9
10
|
|
10
|
-
#
|
11
|
+
# @!attribute [rw] tool_call_id
|
12
|
+
# @return [ToolCall]
|
11
13
|
attr_accessor :tool_call_id
|
12
14
|
|
13
|
-
# @param content [Object]
|
15
|
+
# @param content [Object] e.g. a string, hash, array, boolean, numeric, etc.
|
14
16
|
# @param tool_call_id [String]
|
15
17
|
def initialize(content:, tool_call_id:)
|
16
18
|
@content = content
|
@@ -22,13 +24,23 @@ module OmniAI
|
|
22
24
|
"#<#{self.class.name} content=#{content.inspect} tool_call_id=#{tool_call_id.inspect}>"
|
23
25
|
end
|
24
26
|
|
27
|
+
# Converts the content of a tool call result to JSON unless the result is a string.
|
28
|
+
#
|
29
|
+
# @return [String, nil]
|
30
|
+
def text
|
31
|
+
return content if content.nil? || content.is_a?(String)
|
32
|
+
|
33
|
+
JSON.generate(@content)
|
34
|
+
end
|
35
|
+
|
25
36
|
# @param context [Context] optional
|
37
|
+
#
|
26
38
|
# @return [Hash]
|
27
39
|
def serialize(context: nil)
|
28
40
|
serializer = context&.serializer(:tool_call_result)
|
29
41
|
return serializer.call(self, context:) if serializer
|
30
42
|
|
31
|
-
content =
|
43
|
+
content = text
|
32
44
|
tool_call_id = @tool_call_id
|
33
45
|
|
34
46
|
{ content:, tool_call_id: }
|
@@ -36,12 +48,13 @@ module OmniAI
|
|
36
48
|
|
37
49
|
# @param data [Hash]
|
38
50
|
# @param context [Context] optional
|
51
|
+
#
|
39
52
|
# @return [ToolCallResult]
|
40
53
|
def self.deserialize(data, context: nil)
|
41
54
|
deserialize = context&.deserializer(:tool_call_result)
|
42
55
|
return deserialize.call(data, context:) if deserialize
|
43
56
|
|
44
|
-
content =
|
57
|
+
content = data["content"]
|
45
58
|
tool_call_id = data["tool_call_id"]
|
46
59
|
|
47
60
|
new(content:, tool_call_id:)
|
data/lib/omniai/version.rb
CHANGED