intelligence 0.8.0 → 1.0.0.beta01

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35084b4f3df27ee21c0a21a759b74bcca9c05c6b47e0311026d6e6587f8661a3
4
- data.tar.gz: 76afc7ad3e1f2e3637c82e8613b492680be20962ca5daf263d3c457968512c04
3
+ metadata.gz: 02df79612b47068ee3792e78566e94160741db46f22c5ff8a97947a09872fe5f
4
+ data.tar.gz: e2bf793c4bf2feb17798e0a59bdc2272cdac9e95b9cd2c31b386d973601bfcdf
5
5
  SHA512:
6
- metadata.gz: 643f9acfde921655b5861901f5ea11646d00e9673a852e8546ec112a275d9f4e695934c314c577ca5cf44684ee3ce86b57cb5da9100e67b5c016c3bd90672f14
7
- data.tar.gz: 6a9bb70335d3cd9f5b5ef48f1029e8b7997d880a1ebed37168c6d5cae88ec4abb48c2c8ffb95ef63c5b4b82a0e5c00904b0320321c124d8cf24fabb1928e5453
6
+ metadata.gz: 12bf185efa0bbd063699fc25cd33ada8729a6a95fda62ec4535319dc88b92764fb43677421cfb714f02aa766ec3e52740f018241f1632f0ea938c08543f0e62b
7
+ data.tar.gz: 221871ceb024b137d2e77810ea4ef840bbe161248a72dd69c8d184af4ce176664993dbb6d3d36bc91bbb89b3c2ed8515a2692f681d7e82894c147d83e7e2bda3
@@ -35,6 +35,19 @@ module Intelligence
35
35
  response_mime_type String, as: :responseMimeType
36
36
  response_schema as: :responseSchema
37
37
 
38
+ # google tools setup
39
+ tools do
40
+ google_search as: :google_search_retrieval do
41
+ dynamic_retrieval as: :dynamic_retrieval_config, default: {} do
42
+ mode String, default: 'MODE_DYNAMIC'
43
+ threshold Float, as: :dynamic_threshold, in: 0..1, default: 0.3
44
+ end
45
+ end
46
+
47
+ code_execution do
48
+ end
49
+ end
50
+
38
51
  # google specific tool configuration
39
52
  tool_configuration as: :tool_config do
40
53
  function_calling as: :function_calling_config do
@@ -61,16 +61,33 @@ module Intelligence
61
61
  # discard properties not part of the google generationConfig schema
62
62
  gc.delete( :model )
63
63
  gc.delete( :stream )
64
-
64
+
65
+ # googlify tools
66
+ tools = gc.delete( :tools )
67
+ if tools&.any?
68
+ tools = tools.then do | tools_object |
69
+ tools_array ||= []
70
+ tools_object.each { | key, value | tools_array << { key => value } }
71
+ tools_array
72
+ end
73
+ end
74
+ tool_functions = to_google_tools( conversation[ :tools ] )
75
+ if tool_functions&.any?
76
+ tools ||= {}
77
+ tools[ :function_declarations ] ||= []
78
+ tools[ :function_declarations ].concat( tool_functions )
79
+ end
80
+
65
81
  # googlify tool configuration
66
82
  if tool_config = gc.delete( :tool_config )
67
83
  mode = tool_config[ :function_calling_config ]&.[]( :mode )
68
84
  tool_config[ :function_calling_config ][ :mode ] = mode.to_s.upcase if mode
69
85
  end
70
-
86
+
71
87
  result = {}
72
88
  result[ :generationConfig ] = gc
73
- result[ :tool_config ] = tool_config if tool_config
89
+ result[ :tools ] = tools if tools
90
+ result[ :tool_config ] = tool_config if tools && tool_config
74
91
 
75
92
  # construct the system prompt in the form of the google schema
76
93
  system_instructions = to_google_system_message( conversation[ :system_message ] )
@@ -163,10 +180,6 @@ module Intelligence
163
180
 
164
181
  end
165
182
 
166
- tools_attributes = to_google_tools( conversation[ :tools ] )
167
- result[ :tools ] = [ { function_declarations: tools_attributes } ] \
168
- if tools_attributes&.any?
169
-
170
183
  JSON.generate( result )
171
184
  end
172
185
 
@@ -40,9 +40,8 @@ module Intelligence
40
40
  end
41
41
  logit_bias
42
42
  logprobs [ TrueClass, FalseClass ]
43
+ top_logprobs Integer
43
44
  modalities String, array: true
44
- # the parallel_tool_calls parameter is only allowed when 'tools' are specified
45
- parallel_tool_calls [ TrueClass, FalseClass ]
46
45
  response_format do
47
46
  # 'text' and 'json_schema' are the only supported types
48
47
  type Symbol, in: [ :text, :json_schema ]
@@ -52,9 +51,34 @@ module Intelligence
52
51
  stream_options do
53
52
  include_usage [ TrueClass, FalseClass ]
54
53
  end
55
- tool_choice
56
- top_logprobs Integer
57
- user
54
+ user
55
+
56
+ # open ai tool configuration; this allows you to enable build in tools ( currently
57
+ # that's just 'code_interpreter' )
58
+ #
59
+ # tool :code_interpreter
60
+ #
61
+ #tool array: true, as: :tools, arguments: :type
62
+ # type Symbol
63
+ #end
64
+
65
+ # open ai tool choice configuration
66
+ #
67
+ # `tool_choice :none`
68
+ # or
69
+ # ```
70
+ # tool_choice :function do
71
+ # function :my_function
72
+ # end
73
+ # ```
74
+ tool_choice arguments: :type do
75
+ type Symbol, in: [ :none, :auto, :required ]
76
+ function arguments: :name do
77
+ name Symbol
78
+ end
79
+ end
80
+ # the parallel_tool_calls parameter is only allowed when 'tools' are specified
81
+ parallel_tool_calls [ TrueClass, FalseClass ]
58
82
 
59
83
  end
60
84
 
@@ -1,3 +1,3 @@
1
1
  module Intelligence
2
- VERSION = "0.8.0"
2
+ VERSION = "1.0.0.beta01"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intelligence
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.0.0.beta01
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristoph Cichocki-Romanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-31 00:00:00.000000000 Z
11
+ date: 2024-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday