intelligence 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/intelligence.gemspec +1 -1
- data/lib/intelligence/adapter/base.rb +15 -2
- data/lib/intelligence/adapter/class_methods/construction.rb +17 -0
- data/lib/intelligence/adapter/module_methods/construction.rb +43 -0
- data/lib/intelligence/adapter.rb +2 -2
- data/lib/intelligence/adapters/anthropic/adapter.rb +4 -15
- data/lib/intelligence/adapters/anthropic/chat_methods.rb +9 -8
- data/lib/intelligence/adapters/cerebras.rb +3 -3
- data/lib/intelligence/adapters/generic/adapter.rb +1 -12
- data/lib/intelligence/adapters/generic/chat_methods.rb +34 -10
- data/lib/intelligence/adapters/google/adapter.rb +2 -15
- data/lib/intelligence/adapters/google/chat_methods.rb +68 -21
- data/lib/intelligence/adapters/groq.rb +20 -1
- data/lib/intelligence/adapters/hyperbolic.rb +1 -1
- data/lib/intelligence/adapters/legacy/adapter.rb +0 -2
- data/lib/intelligence/adapters/legacy/chat_methods.rb +23 -6
- data/lib/intelligence/adapters/mistral.rb +57 -0
- data/lib/intelligence/adapters/open_ai/adapter.rb +2 -16
- data/lib/intelligence/adapters/open_ai/chat_methods.rb +39 -8
- data/lib/intelligence/adapters/open_router.rb +62 -0
- data/lib/intelligence/adapters/samba_nova.rb +1 -1
- data/lib/intelligence/adapters/together_ai.rb +1 -1
- data/lib/intelligence/chat_request.rb +57 -7
- data/lib/intelligence/chat_result.rb +4 -0
- data/lib/intelligence/chat_result_choice.rb +4 -2
- data/lib/intelligence/conversation.rb +37 -9
- data/lib/intelligence/message.rb +90 -23
- data/lib/intelligence/message_content/base.rb +10 -0
- data/lib/intelligence/message_content/binary.rb +6 -0
- data/lib/intelligence/message_content/file.rb +35 -0
- data/lib/intelligence/message_content/text.rb +5 -0
- data/lib/intelligence/message_content/tool_call.rb +8 -1
- data/lib/intelligence/message_content/tool_result.rb +8 -1
- data/lib/intelligence/message_content.rb +12 -3
- data/lib/intelligence/version.rb +1 -1
- data/lib/intelligence.rb +4 -3
- metadata +9 -5
- data/lib/intelligence/adapter/construction_methods.rb +0 -37
@@ -4,11 +4,20 @@ end
|
|
4
4
|
|
5
5
|
module Intelligence
|
6
6
|
module MessageContent
|
7
|
-
|
8
|
-
def self.
|
7
|
+
|
8
|
+
def self.[]( type )
|
9
9
|
type_name = type.to_s.split( '_' ).map { | word | word.capitalize }.join
|
10
10
|
klass = Intelligence.const_get( "MessageContent::#{type_name}" ) rescue nil
|
11
|
-
|
11
|
+
raise TypeError, "An unknown content type '#{type}' was given." unless klass
|
12
|
+
klass
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.build!( type, attributes = nil, &block )
|
16
|
+
self[ type ].build!( attributes, &block )
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.build( type, attributes = nil, &block )
|
20
|
+
self[ type ].build( attributes, &block )
|
12
21
|
end
|
13
22
|
|
14
23
|
end
|
data/lib/intelligence/version.rb
CHANGED
data/lib/intelligence.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'base64'
|
2
3
|
|
3
4
|
require 'faraday'
|
4
5
|
require 'adaptive_configuration'
|
@@ -11,14 +12,14 @@ require 'intelligence/adapter_error'
|
|
11
12
|
require 'intelligence/unsupported_content_error'
|
12
13
|
|
13
14
|
require 'intelligence/error_result'
|
15
|
+
require 'intelligence/chat_error_result'
|
14
16
|
|
15
|
-
require 'intelligence/conversation'
|
16
|
-
require 'intelligence/message'
|
17
17
|
require 'intelligence/message_content'
|
18
|
+
require 'intelligence/message'
|
19
|
+
require 'intelligence/conversation'
|
18
20
|
require 'intelligence/adapter'
|
19
21
|
require 'intelligence/chat_request'
|
20
22
|
require 'intelligence/chat_result'
|
21
23
|
require 'intelligence/chat_result_choice'
|
22
24
|
require 'intelligence/chat_metrics'
|
23
|
-
require 'intelligence/chat_error_result'
|
24
25
|
|
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.6.0
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0.
|
33
|
+
version: 1.0.0.beta08
|
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.beta08
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mime-types
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +112,8 @@ files:
|
|
112
112
|
- lib/intelligence.rb
|
113
113
|
- lib/intelligence/adapter.rb
|
114
114
|
- lib/intelligence/adapter/base.rb
|
115
|
-
- lib/intelligence/adapter/
|
115
|
+
- lib/intelligence/adapter/class_methods/construction.rb
|
116
|
+
- lib/intelligence/adapter/module_methods/construction.rb
|
116
117
|
- lib/intelligence/adapter_error.rb
|
117
118
|
- lib/intelligence/adapters/anthropic.rb
|
118
119
|
- lib/intelligence/adapters/anthropic/adapter.rb
|
@@ -128,9 +129,11 @@ files:
|
|
128
129
|
- lib/intelligence/adapters/hyperbolic.rb
|
129
130
|
- lib/intelligence/adapters/legacy/adapter.rb
|
130
131
|
- lib/intelligence/adapters/legacy/chat_methods.rb
|
132
|
+
- lib/intelligence/adapters/mistral.rb
|
131
133
|
- lib/intelligence/adapters/open_ai.rb
|
132
134
|
- lib/intelligence/adapters/open_ai/adapter.rb
|
133
135
|
- lib/intelligence/adapters/open_ai/chat_methods.rb
|
136
|
+
- lib/intelligence/adapters/open_router.rb
|
134
137
|
- lib/intelligence/adapters/samba_nova.rb
|
135
138
|
- lib/intelligence/adapters/together_ai.rb
|
136
139
|
- lib/intelligence/chat_error_result.rb
|
@@ -146,6 +149,7 @@ files:
|
|
146
149
|
- lib/intelligence/message_content.rb
|
147
150
|
- lib/intelligence/message_content/base.rb
|
148
151
|
- lib/intelligence/message_content/binary.rb
|
152
|
+
- lib/intelligence/message_content/file.rb
|
149
153
|
- lib/intelligence/message_content/text.rb
|
150
154
|
- lib/intelligence/message_content/tool_call.rb
|
151
155
|
- lib/intelligence/message_content/tool_result.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Intelligence
|
2
|
-
module Adapter
|
3
|
-
module ConstructionMethods
|
4
|
-
|
5
|
-
def []( adapter_type )
|
6
|
-
|
7
|
-
raise ArgumentError.new( "An adapter type is required but nil was given." ) \
|
8
|
-
if adapter_type.nil?
|
9
|
-
|
10
|
-
class_name = adapter_type.to_s.split( '_' ).map( &:capitalize ).join
|
11
|
-
class_name += "::Adapter"
|
12
|
-
|
13
|
-
adapter_class = Intelligence.const_get( class_name ) rescue nil
|
14
|
-
if adapter_class.nil?
|
15
|
-
adapter_file = File.expand_path( "../../adapters/#{adapter_type}", __FILE__ )
|
16
|
-
unless require adapter_file
|
17
|
-
raise ArgumentError.new(
|
18
|
-
"The Intelligence adapter file #{adapter_file} is missing or does not define #{class_name}."
|
19
|
-
)
|
20
|
-
end
|
21
|
-
adapter_class = Intelligence.const_get( class_name ) rescue nil
|
22
|
-
end
|
23
|
-
|
24
|
-
raise ArgumentError.new( "An unknown Intelligence adapter #{adapter_type} was configured." ) \
|
25
|
-
if adapter_class.nil?
|
26
|
-
|
27
|
-
adapter_class
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def build( adapter_type, attributes, &block )
|
32
|
-
self.[]( adapter_type ).new( attributes, &block )
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|