ask-core 0.1.2 → 0.1.3

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: a2012b5b5d5214c3378ca4c17fe6a6634f051dc5662d4b2801327d29772bfe84
4
- data.tar.gz: 1b7956f7da49646219fa3202893af7ee182395506929574ad88a3b4ab46f4b43
3
+ metadata.gz: e946277b56e6e4ace450e2da7b1c36f92510b2db77544586773d88ca296c573b
4
+ data.tar.gz: 4422ae36f021a460470437097d06a84c680b76de7c8acbbbc942b477240f598b
5
5
  SHA512:
6
- metadata.gz: bede0ef124fcb49a35d7a74dd447203fbd21318581bad7b88d39af1b220f59a75994397baadaa41aeaa92eff9483bb26615a7c593d9dd5ceb74324717cc476ff
7
- data.tar.gz: 8afc76d781a2f95207a2919b8dca11c65925bc8d5575ce81ef25af0039eb662c689408e5ea19212bebe2064e4699e8526a3d85aa72bd6946af802bda149a2f5d
6
+ metadata.gz: 8776604d752f326fbb2ddb063694e364a63f1a2900073b9782eef11722837f161fdbc7ea57fe5902521b52973c6c180429c1cc92b833a475fb8591ab76572f3d
7
+ data.tar.gz: 7efbedddd31c08a2dac6c99a432631950f50cad067c71965f0b8ff72d13666ff069d8902aeba0f4f4aefbfbff1e05c8eeda2c53bdb6e1479947a11353a9df892
@@ -54,14 +54,29 @@ module Ask
54
54
  def tool? = @role == :tool
55
55
 
56
56
  # Convert to a hash suitable for provider wire format serialization.
57
- # Omits nil-valued keys.
57
+ # Omits nil-valued keys. Tool calls are converted from internal Hash format
58
+ # ({id => object with .id, .name, .arguments}) to the provider API Array format
59
+ # ([{id:, type:, function: {name:, arguments:}}]).
58
60
  # @return [Hash]
59
61
  def to_h
60
62
  base = { role: @role }
61
63
  base[:content] = @content if @content
62
64
  base[:name] = @name if @name
63
65
  base[:tool_call_id] = @tool_call_id if @tool_call_id
64
- base[:tool_calls] = @tool_calls if @tool_calls
66
+
67
+ if @tool_calls
68
+ base[:tool_calls] = @tool_calls.is_a?(Array) ? @tool_calls : @tool_calls.map do |id, tc|
69
+ {
70
+ id: tc.respond_to?(:id) ? tc.id : id,
71
+ type: "function",
72
+ function: {
73
+ name: tc.respond_to?(:name) ? tc.name : tc.to_s,
74
+ arguments: tc.respond_to?(:arguments) ? tc.arguments : "{}"
75
+ }
76
+ }
77
+ end
78
+ end
79
+
65
80
  base
66
81
  end
67
82
 
data/lib/ask/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ask
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto