ask-core 0.1.3 → 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: e946277b56e6e4ace450e2da7b1c36f92510b2db77544586773d88ca296c573b
4
- data.tar.gz: 4422ae36f021a460470437097d06a84c680b76de7c8acbbbc942b477240f598b
3
+ metadata.gz: ade09594597628220a63aa89dc9c76c8ee38b4aed90d2e9f4e31cfa01dd528e7
4
+ data.tar.gz: 5e08465e65c3730fa6e2e1edce2969e050a28c5dd0fb7b3e93941e337aadd13e
5
5
  SHA512:
6
- metadata.gz: 8776604d752f326fbb2ddb063694e364a63f1a2900073b9782eef11722837f161fdbc7ea57fe5902521b52973c6c180429c1cc92b833a475fb8591ab76572f3d
7
- data.tar.gz: 7efbedddd31c08a2dac6c99a432631950f50cad067c71965f0b8ff72d13666ff069d8902aeba0f4f4aefbfbff1e05c8eeda2c53bdb6e1479947a11353a9df892
6
+ metadata.gz: 855bfe670f67cbead6c7d3cadf0928034222fa99cd018066c3c0703ca15ab2bbac9d19cea2c56bdb07010309d87c1bc094ae44c3fd09aff06c5884a3b1eff238
7
+ data.tar.gz: f361f34373a234823e206b7e4ce0ccb2bd188c8cf5091b227e0ea58c2407c985ad456db3f8c5dad4d4cefd24126a72c6f70935fc4ec7ca55376bceefbd366feb
@@ -65,15 +65,32 @@ module Ask
65
65
  base[:tool_call_id] = @tool_call_id if @tool_call_id
66
66
 
67
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
- }
68
+ base[:tool_calls] = @tool_calls.is_a?(Array) ? @tool_calls : @tool_calls.map do |id_val, tc|
69
+ tc_id = if tc.respond_to?(:id)
70
+ tc.id
71
+ elsif tc.is_a?(Hash)
72
+ tc[:id] || tc["id"] || id_val
73
+ else
74
+ id_val
75
+ end
76
+
77
+ tc_name = if tc.respond_to?(:name)
78
+ tc.name
79
+ elsif tc.is_a?(Hash)
80
+ tc.dig(:function, :name) || tc.dig("function", "name") || tc[:name] || tc["name"] || id_val
81
+ else
82
+ id_val
83
+ end
84
+
85
+ tc_args = if tc.respond_to?(:arguments)
86
+ tc.arguments
87
+ elsif tc.is_a?(Hash)
88
+ tc.dig(:function, :arguments) || tc.dig("function", "arguments") || tc[:arguments] || tc["arguments"] || "{}"
89
+ else
90
+ "{}"
91
+ end
92
+
93
+ { id: tc_id, type: "function", function: { name: tc_name, arguments: tc_args } }
77
94
  end
78
95
  end
79
96
 
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.3"
4
+ VERSION = "0.1.4"
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto