intelligence 1.0.0.beta04 → 1.0.0.beta05

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df9c6c9d4ecd7c8adde5eb20067ceef7f9f88ab5602c862b50635039fad13e81
4
- data.tar.gz: 4af029c32fba747acd6a1fff0daa3e6de6ab049e20240e9dfbcbf4b5c454a867
3
+ metadata.gz: c0a3f15cdc1061405db03b0b8039b4867b16e70458d1a896a3d7cec542870cf5
4
+ data.tar.gz: 2914681b64f2295b7fbd9a4e4edb3425f53d23ec3a3dd3da0639df101a2fe31f
5
5
  SHA512:
6
- metadata.gz: 7cfdef5d95d37a78f73ad283565f74e706fdcff384c224ff9a92012ee0888179f536f93d34580fd49ee0663800da3066d6174231a5536e917cabde04b1c72ae8
7
- data.tar.gz: 54b476462cf87767cc7b10c95bdc6e149a1b1b4de59ef1795c70761813594d971e8d6690aeeee22756caf8fce8d107edfd97d78b07b7c9db4c2ee7f2981b0ad4
6
+ metadata.gz: 181c33085c1c608f8d35b39332514e0a4028124e85309f4e95fddb5913b43490333298ffa8d935f3cc447d682968e04816c7d5497967d1700daa4d575dbd6425
7
+ data.tar.gz: abf03a55cf8c5f1ff5d0c97bc4d6918327f240cbc1f2137338726611c447fdd32cabf2cc15ba7f0f40b6cb122d35f9e0dec092add65c10b40044f248c2535d97
data/intelligence.gemspec CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do | spec |
37
37
  spec.require_paths = [ "lib" ]
38
38
 
39
39
  spec.add_runtime_dependency 'faraday', '~> 2.7'
40
- spec.add_runtime_dependency 'dynamicschema', '~> 1.0.0.beta03'
40
+ spec.add_runtime_dependency 'dynamicschema', '~> 1.0'
41
41
  spec.add_runtime_dependency 'mime-types', '~> 3.6'
42
42
  spec.add_runtime_dependency 'json-repair', '~> 0.2'
43
43
 
@@ -2,7 +2,7 @@ module Intelligence
2
2
  class AdapterError < Error;
3
3
  def initialize( adapter_type, text )
4
4
  adapter_class_name = adapter_type.to_s.split( '_' ).map( &:capitalize ).join
5
- super( "The #{adapter_class_name} #{text}." )
5
+ super( "The #{adapter_class_name} adapter #{text}." )
6
6
  end
7
7
  end
8
8
  end
@@ -5,10 +5,13 @@ module Intelligence
5
5
 
6
6
  class Adapter < Generic::Adapter
7
7
 
8
- chat_request_uri "https://api.cerebras.ai/v1/chat/completions"
8
+ DEFAULT_BASE_URI = 'https://api.cerebras.ai/v1'
9
9
 
10
10
  schema do
11
+
12
+ base_uri String, default: DEFAULT_BASE_URI
11
13
  key String
14
+
12
15
  chat_options do
13
16
  model String
14
17
  max_tokens Integer
@@ -26,8 +29,9 @@ module Intelligence
26
29
  type String
27
30
  mame String
28
31
  end
29
- user
32
+ user String
30
33
  end
34
+
31
35
  end
32
36
 
33
37
  end
@@ -12,25 +12,32 @@ module Intelligence
12
12
  end
13
13
  end
14
14
 
15
+ CHAT_COMPLETIONS_PATH = 'chat/completions'
16
+
15
17
  def self.included( base )
16
18
  base.extend( ClassMethods )
17
19
  end
18
20
 
19
- def chat_request_uri( options )
20
- self.class.chat_request_uri
21
+ def chat_request_uri( options = nil )
22
+ options = merge_options( @options, build_options( options ) )
23
+ self.class.chat_request_uri || begin
24
+ base_uri = options[ :base_uri ]
25
+ if base_uri
26
+ # because URI join is dumb
27
+ base_uri = ( base_uri.end_with?( '/' ) ? base_uri : base_uri + '/' )
28
+ URI.join( base_uri, CHAT_COMPLETIONS_PATH )
29
+ else
30
+ nil
31
+ end
32
+ end
21
33
  end
22
34
 
23
35
  def chat_request_headers( options = nil )
24
36
  options = merge_options( @options, build_options( options ) )
25
- result = {}
37
+ result = { 'Content-Type': 'application/json' }
26
38
 
27
39
  key = options[ :key ]
28
-
29
- raise ArgumentError.new( "An API key is required to build a chat request." ) \
30
- if key.nil?
31
-
32
- result[ 'Content-Type' ] = 'application/json'
33
- result[ 'Authorization' ] = "Bearer #{key}"
40
+ result[ 'Authorization' ] = "Bearer #{key}" if key
34
41
 
35
42
  result
36
43
  end
@@ -17,7 +17,7 @@ module Intelligence
17
17
 
18
18
  SUPPORTED_FILE_MEDIA_TYPES = %w[ text ]
19
19
 
20
- SUPPORTED_CONTENT_TYPES = %w[
20
+ SUPPORTED_FILE_CONTENT_TYPES = %w[
21
21
  image/png image/jpeg image/webp image/heic image/heif
22
22
  video/x-flv video/quicktime video/mpeg video/mpegps video/mpg video/mp4 video/webm
23
23
  video/wmv video/3gpp
@@ -5,11 +5,15 @@ module Intelligence
5
5
 
6
6
  class Adapter < Generic::Adapter
7
7
 
8
- chat_request_uri 'https://api.groq.com/openai/v1/chat/completions'
8
+ DEFAULT_BASE_URI = 'https://api.groq.com/openai/v1'
9
9
 
10
10
  schema do
11
+
12
+ base_uri String, default: DEFAULT_BASE_URI
11
13
  key String
14
+
12
15
  chat_options do
16
+
13
17
  frequency_penalty Float
14
18
  logit_bias
15
19
  logprobs [ TrueClass, FalseClass ]
@@ -25,10 +29,12 @@ module Intelligence
25
29
  end
26
30
  seed Integer
27
31
  stop String, array: true
32
+
28
33
  stream [ TrueClass, FalseClass ]
29
34
  stream_options do
30
35
  include_usage [ TrueClass, FalseClass ]
31
36
  end
37
+
32
38
  temperature Float
33
39
  tool array: true, as: :tools, &Tool.schema
34
40
  tool_choice do
@@ -39,10 +45,13 @@ module Intelligence
39
45
  name String
40
46
  end
41
47
  end
48
+
42
49
  top_logprobs Integer
43
50
  top_p Float
44
51
  user String
52
+
45
53
  end
54
+
46
55
  end
47
56
 
48
57
  end
@@ -5,9 +5,10 @@ module Intelligence
5
5
 
6
6
  class Adapter < Generic::Adapter
7
7
 
8
- chat_request_uri "https://api.hyperbolic.xyz/v1/chat/completions"
8
+ DEFAULT_BASE_URI = 'https://api.hyperbolic.xyz/v1'
9
9
 
10
10
  schema do
11
+ base_uri String, default: DEFAULT_BASE_URI
11
12
  key String
12
13
  chat_options do
13
14
  model String
@@ -15,7 +16,7 @@ module Intelligence
15
16
  top_p Float
16
17
  n Integer
17
18
  max_tokens Integer
18
- stop String, array: true
19
+ stop String, array: true
19
20
  stream [ TrueClass, FalseClass ]
20
21
  frequency_penalty Float
21
22
  presence_penalty Float
@@ -0,0 +1,28 @@
1
+ require_relative 'generic/adapter'
2
+
3
+ module Intelligence
4
+ module Ollama
5
+
6
+ class Adapter < Generic::Adapter
7
+
8
+ DEFAULT_BASE_URI = 'http://localhost:11435/v1'
9
+
10
+ schema do
11
+
12
+ base_uri String, default: DEFAULT_BASE_URI
13
+ key String
14
+
15
+ chat_options do
16
+ max_tokens Integer
17
+ model String
18
+ stop String, array: true
19
+ stream [ TrueClass, FalseClass ]
20
+ temperature Float
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
@@ -5,11 +5,14 @@ module Intelligence
5
5
 
6
6
  class Adapter < Generic::Adapter
7
7
 
8
- chat_request_uri "https://openrouter.ai/api/v1/chat/completions"
8
+ DEFAULT_BASE_URI = 'https://openrouter.ai/api/v1'
9
9
 
10
10
  schema do
11
+ base_uri String, default: DEFAULT_BASE_URI
11
12
  key String
13
+
12
14
  chat_options do
15
+
13
16
  model String
14
17
  temperature Float
15
18
  top_k Integer
@@ -27,7 +30,9 @@ module Intelligence
27
30
  require_parameters [ TrueClass, FalseClass ]
28
31
  allow_fallbacks [ TrueClass, FalseClass ]
29
32
  end
33
+
30
34
  end
35
+
31
36
  end
32
37
 
33
38
  # def chat_result_error_attributes( response )
@@ -5,11 +5,12 @@ module Intelligence
5
5
 
6
6
  class Adapter < Generic::Adapter
7
7
 
8
- chat_request_uri "https://api.sambanova.ai/v1/chat/completions"
8
+ DEFAULT_BASE_URI = "https://api.sambanova.ai/v1"
9
9
 
10
10
  schema do
11
11
 
12
12
  # normalized properties for all endpoints
13
+ base_uri String, default: DEFAULT_BASE_URI
13
14
  key String
14
15
 
15
16
  # properties for generative text endpoints
@@ -42,12 +43,10 @@ module Intelligence
42
43
  }
43
44
 
44
45
  parsed_body = JSON.parse( response.body, symbolize_names: true ) rescue nil
45
- if parsed_body && parsed_body.respond_to?( :include? ) && parsed_body.include?( :error )
46
- result = {
47
- error_type: error_type.to_s,
48
- error: parsed_body[ :error ][ :code ] || error_type.to_s,
49
- error_description: parsed_body[ :error ][ :message ] || error_description
50
- }
46
+ if parsed_body &&
47
+ parsed_body.respond_to?( :include? ) && parsed_body.include?( :error ) &&
48
+ parsed_body[ :error ].is_a?( String )
49
+ result[ :error_description ] = parsed_body[ :error ]
51
50
  elsif response.headers[ 'content-type' ].start_with?( 'text/plain' ) &&
52
51
  response.body && response.body.length > 0
53
52
  result[ :error_description ] = response.body
@@ -5,9 +5,10 @@ module Intelligence
5
5
 
6
6
  class Adapter < Generic::Adapter
7
7
 
8
- chat_request_uri "https://api.together.xyz/v1/chat/completions"
9
-
8
+ DEFAULT_BASE_URI = "https://api.together.xyz/v1"
9
+
10
10
  schema do
11
+ base_uri String, default: DEFAULT_BASE_URI
11
12
  key String
12
13
  chat_options do
13
14
  model String
@@ -90,7 +90,7 @@ module Intelligence
90
90
  options[ :tools ] = options[ :tools ].to_a.map!( &:to_h ) if options[ :tools ]
91
91
 
92
92
  uri = @adapter.chat_request_uri( options )
93
- headers = @adapter.chat_request_headers( @options.merge( options ) )
93
+ headers = @adapter.chat_request_headers( options )
94
94
  payload = @adapter.chat_request_body( conversation, options )
95
95
 
96
96
  result_callback = nil
@@ -1,3 +1,3 @@
1
1
  module Intelligence
2
- VERSION = "1.0.0.beta04"
2
+ VERSION = "1.0.0.beta05"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intelligence
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta04
4
+ version: 1.0.0.beta05
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristoph Cichocki-Romanov
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-21 00:00:00.000000000 Z
10
+ date: 2025-06-07 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: faraday
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.0.0.beta03
32
+ version: '1.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 1.0.0.beta03
39
+ version: '1.0'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: mime-types
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -146,6 +146,7 @@ files:
146
146
  - lib/intelligence/adapters/groq.rb
147
147
  - lib/intelligence/adapters/hyperbolic.rb
148
148
  - lib/intelligence/adapters/mistral.rb
149
+ - lib/intelligence/adapters/ollama.rb
149
150
  - lib/intelligence/adapters/open_ai.rb
150
151
  - lib/intelligence/adapters/open_ai/adapter.rb
151
152
  - lib/intelligence/adapters/open_ai/chat_request_methods.rb