omniai 1.8.0 → 1.8.1

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: 7325d58430db1dd52ecbbf7964ad9a02a3fe5ae89be51779582a672bbc8c8222
4
- data.tar.gz: 2464d2ae08fc94fad891acae6eb1ec7fbe163414a3dfb6583fd89bca52dc92d1
3
+ metadata.gz: cca8dd5cc19989ca0a3fc89d1e8f2c5a56611378a202ea8da2fd49528454ea6c
4
+ data.tar.gz: ee0abcf49b13df01ed5b63ed557de44d42d640fb966bcfb5c7592e19aff06f93
5
5
  SHA512:
6
- metadata.gz: 2d966778690e811bab403217378a748c778e043c48cdb946d9f2b3503ae3b48a165c63ab57bbba65ffa864cd9395388181b57b3c689efb548b864d58f931a757
7
- data.tar.gz: a82e9b1b092c4df179a4d2b931f6d2c217ba1976504fd40179bc9c0549ab9c9fd349e3eedb79df2c3e30cde1a1ea3b236b99449074c10da381171e1d560314e8
6
+ metadata.gz: eb48e8f76d7cd1836ad8dc0ceb577362a3f289026749e2cc49044e31d25758a625ff66fe8003be12dc09585d9ee571671dd4f6d0b8c355cc7962eb4c136ec9f0
7
+ data.tar.gz: 41cf6419a3cf3c1662e2f6c5925ae5a05e991f6f2e8f81bcf3d5dfb62ad029bf3d6c32565892ef81acc651a43533dc3a7e9efb2c75922bbdddf28bb29e18b3c2
data/README.md CHANGED
@@ -179,12 +179,12 @@ tool = OmniAI::Tool.new(
179
179
  parameters: OmniAI::Tool::Parameters.new(
180
180
  properties: {
181
181
  location: OmniAI::Tool::Property.string(description: 'e.g. Toronto'),
182
- unit: OmniAI::Tool::Property.string(enum: %w[celcius farenheit]),
182
+ unit: OmniAI::Tool::Property.string(enum: %w[celcius fahrenheit]),
183
183
  },
184
184
  required: %i[location]
185
185
  )
186
186
  )
187
- client.chat('What is the weather in "London" and "Madrid"?', tools: [tool])
187
+ client.chat('What is the weather in "London" in celcius and "Paris" in fahrenheit?', tools: [tool])
188
188
  ```
189
189
 
190
190
  ### Transcribe
@@ -24,10 +24,10 @@ module OmniAI
24
24
  end
25
25
 
26
26
  # @return [Hash]
27
- def prepare
27
+ def serialize
28
28
  {
29
29
  type: @type,
30
- properties: @properties.transform_values(&:prepare),
30
+ properties: @properties.transform_values(&:serialize),
31
31
  required: @required,
32
32
  }.compact
33
33
  end
@@ -60,7 +60,7 @@ module OmniAI
60
60
  end
61
61
 
62
62
  # @example
63
- # property.prepare
63
+ # property.serialize
64
64
  # # {
65
65
  # # type: 'string',
66
66
  # # description: 'The unit (e.g. "fahrenheit" or "celsius").'
@@ -68,7 +68,7 @@ module OmniAI
68
68
  # # }
69
69
  #
70
70
  # @return [Hash]
71
- def prepare
71
+ def serialize
72
72
  {
73
73
  type: @type,
74
74
  description: @description,
data/lib/omniai/tool.rb CHANGED
@@ -53,7 +53,10 @@ module OmniAI
53
53
  # # parameters: {
54
54
  # # type: 'object',
55
55
  # # properties: {
56
- # # n: OmniAI::Tool::Property.integer(description: 'The nth Fibonacci number to calculate')
56
+ # # n: {
57
+ # # description: 'The nth Fibonacci number to calculate')
58
+ # # type: 'integer'
59
+ # # }
57
60
  # # },
58
61
  # # required: ['n']
59
62
  # # }
@@ -71,7 +74,7 @@ module OmniAI
71
74
  function: {
72
75
  name: @name,
73
76
  description: @description,
74
- parameters: @parameters&.prepare,
77
+ parameters: @parameters.is_a?(Tool::Parameters) ? @parameters.serialize : @parameters,
75
78
  }.compact,
76
79
  }
77
80
  end
@@ -83,7 +86,7 @@ module OmniAI
83
86
  # @param args [Hash]
84
87
  # @return [String]
85
88
  def call(args = {})
86
- @function.call(**(@parameters ? @parameters.parse(args) : args))
89
+ @function.call(**(@parameters.is_a?(Tool::Parameters) ? @parameters.parse(args) : args))
87
90
  end
88
91
  end
89
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniAI
4
- VERSION = '1.8.0'
4
+ VERSION = '1.8.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-16 00:00:00.000000000 Z
11
+ date: 2024-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: event_stream_parser