intelligence 0.6.0 → 0.8.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +576 -0
  3. data/intelligence.gemspec +2 -1
  4. data/lib/intelligence/adapter/base.rb +13 -6
  5. data/lib/intelligence/adapter/class_methods.rb +15 -0
  6. data/lib/intelligence/adapter/module_methods.rb +41 -0
  7. data/lib/intelligence/adapter.rb +2 -2
  8. data/lib/intelligence/adapters/anthropic/adapter.rb +21 -19
  9. data/lib/intelligence/adapters/anthropic/chat_request_methods.rb +189 -0
  10. data/lib/intelligence/adapters/anthropic/{chat_methods.rb → chat_response_methods.rb} +13 -137
  11. data/lib/intelligence/adapters/cerebras.rb +19 -19
  12. data/lib/intelligence/adapters/generic/adapter.rb +4 -2
  13. data/lib/intelligence/adapters/generic/chat_request_methods.rb +221 -0
  14. data/lib/intelligence/adapters/generic/chat_response_methods.rb +234 -0
  15. data/lib/intelligence/adapters/generic.rb +1 -1
  16. data/lib/intelligence/adapters/google/adapter.rb +33 -22
  17. data/lib/intelligence/adapters/google/chat_request_methods.rb +234 -0
  18. data/lib/intelligence/adapters/google/chat_response_methods.rb +236 -0
  19. data/lib/intelligence/adapters/groq.rb +29 -49
  20. data/lib/intelligence/adapters/hyperbolic.rb +13 -39
  21. data/lib/intelligence/adapters/mistral.rb +21 -42
  22. data/lib/intelligence/adapters/open_ai/adapter.rb +39 -32
  23. data/lib/intelligence/adapters/open_ai/chat_request_methods.rb +186 -0
  24. data/lib/intelligence/adapters/open_ai/chat_response_methods.rb +239 -0
  25. data/lib/intelligence/adapters/open_ai.rb +1 -1
  26. data/lib/intelligence/adapters/open_router.rb +18 -18
  27. data/lib/intelligence/adapters/samba_nova.rb +16 -18
  28. data/lib/intelligence/adapters/together_ai.rb +25 -23
  29. data/lib/intelligence/conversation.rb +11 -10
  30. data/lib/intelligence/message.rb +45 -29
  31. data/lib/intelligence/message_content/base.rb +2 -9
  32. data/lib/intelligence/message_content/binary.rb +3 -3
  33. data/lib/intelligence/message_content/file.rb +3 -3
  34. data/lib/intelligence/message_content/text.rb +10 -2
  35. data/lib/intelligence/message_content/tool_call.rb +61 -5
  36. data/lib/intelligence/message_content/tool_result.rb +11 -6
  37. data/lib/intelligence/tool.rb +139 -0
  38. data/lib/intelligence/version.rb +1 -1
  39. data/lib/intelligence.rb +3 -1
  40. metadata +31 -13
  41. data/lib/intelligence/adapter/class_methods/construction.rb +0 -17
  42. data/lib/intelligence/adapter/module_methods/construction.rb +0 -43
  43. data/lib/intelligence/adapters/generic/chat_methods.rb +0 -355
  44. data/lib/intelligence/adapters/google/chat_methods.rb +0 -393
  45. data/lib/intelligence/adapters/legacy/adapter.rb +0 -11
  46. data/lib/intelligence/adapters/legacy/chat_methods.rb +0 -54
  47. data/lib/intelligence/adapters/open_ai/chat_methods.rb +0 -345
@@ -1,33 +1,33 @@
1
- require_relative 'legacy/adapter'
1
+ require_relative 'generic/adapter'
2
2
 
3
3
  module Intelligence
4
4
  module SambaNova
5
5
 
6
- class Adapter < Legacy::Adapter
6
+ class Adapter < Generic::Adapter
7
7
 
8
8
  chat_request_uri "https://api.sambanova.ai/v1/chat/completions"
9
9
 
10
- configuration do
10
+ schema do
11
11
 
12
12
  # normalized properties for all endpoints
13
- parameter :key, String
13
+ key String
14
14
 
15
15
  # properties for generative text endpoints
16
- group :chat_options do
16
+ chat_options do
17
17
 
18
18
  # normalized properties for samba nova generative text endpoint
19
- parameter :model, String
20
- parameter :max_tokens, Integer
21
- parameter :temperature, Float
22
- parameter :top_p, Float
23
- parameter :top_k, Float
24
- parameter :stop, String, array: true
25
- parameter :stream, [ TrueClass, FalseClass ]
19
+ model String
20
+ max_tokens Integer
21
+ temperature Float
22
+ top_p Float
23
+ top_k Float
24
+ stop String, array: true
25
+ stream [ TrueClass, FalseClass ]
26
26
 
27
27
  # samba nova properties for samba nova generative text endpoint
28
- parameter :repetition_penalty, Float
29
- group :stream_options do
30
- parameter :include_usage, [ TrueClass, FalseClass ]
28
+ repetition_penalty Float
29
+ stream_options do
30
+ include_usage [ TrueClass, FalseClass ]
31
31
  end
32
32
 
33
33
  end
@@ -35,8 +35,7 @@ module Intelligence
35
35
  end
36
36
 
37
37
  def chat_result_error_attributes( response )
38
-
39
- error_type, error_description = translate_error_response_status( response.status )
38
+ error_type, error_description = to_error_response( response.status )
40
39
  result = {
41
40
  error_type: error_type.to_s,
42
41
  error_description: error_description
@@ -55,7 +54,6 @@ module Intelligence
55
54
  end
56
55
 
57
56
  result
58
-
59
57
  end
60
58
 
61
59
  end
@@ -1,39 +1,41 @@
1
- require_relative 'legacy/adapter'
1
+ require_relative 'generic/adapter'
2
2
 
3
3
  module Intelligence
4
4
  module TogetherAi
5
5
 
6
- class Adapter < Legacy::Adapter
6
+ class Adapter < Generic::Adapter
7
7
 
8
8
  chat_request_uri "https://api.together.xyz/v1/chat/completions"
9
9
 
10
- configuration do
11
- parameter :key, String
12
- group :chat_options do
13
- parameter :model, String
14
- parameter :temperature, Float
15
- parameter :top_p, Float
16
- parameter :top_k, Integer
17
- parameter :n, Integer
18
- parameter :max_tokens, Float
19
- parameter :stop, String, array: true
20
- parameter :stream, [ TrueClass, FalseClass ]
21
- parameter :frequency_penalty, Float
22
- parameter :presence_penalty, Float
23
- parameter :repetition_penalty, Float
24
- parameter :user, String
10
+ schema do
11
+ key String
12
+ chat_options do
13
+ model String
14
+ temperature Float
15
+ top_p Float
16
+ top_k Integer
17
+ n Integer
18
+ max_tokens Float
19
+ stop String, array: true
20
+ stream [ TrueClass, FalseClass ]
21
+ frequency_penalty Float
22
+ presence_penalty Float
23
+ repetition_penalty Float
24
+ user String
25
25
  end
26
26
  end
27
27
 
28
- def translate_end_result( end_result )
28
+ def to_end_reason( end_result )
29
29
  case end_result
30
- when 'eos'
30
+ when 'eos', 'stop'
31
31
  :ended
32
- when 'length'
32
+ # unfortunatelly eos seems to only work with certain models while others always return
33
+ # stop so for now tomorrow ai will not support :end_sequence_encountered
34
+ # when 'stop'
35
+ # :end_sequence_encountered
36
+ when 'length'
33
37
  :token_limit_exceeded
34
- when 'stop'
35
- :end_sequence_encountered
36
- when 'function_call'
38
+ when 'tool_calls'
37
39
  :tool_called
38
40
  else
39
41
  nil
@@ -1,16 +1,12 @@
1
1
  module Intelligence
2
2
  class Conversation
3
3
 
4
- extend AdaptiveConfiguration::Configurable
4
+ include DynamicSchema::Definable
5
+ include DynamicSchema::Buildable
5
6
 
6
- configuration do
7
- group :system_message, default: { role: :system }, &Message::CONFIGURATION
8
- group :message, as: :messages, array: true, &Message::CONFIGURATION
9
- end
10
-
11
- def self.build( attributes = nil, &block )
12
- configuration = self.configure( attributes, &block )
13
- self.new( configuration.to_h )
7
+ schema do
8
+ system_message default: { role: :system }, &Message.schema
9
+ message as: :messages, array: true, &Message.schema
14
10
  end
15
11
 
16
12
  attr_reader :system_message
@@ -22,7 +18,7 @@ module Intelligence
22
18
  @messages = []
23
19
  @tools = []
24
20
  if attributes
25
- if attributes[ :system_message ]
21
+ if attributes[ :system_message ]&.any?
26
22
  system_message = Message.new(
27
23
  attributes[ :system_message ][ :role ],
28
24
  attributes[ :system_message ]
@@ -64,6 +60,11 @@ module Intelligence
64
60
 
65
61
  alias :<< :append_message
66
62
 
63
+ def append_tool( *tools )
64
+ @tools.concat( tools.flatten )
65
+ self
66
+ end
67
+
67
68
  def to_h
68
69
  result = {}
69
70
  result[ :system_message ] = @system_message.to_h if @system_message
@@ -1,33 +1,47 @@
1
1
  module Intelligence
2
2
  class Message
3
3
 
4
- extend AdaptiveConfiguration::Configurable
4
+ include DynamicSchema::Definable
5
5
 
6
6
  ROLES = [ :system, :user, :assistant ]
7
- CONFIGURATION = Proc.new do
8
- parameter :role, Symbol, required: true
9
- group :content, array: true, as: :contents do
10
- parameter :type, Symbol, default: :text
11
- parameter :text, String
12
- parameter :content_type, String
13
- parameter :bytes, String
14
- parameter :uri, URI
7
+ schema do
8
+ role Symbol, required: true
9
+ content array: true, as: :contents do
10
+ type Symbol, default: :text
11
+
12
+ # note: we replicate these schema elements of the individual content types here to
13
+ # provide more semantic flexibility when building a message; we don't delegate to the
14
+ # individual content type schemas because, unlike for a specific content type, not all
15
+ # attributes are required
16
+
17
+ # text
18
+ text String
19
+ # binary and file
20
+ content_type String
21
+ bytes String
22
+ uri URI
23
+ # tool call and tool result
24
+ tool_call_id String
25
+ tool_name String
26
+ tool_parameters [ Hash, String ]
27
+ tool_result [ Hash, String ]
15
28
  end
16
29
  end
17
30
 
18
- configuration( &CONFIGURATION )
19
-
20
31
  attr_reader :role
21
32
  attr_reader :contents
22
33
 
23
34
  ##
24
- # The build! class method constructs and returns a new +Message+ instance. The build! method
25
- # accepts message +attributes+ and a block, which may be combined when constructing a Message.
26
- # The +role+ is required, either as a paramter or in the block. If the role is not present,
27
- # an exception will be raised.
35
+ # The +build!+ class method constructs and returns a new +Message+ instance. The +build!+
36
+ # method accepts message +attributes+ and a block, which may be combined when constructing
37
+ # a +Message+. The +role+ is required, either as an attribute or in the block. If the +role+
38
+ # is not present, an exception will be raised.
28
39
  #
29
40
  # The block offers the +role+ method, as well as a +content+ method permiting the caller to
30
41
  # set the role and add content respectivelly.
42
+ #
43
+ # Note that there is no corresponding +build+ method because a +Message+ strictly requires a
44
+ # +role+. It cannot be constructed without one.
31
45
  #
32
46
  # === examples
33
47
  #
@@ -50,19 +64,21 @@ module Intelligence
50
64
  # content type: :binary do
51
65
  # content_type 'image/png'
52
66
  # bytes File.binread( '99_red_balloons.png' )
67
+ # end
68
+ # end
53
69
  #
54
70
  def self.build!( attributes = nil, &block )
55
- configuration = self.configure!( attributes, &block ).to_h
56
- self.new( configuration[ :role ], configuration )
71
+ attributes = self.builder.build!( attributes, &block )
72
+ self.new( attributes[ :role ], attributes )
57
73
  end
58
74
 
59
75
  def initialize( role, attributes = nil )
60
- raise ArgumentError.new( "The role is invalid. It must be one of #{ROLES.join( ', ' )}." ) \
61
- unless ROLES.include?( role&.to_sym )
62
-
63
- @role = role.to_sym
76
+ @role = role&.to_sym
64
77
  @contents = []
65
78
 
79
+ raise ArgumentError.new( "The role is invalid. It must be one of #{ROLES.join( ', ' )}." ) \
80
+ unless ROLES.include?( @role )
81
+
66
82
  if attributes && attributes[ :contents ]
67
83
  attributes[ :contents ].each do | content |
68
84
  @contents << MessageContent.build!( content[ :type ], content )
@@ -93,18 +109,11 @@ module Intelligence
93
109
  def text
94
110
  result = []
95
111
  each_content do | content |
96
- result << content.text if content.is_a?( MessageContent::Text )
112
+ result << content.text if content.is_a?( MessageContent::Text ) && content.text
97
113
  end
98
114
  result.join( "\n" )
99
115
  end
100
116
 
101
- def to_h
102
- {
103
- role: @role,
104
- contents: @contents.map { | c | c.to_h }
105
- }
106
- end
107
-
108
117
  def each_content( &block )
109
118
  @contents.each( &block )
110
119
  end
@@ -116,5 +125,12 @@ module Intelligence
116
125
 
117
126
  alias :<< :append_content
118
127
 
128
+ def to_h
129
+ {
130
+ role: @role,
131
+ contents: @contents.map { | c | c.to_h }
132
+ }
133
+ end
134
+
119
135
  end
120
136
  end
@@ -2,16 +2,9 @@ module Intelligence
2
2
  module MessageContent
3
3
 
4
4
  class Base
5
- extend AdaptiveConfiguration::Configurable
5
+ include DynamicSchema::Definable
6
+ include DynamicSchema::Buildable
6
7
 
7
- def self.build( attributes = nil, &block )
8
- self.new( self.configure( attributes, &block ) )
9
- end
10
-
11
- def self.build!( attributes = nil, &block )
12
- self.new( self.configure!( attributes, &block ) )
13
- end
14
-
15
8
  def initialize( attributes = {} )
16
9
  attributes.each do | key, value |
17
10
  instance_variable_set( "@#{key}", value.freeze ) if self.respond_to?( "#{key}" )
@@ -3,9 +3,9 @@ module Intelligence
3
3
 
4
4
  class Binary < Base
5
5
 
6
- configuration do
7
- parameter :content_type, String, required: true
8
- parameter :bytes, String, required: true
6
+ schema do
7
+ content_type String, required: true
8
+ bytes String, required: true
9
9
  end
10
10
 
11
11
  attr_reader :content_type
@@ -3,9 +3,9 @@ module Intelligence
3
3
 
4
4
  class File < Base
5
5
 
6
- configuration do
7
- parameter :content_type, String
8
- parameter :uri, URI, required: true
6
+ schema do
7
+ content_type String
8
+ uri URI, required: true
9
9
  end
10
10
 
11
11
  def initialize( attributes )
@@ -3,8 +3,8 @@ module Intelligence
3
3
 
4
4
  class Text < Base
5
5
 
6
- configuration do
7
- parameter :text, String, required: true
6
+ schema do
7
+ text String, required: true
8
8
  end
9
9
 
10
10
  attr_reader :text
@@ -13,6 +13,14 @@ module Intelligence
13
13
  ( text || false ) && text.respond_to?( :empty? ) && !text.empty?
14
14
  end
15
15
 
16
+ def merge( other )
17
+ other_text = other.text
18
+ text = @text
19
+ text = ( @text || '' ) + other_text if other_text
20
+
21
+ self.class.new( text: text )
22
+ end
23
+
16
24
  def to_h
17
25
  { type: :text, text: text }
18
26
  end
@@ -3,15 +3,71 @@ module Intelligence
3
3
 
4
4
  class ToolCall < Base
5
5
 
6
- configuration do
7
- parameter :tool_call_id, String
8
- parameter :tool_name, String, required: true
9
- parameter :tool_parameters, String, array: true
6
+ schema do
7
+ tool_call_id String
8
+ tool_name String, required: true
9
+ tool_parameters [ Hash, String ]
10
10
  end
11
11
 
12
12
  attr_reader :tool_call_id
13
13
  attr_reader :tool_name
14
- attr_reader :tool_parameters
14
+
15
+ def tool_parameters( options = nil )
16
+ return @tool_parameters if @tool_parameters.nil? || @tool_parameters.is_a?( Hash )
17
+
18
+ options = options || {}
19
+ parse = options.key?( :parse ) ? options[ :parse ] : true
20
+
21
+ return @parsed_tool_parameters if @parsed_tool_parameters && parse
22
+
23
+ tool_parameters = ( options.key?( :repair ) ? options[ :repair ] : true ) ?
24
+ JSON.repair( @tool_parameters ) : @tool_parameters
25
+
26
+ if parse
27
+ @parsed_tool_parameters = tool_parameters =
28
+ JSON.parse(
29
+ tool_parameters,
30
+ parse.is_a?( Hash ) ? parse : { symbolize_names: true }
31
+ )
32
+ end
33
+
34
+ tool_parameters
35
+ end
36
+
37
+ def valid?
38
+ tool_name && !tool_name.empty?
39
+ end
40
+
41
+ def merge( other_tool_call )
42
+ other_tool_call_id = other_tool_call.tool_call_id
43
+ other_tool_name = other_tool_call.tool_name
44
+ other_tool_parameters = other_tool_call.tool_parameters( repair: false, parse: false )
45
+
46
+ raise ArgumentError,
47
+ "The given tool call parameters are incompative with this tool's parameters." \
48
+ unless @tool_parameters.nil? || other_tool_parameters.nil? ||
49
+ @tool_parameters.is_a?( other_tool_parameters.class )
50
+
51
+ tool_call_id = other_tool_call_id.nil? ?
52
+ @tool_call_id : @tool_call_id || '' + other_tool_call_id
53
+ tool_name = other_tool_name.nil? ?
54
+ @tool_name : @tool_name || '' + other_tool_name
55
+ tool_parameters = @tool_parameters
56
+
57
+ unless other_tool_parameters.nil?
58
+ if other_tool_parameters.is_a?( Hash )
59
+ tool_parameters = ( tool_parameters || {} ).merge( other_tool_parameters )
60
+ else
61
+ tool_parameters = ( tool_parameters || '' ) + other_tool_parameters
62
+ end
63
+ end
64
+
65
+ self.class.new(
66
+ tool_call_id: tool_call_id,
67
+ tool_name: tool_name,
68
+ tool_parameters: tool_parameters
69
+ )
70
+ end
15
71
 
16
72
  def to_h
17
73
  {
@@ -3,22 +3,27 @@ module Intelligence
3
3
 
4
4
  class ToolResult < Base
5
5
 
6
- configuration do
7
- parameter :tool_call_id
8
- parameter :tool_name, String, required: true
9
- parameter :tool_result, String, required: true
6
+ schema do
7
+ tool_call_id
8
+ tool_name String, required: true
9
+ tool_result [ Hash, String ]
10
10
  end
11
11
 
12
12
  attr_reader :tool_call_id
13
13
  attr_reader :tool_name
14
14
  attr_reader :tool_result
15
15
 
16
+ def valid?
17
+ tool_call_id && !tool_call_id.empty? &&
18
+ tool_name && !tool_name.empty?
19
+ end
20
+
16
21
  def to_h
17
22
  {
18
- type: :tool_call,
23
+ type: :tool_result,
19
24
  tool_call_id: tool_call_id,
20
25
  tool_name: tool_name,
21
- tool_parameters: tool_result
26
+ tool_result: tool_result
22
27
  }.compact
23
28
  end
24
29
  end
@@ -0,0 +1,139 @@
1
+ module Intelligence
2
+ ##
3
+ # The +Tool+ class instance encpasulates a definition of a tool that may be executed by a
4
+ # model. The properies of a tool include a unique name, a comprehensive description of what
5
+ # the tool does and a set of properies that describe the arguments the tool accepts, each
6
+ # with its own type and validation rules.
7
+ #
8
+ # A +Tool+ instance does not implement the tool, only the defintion of the tool, which is
9
+ # presented to the model to allow it to make a tool call.
10
+ #
11
+ # == Configuration
12
+ #
13
+ # A tool MUST include the +name+ and +description+ and may include any number of
14
+ # +arguments+ as well as a +required+ attribute with a list of the required arguments.
15
+ # Each argument must include a +name+ and may include +description+, +type+, a list of
16
+ # acceptable values through +enum+ and a +minimum+ and +maximum+ for numerical
17
+ # arguments.
18
+ #
19
+ # === Tool Attributes
20
+ #
21
+ # - +name+: A +String+ representing the unique name of the tool. *required*
22
+ # - +description+: A +String+ describing it's purpose and functionality. *required*
23
+ #
24
+ # === Argument Attributes
25
+ #
26
+ # An argument is defined through the +argument+ block. The block MUST include the +name+,
27
+ # while all other attributes, including the +description+ and +type+ are all optional.
28
+ #
29
+ # - +type+:
30
+ # A +String+ indicating the data type of the property. Accepted values include +string+,
31
+ # +number+, +integer+, +array+, +boolean+, +object+.
32
+ # - +name+: A +String+ representing the name of the property. *required*
33
+ # - +description+: A +String+ that describes the property and its purpose. *required*
34
+ # - +minimum+: An +Integer+ or +Float+ specifying the minimum value for numerical properties.
35
+ # - +maximum+: An +Integer+ or +Float+ specifying the maximum value for numerical properties.
36
+ # - +enum+:
37
+ # An +Array+ of acceptable values for the property. Note that ( as per the JSON schema
38
+ # specification ) an enum could be composed of mixed types but this is discouraged.
39
+ # - +required:
40
+ # A boolean ( +TrueClass+, +FalseClass+ ) that specifying if the argument is required.
41
+ #
42
+ # === Examples
43
+ #
44
+ # weather_tool = Tool.build! do
45
+ # name :get_weather_by_locality
46
+ # description \
47
+ # "The get_weather_by_locality tool will return the current weather in a given locality " \
48
+ # "( city, state or province, and country )."
49
+ # argument name: 'city', type: 'string', required: true do
50
+ # description "The city or town for which the current weather should be returned."
51
+ # end
52
+ # argument name: 'state', type: 'string' do
53
+ # description \
54
+ # "The state or province for which the current weather should be returned. If this is " \
55
+ # "not provided the largest or most prominent city with the given name, in the given " \
56
+ # "country, will be assumed."
57
+ # end
58
+ # argument name: 'country', type: 'string', required: true do
59
+ # description "The city or town for which the current weather should be returned."
60
+ # end
61
+ # end
62
+ #
63
+ # web_browser_tool = Tool.build!
64
+ # name :get_web_page
65
+ # description "The get_web_page tool will return the content of a web page, given a page url."
66
+ # argument name: :url, type: 'string', required: true do
67
+ # description \
68
+ # "The url of the page including the scheme.\n"
69
+ # "Examples:\n"
70
+ # " https://example.com\n"
71
+ # " https://www.iana.org/help/example-domains\n"
72
+ # end
73
+ # argument name: :format do
74
+ # description \
75
+ # "The format of the returned content. By default you will receive 'markdown'. You " \
76
+ # "should specify 'html' only if it is specifically required to fullfill the user " \
77
+ # "request."
78
+ # enum [ 'html', 'markdown' ]
79
+ # end
80
+ # argument name: :content do
81
+ # description \
82
+ # "The content of the page to be returned. By default you will receive only the 'main' " \
83
+ # "content, excluding header, footer, menu, advertising and other miscelanous elements. " \
84
+ # "You should request 'full' only if absolutely neccessry to fullfill the user request. " \
85
+ # enum [ 'main', 'full' ]
86
+ # end
87
+ # argument name: :include_tags do
88
+ # description "If content is set to html some tags will."
89
+ # end
90
+ # end
91
+ #
92
+ class Tool
93
+ include DynamicSchema::Definable
94
+ include DynamicSchema::Buildable
95
+
96
+ ARGUMENT_TYPES = [ 'string', 'number', 'integer', 'array', 'boolean', 'object' ]
97
+
98
+ ARGUMENT_SCHEMA = proc do
99
+ type String, in: ARGUMENT_TYPES
100
+ name String, required: true
101
+ description String, required: true
102
+ required [ TrueClass, FalseClass ]
103
+ # note that an enum does not require a type as it implicitly restricts the argument
104
+ # to specific values
105
+ enum array: true
106
+ # for arguments of type number and integer
107
+ minimum [ Integer, Float ]
108
+ maximum [ Integer, Float ]
109
+ # for arguments of type array
110
+ maximum_items Integer, as: :maxItems
111
+ minimum_items Integer, as: :minItems
112
+ unique_items [ TrueClass, FalseClass ]
113
+ items do
114
+ type in: ARGUMENT_TYPES
115
+ property array: true, as: :properties, &ARGUMENT_SCHEMA
116
+ end
117
+ # for arguments of type object
118
+ property array: true, as: :properties, &ARGUMENT_SCHEMA
119
+ end
120
+
121
+ schema do
122
+ name String, required: true
123
+ description String, required: true
124
+ argument array: true, as: :properties do
125
+ self.instance_eval( &ARGUMENT_SCHEMA )
126
+ end
127
+ end
128
+
129
+ def initialize( attributes = nil )
130
+ @properies = attributes
131
+ end
132
+
133
+ def to_h
134
+ @properies.to_h
135
+ end
136
+
137
+ end
138
+ end
139
+
@@ -1,3 +1,3 @@
1
1
  module Intelligence
2
- VERSION = "0.6.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/lib/intelligence.rb CHANGED
@@ -2,8 +2,9 @@ require 'json'
2
2
  require 'base64'
3
3
 
4
4
  require 'faraday'
5
- require 'adaptive_configuration'
5
+ require 'dynamic_schema'
6
6
  require 'mime-types'
7
+ require 'json/repair'
7
8
 
8
9
  require 'intelligence/version'
9
10
 
@@ -14,6 +15,7 @@ require 'intelligence/unsupported_content_error'
14
15
  require 'intelligence/error_result'
15
16
  require 'intelligence/chat_error_result'
16
17
 
18
+ require 'intelligence/tool'
17
19
  require 'intelligence/message_content'
18
20
  require 'intelligence/message'
19
21
  require 'intelligence/conversation'