boxcars 0.7.1 → 0.7.2

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: f737b8f862a6054265b74b7705a9779d301ceba197737c5b85aed4fc96733867
4
- data.tar.gz: ffb896560aab128f2bcf685082755ce6400174d38b7d8b5294feea51808d0e17
3
+ metadata.gz: 517934e9dae206e574b969cd8645b3bfe287ab0cf2a5567a25f83f9b87257b67
4
+ data.tar.gz: 1208007664c046fa3da7d92e367b4032d1eeabef18635b74358d09a89130305d
5
5
  SHA512:
6
- metadata.gz: 2f9afcd76b2efda7fc9f35f2ae02882256a03f935d8a94a10149daa10ad8180c5d91db34e11296310074a1ec9d5d4863a10e74ddc41b19cd9d250d2da64bdff2
7
- data.tar.gz: 17860c296d8cb4a167e4e4bc58835b3bb9da867bb65e38b89cc08d884f88bf09707bc64b4a36195848d7ee995592c4f32ede29752744a7dee4135dd90338285f
6
+ metadata.gz: 2e410138d08fd6744a5ef27aa8724db7839b9ff272e319df9d79b9d1ad1e0d27088da932b83367d82b6458e319eb1710038f0c9e03212b7b3f59c8dee61ac4e2
7
+ data.tar.gz: '09716daacbcecba8debb27c3b243e25087f609c033fdccad40dd5ddad4f9b311d0764ab9a816d0a9d1ae5bfb51b0fdaa5c13fffbb7eb2034c5f39ea78d11e906'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boxcars (0.7.1)
4
+ boxcars (0.7.2)
5
5
  anthropic (~> 0.3)
6
6
  google_search_results (~> 2.2)
7
7
  gpt4all (~> 0.0.5)
@@ -295,4 +295,4 @@ DEPENDENCIES
295
295
  webmock (~> 3.24.0)
296
296
 
297
297
  BUNDLED WITH
298
- 2.5.23
298
+ 2.5.20
@@ -95,7 +95,7 @@ module Boxcars
95
95
  raise KeyError, "Prompt format error: #{first_line}"
96
96
  end
97
97
 
98
- def as_intelligence_conversation(inputs = nil)
98
+ def as_intelligence_conversation(inputs: nil)
99
99
  conversation = Intelligence::Conversation.new
100
100
  no_history.each do |ln|
101
101
  message = Intelligence::Message.new(ln[0])
@@ -56,7 +56,7 @@ module Boxcars
56
56
  # @param inputs [Hash] The inputs to use for the prompt
57
57
  # @return [Intelligence::Conversation] The converted conversation
58
58
  def as_intelligence_conversation(inputs: nil)
59
- conversation.to_intelligence_conversation(inputs: inputs)
59
+ conversation.as_intelligence_conversation(inputs: inputs)
60
60
  end
61
61
  end
62
62
  end
@@ -60,17 +60,17 @@ module Boxcars
60
60
  def client(prompt:, inputs: {}, api_key: nil, **kwargs)
61
61
  params = cerebras_params.merge(kwargs)
62
62
  adapter = Cerebras.adapter(api_key: api_key, params: params)
63
- raise Error, "OpenAI: No response from API" unless adapter
63
+ raise Error, "Cerebras: No response from API" unless adapter
64
64
 
65
65
  convo = prompt.as_intelligence_conversation(inputs: inputs)
66
-
67
- # Add content processing
68
- Boxcars.debug("Sending to Cerebras:\n#{convo}", :cyan) if Boxcars.configuration.log_prompts
66
+ raise Error, "Cerebras: No conversation" unless convo
69
67
 
70
68
  # Make API call
71
69
  request = Intelligence::ChatRequest.new(adapter: adapter)
72
70
  response = request.chat(convo)
73
- check_response(response)
71
+ return JSON.parse(response.body) if response.success?
72
+
73
+ raise Error, "Cerebras: #{response.reason_phrase}"
74
74
  rescue StandardError => e
75
75
  Boxcars.error("Cerebras Error: #{e.message}", :red)
76
76
  raise
@@ -95,7 +95,7 @@ module Boxcars
95
95
  end
96
96
 
97
97
  def check_response(response)
98
- return response.result.text if response.success?
98
+ return if response.present? && response.key?("choices")
99
99
 
100
100
  raise KeyError, "CEREBRAS_API_KEY not valid" if response&.reason_phrase == "Unauthorized"
101
101
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Boxcars
4
4
  # The current version of the gem.
5
- VERSION = "0.7.1"
5
+ VERSION = "0.7.2"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxcars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Sullivan
@@ -172,7 +172,6 @@ files:
172
172
  - lib/boxcars/engine/gpt4all_eng.rb
173
173
  - lib/boxcars/engine/groq.rb
174
174
  - lib/boxcars/engine/intelligence.rb
175
- - lib/boxcars/engine/intelligence/client.rb
176
175
  - lib/boxcars/engine/ollama.rb
177
176
  - lib/boxcars/engine/openai.rb
178
177
  - lib/boxcars/engine/perplexityai.rb
@@ -231,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
230
  - !ruby/object:Gem::Version
232
231
  version: '0'
233
232
  requirements: []
234
- rubygems_version: 3.5.23
233
+ rubygems_version: 3.5.16
235
234
  signing_key:
236
235
  specification_version: 4
237
236
  summary: Boxcars is a gem that enables you to create new systems with AI composability.
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Boxcars
4
- class Intelligence
5
- # Client for interacting with the Intelligence API
6
- class Client
7
- BASE_URL = "https://api.intelligence.com/v1"
8
- DEFAULT_TIMEOUT = 120
9
-
10
- def initialize(api_key:)
11
- @api_key = api_key
12
- @connection = Faraday.new(
13
- url: BASE_URL,
14
- headers: {
15
- "Content-Type" => "application/json",
16
- "Authorization" => "Bearer #{@api_key}"
17
- },
18
- request: {
19
- timeout: DEFAULT_TIMEOUT
20
- }
21
- )
22
- end
23
-
24
- # Generate a response from the Intelligence API
25
- def generate(parameters:)
26
- response = @connection.post("/generate") do |req|
27
- req.body = parameters.to_json
28
- end
29
-
30
- handle_response(response)
31
- end
32
-
33
- # Stream a response from the Intelligence API
34
- def stream(parameters:, &block)
35
- @connection.post("/generate") do |req|
36
- req.options.on_data = block
37
- req.headers["Accept"] = "text/event-stream"
38
- req.body = parameters.to_json
39
- end
40
- end
41
-
42
- private
43
-
44
- def handle_response(response)
45
- case response.status
46
- when 200
47
- JSON.parse(response.body)
48
- when 401
49
- raise KeyError, "Invalid API key"
50
- when 429
51
- raise ValueError, "Rate limit exceeded"
52
- when 400..499
53
- raise ArgumentError, "Bad request: #{response.body}"
54
- when 500..599
55
- raise Error, "Intelligence API server error"
56
- else
57
- raise Error, "Unexpected response: #{response.status}"
58
- end
59
- end
60
- end
61
- end
62
- end