intelligence 0.6.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +555 -0
- data/intelligence.gemspec +1 -1
- data/lib/intelligence/adapter/base.rb +13 -6
- data/lib/intelligence/adapter/class_methods.rb +15 -0
- data/lib/intelligence/adapter/module_methods.rb +41 -0
- data/lib/intelligence/adapter.rb +2 -2
- data/lib/intelligence/adapters/anthropic/adapter.rb +21 -19
- data/lib/intelligence/adapters/anthropic/chat_request_methods.rb +189 -0
- data/lib/intelligence/adapters/anthropic/{chat_methods.rb → chat_response_methods.rb} +8 -125
- data/lib/intelligence/adapters/cerebras.rb +17 -17
- data/lib/intelligence/adapters/generic/chat_methods.rb +12 -5
- data/lib/intelligence/adapters/generic.rb +1 -1
- data/lib/intelligence/adapters/google/adapter.rb +33 -22
- data/lib/intelligence/adapters/google/chat_request_methods.rb +233 -0
- data/lib/intelligence/adapters/google/chat_response_methods.rb +236 -0
- data/lib/intelligence/adapters/groq.rb +27 -28
- data/lib/intelligence/adapters/hyperbolic.rb +13 -13
- data/lib/intelligence/adapters/legacy/chat_methods.rb +1 -2
- data/lib/intelligence/adapters/mistral.rb +18 -18
- data/lib/intelligence/adapters/open_ai/adapter.rb +39 -32
- data/lib/intelligence/adapters/open_ai/chat_request_methods.rb +186 -0
- data/lib/intelligence/adapters/open_ai/{chat_methods.rb → chat_response_methods.rb} +60 -162
- data/lib/intelligence/adapters/open_ai.rb +1 -1
- data/lib/intelligence/adapters/open_router.rb +18 -18
- data/lib/intelligence/adapters/samba_nova.rb +13 -13
- data/lib/intelligence/adapters/together_ai.rb +21 -19
- data/lib/intelligence/conversation.rb +11 -10
- data/lib/intelligence/message.rb +44 -28
- data/lib/intelligence/message_content/base.rb +2 -9
- data/lib/intelligence/message_content/binary.rb +3 -3
- data/lib/intelligence/message_content/file.rb +3 -3
- data/lib/intelligence/message_content/text.rb +2 -2
- data/lib/intelligence/message_content/tool_call.rb +8 -4
- data/lib/intelligence/message_content/tool_result.rb +11 -6
- data/lib/intelligence/tool.rb +139 -0
- data/lib/intelligence/version.rb +1 -1
- data/lib/intelligence.rb +2 -1
- metadata +15 -10
- data/lib/intelligence/adapter/class_methods/construction.rb +0 -17
- data/lib/intelligence/adapter/module_methods/construction.rb +0 -43
- data/lib/intelligence/adapters/google/chat_methods.rb +0 -393
@@ -7,32 +7,34 @@ module Intelligence
|
|
7
7
|
|
8
8
|
chat_request_uri "https://api.together.xyz/v1/chat/completions"
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
28
|
def translate_end_result( end_result )
|
29
29
|
case end_result
|
30
|
-
when 'eos'
|
30
|
+
when 'eos', 'stop'
|
31
31
|
:ended
|
32
|
-
|
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
38
|
when 'function_call'
|
37
39
|
:tool_called
|
38
40
|
else
|
@@ -1,16 +1,12 @@
|
|
1
1
|
module Intelligence
|
2
2
|
class Conversation
|
3
3
|
|
4
|
-
|
4
|
+
include DynamicSchema::Definable
|
5
|
+
include DynamicSchema::Buildable
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
data/lib/intelligence/message.rb
CHANGED
@@ -1,33 +1,47 @@
|
|
1
1
|
module Intelligence
|
2
2
|
class Message
|
3
3
|
|
4
|
-
|
4
|
+
include DynamicSchema::Definable
|
5
5
|
|
6
6
|
ROLES = [ :system, :user, :assistant ]
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
25
|
-
# accepts message +attributes+ and a block, which may be combined when constructing
|
26
|
-
# The +role+ is required, either as
|
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
|
-
|
56
|
-
self.new(
|
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
|
-
|
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 )
|
@@ -98,13 +114,6 @@ module Intelligence
|
|
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
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
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,16 +3,20 @@ module Intelligence
|
|
3
3
|
|
4
4
|
class ToolCall < Base
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
14
|
attr_reader :tool_parameters
|
15
15
|
|
16
|
+
def valid?
|
17
|
+
tool_name && !tool_name.empty?
|
18
|
+
end
|
19
|
+
|
16
20
|
def to_h
|
17
21
|
{
|
18
22
|
type: :tool_call,
|
@@ -3,22 +3,27 @@ module Intelligence
|
|
3
3
|
|
4
4
|
class ToolResult < Base
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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: :
|
23
|
+
type: :tool_result,
|
19
24
|
tool_call_id: tool_call_id,
|
20
25
|
tool_name: tool_name,
|
21
|
-
|
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
|
+
|
data/lib/intelligence/version.rb
CHANGED
data/lib/intelligence.rb
CHANGED
@@ -2,7 +2,7 @@ require 'json'
|
|
2
2
|
require 'base64'
|
3
3
|
|
4
4
|
require 'faraday'
|
5
|
-
require '
|
5
|
+
require 'dynamic_schema'
|
6
6
|
require 'mime-types'
|
7
7
|
|
8
8
|
require 'intelligence/version'
|
@@ -14,6 +14,7 @@ require 'intelligence/unsupported_content_error'
|
|
14
14
|
require 'intelligence/error_result'
|
15
15
|
require 'intelligence/chat_error_result'
|
16
16
|
|
17
|
+
require 'intelligence/tool'
|
17
18
|
require 'intelligence/message_content'
|
18
19
|
require 'intelligence/message'
|
19
20
|
require 'intelligence/conversation'
|
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.
|
4
|
+
version: 0.7.1
|
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-
|
11
|
+
date: 2024-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: dynamicschema
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0.
|
33
|
+
version: 1.0.0.beta03
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.0.
|
40
|
+
version: 1.0.0.beta03
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mime-types
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,23 +108,26 @@ extensions: []
|
|
108
108
|
extra_rdoc_files: []
|
109
109
|
files:
|
110
110
|
- LICENSE
|
111
|
+
- README.md
|
111
112
|
- intelligence.gemspec
|
112
113
|
- lib/intelligence.rb
|
113
114
|
- lib/intelligence/adapter.rb
|
114
115
|
- lib/intelligence/adapter/base.rb
|
115
|
-
- lib/intelligence/adapter/class_methods
|
116
|
-
- lib/intelligence/adapter/module_methods
|
116
|
+
- lib/intelligence/adapter/class_methods.rb
|
117
|
+
- lib/intelligence/adapter/module_methods.rb
|
117
118
|
- lib/intelligence/adapter_error.rb
|
118
119
|
- lib/intelligence/adapters/anthropic.rb
|
119
120
|
- lib/intelligence/adapters/anthropic/adapter.rb
|
120
|
-
- lib/intelligence/adapters/anthropic/
|
121
|
+
- lib/intelligence/adapters/anthropic/chat_request_methods.rb
|
122
|
+
- lib/intelligence/adapters/anthropic/chat_response_methods.rb
|
121
123
|
- lib/intelligence/adapters/cerebras.rb
|
122
124
|
- lib/intelligence/adapters/generic.rb
|
123
125
|
- lib/intelligence/adapters/generic/adapter.rb
|
124
126
|
- lib/intelligence/adapters/generic/chat_methods.rb
|
125
127
|
- lib/intelligence/adapters/google.rb
|
126
128
|
- lib/intelligence/adapters/google/adapter.rb
|
127
|
-
- lib/intelligence/adapters/google/
|
129
|
+
- lib/intelligence/adapters/google/chat_request_methods.rb
|
130
|
+
- lib/intelligence/adapters/google/chat_response_methods.rb
|
128
131
|
- lib/intelligence/adapters/groq.rb
|
129
132
|
- lib/intelligence/adapters/hyperbolic.rb
|
130
133
|
- lib/intelligence/adapters/legacy/adapter.rb
|
@@ -132,7 +135,8 @@ files:
|
|
132
135
|
- lib/intelligence/adapters/mistral.rb
|
133
136
|
- lib/intelligence/adapters/open_ai.rb
|
134
137
|
- lib/intelligence/adapters/open_ai/adapter.rb
|
135
|
-
- lib/intelligence/adapters/open_ai/
|
138
|
+
- lib/intelligence/adapters/open_ai/chat_request_methods.rb
|
139
|
+
- lib/intelligence/adapters/open_ai/chat_response_methods.rb
|
136
140
|
- lib/intelligence/adapters/open_router.rb
|
137
141
|
- lib/intelligence/adapters/samba_nova.rb
|
138
142
|
- lib/intelligence/adapters/together_ai.rb
|
@@ -153,6 +157,7 @@ files:
|
|
153
157
|
- lib/intelligence/message_content/text.rb
|
154
158
|
- lib/intelligence/message_content/tool_call.rb
|
155
159
|
- lib/intelligence/message_content/tool_result.rb
|
160
|
+
- lib/intelligence/tool.rb
|
156
161
|
- lib/intelligence/unsupported_content_error.rb
|
157
162
|
- lib/intelligence/version.rb
|
158
163
|
homepage: https://github.com/EndlessInternational/intelligence
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Intelligence
|
2
|
-
module Adapter
|
3
|
-
module ClassMethods
|
4
|
-
module Construction
|
5
|
-
|
6
|
-
def build( options = nil, &block )
|
7
|
-
self.new( configuration: self.configure( options, &block ) )
|
8
|
-
end
|
9
|
-
|
10
|
-
def build!( options = nil, &block )
|
11
|
-
self.new( configuration: self.configure!( options, &block ) )
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Intelligence
|
2
|
-
module Adapter
|
3
|
-
module ModuleMethods
|
4
|
-
module Construction
|
5
|
-
|
6
|
-
def []( adapter_type )
|
7
|
-
|
8
|
-
raise ArgumentError.new( "An adapter type is required but nil was given." ) \
|
9
|
-
if adapter_type.nil?
|
10
|
-
|
11
|
-
class_name = adapter_type.to_s.split( '_' ).map( &:capitalize ).join
|
12
|
-
class_name += "::Adapter"
|
13
|
-
|
14
|
-
adapter_class = Intelligence.const_get( class_name ) rescue nil
|
15
|
-
if adapter_class.nil?
|
16
|
-
adapter_file = File.expand_path( "../../../adapters/#{adapter_type}", __FILE__ )
|
17
|
-
unless require adapter_file
|
18
|
-
raise ArgumentError.new(
|
19
|
-
"The Intelligence adapter file #{adapter_file} is missing or does not define #{class_name}."
|
20
|
-
)
|
21
|
-
end
|
22
|
-
adapter_class = Intelligence.const_get( class_name ) rescue nil
|
23
|
-
end
|
24
|
-
|
25
|
-
raise ArgumentError.new( "An unknown Intelligence adapter #{adapter_type} was requested." ) \
|
26
|
-
if adapter_class.nil?
|
27
|
-
|
28
|
-
adapter_class
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def build( adapter_type, attributes = nil, &block )
|
33
|
-
self.[]( adapter_type ).build( attributes, &block )
|
34
|
-
end
|
35
|
-
|
36
|
-
def build!( adapter_type, attributes = nil, &block )
|
37
|
-
self.[]( adapter_type ).build!( attributes, &block )
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|