boxcars 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de08261a25297ffb293928ed0f041c23bd40c509becb59a2c959c1a9e29eba15
4
- data.tar.gz: a9896ba99310815803c7ce4143d959a37f0e2c740675fcc57a87ecb74e1e6f5f
3
+ metadata.gz: b025b4faf290736766df116e4146cdcea5285bfbd54b6b1c8eaae1e3fc220507
4
+ data.tar.gz: cdc51dd2f92609b3b2d52879de4716fe8a34e20a15c9bc5d9f27c005bd5f760f
5
5
  SHA512:
6
- metadata.gz: a400bcd9c05ee4d81b67340b0edb9612b94406b02c93db6deaf29604a812469798d23256aa180bc76464025a7c26730395e3f3bd2d5d0235210acae0c60bbdbe
7
- data.tar.gz: 1001cc39c183ae93aa9e8e30fc85679b1bc3ad8a1dc77888a9150ac8ad134d5b595fc94fdf4c68d6e7843bc0be6b1d5690b60263516445e4d6b4fc243b264b93
6
+ metadata.gz: 4267533089c1c3be564ac59d321a8adb670d4197d0548767be1291835049c1edf86f6994b93186d4b0c5ab49445f17d1bdba35bc3b983eafea150c0b05732775
7
+ data.tar.gz: 3d37938ea2c431fe3f1b839471421fc5af46e0c60ede688265874d8b1ac93a6e58e440509a66aea4c91375986ed0295a477cca3adca75f68ffc028f33976583a
data/CHANGELOG.md CHANGED
@@ -1,9 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.6.7](https://github.com/BoxcarsAI/boxcars/tree/v0.6.7) (2024-12-04)
4
+
5
+ [Full Changelog](https://github.com/BoxcarsAI/boxcars/compare/v0.6.6...v0.6.7)
6
+
7
+ ## [v0.6.6](https://github.com/BoxcarsAI/boxcars/tree/v0.6.6) (2024-11-15)
8
+
9
+ [Full Changelog](https://github.com/BoxcarsAI/boxcars/compare/v0.6.5...v0.6.6)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - update anthropic prompt output [\#235](https://github.com/BoxcarsAI/boxcars/pull/235) ([francis](https://github.com/francis))
14
+ - \[infra\] Bump rubocop-rspec from 3.1.0 to 3.2.0 [\#230](https://github.com/BoxcarsAI/boxcars/pull/230) ([dependabot[bot]](https://github.com/apps/dependabot))
15
+ - \[infra\] Bump rexml from 3.3.8 to 3.3.9 [\#229](https://github.com/BoxcarsAI/boxcars/pull/229) ([dependabot[bot]](https://github.com/apps/dependabot))
16
+ - \[infra\] Bump activerecord from 7.1.4 to 7.1.4.2 [\#228](https://github.com/BoxcarsAI/boxcars/pull/228) ([dependabot[bot]](https://github.com/apps/dependabot))
17
+ - \[infra\] Bump activesupport from 7.1.4 to 7.1.4.2 [\#227](https://github.com/BoxcarsAI/boxcars/pull/227) ([dependabot[bot]](https://github.com/apps/dependabot))
18
+ - \[infra\] Bump rubocop from 1.66.1 to 1.67.0 [\#224](https://github.com/BoxcarsAI/boxcars/pull/224) ([dependabot[bot]](https://github.com/apps/dependabot))
19
+ - \[infra\] Bump ruby-openai from 7.1.0 to 7.3.1 [\#223](https://github.com/BoxcarsAI/boxcars/pull/223) ([dependabot[bot]](https://github.com/apps/dependabot))
20
+ - \[infra\] Bump anthropic from 0.3.0 to 0.3.2 [\#220](https://github.com/BoxcarsAI/boxcars/pull/220) ([dependabot[bot]](https://github.com/apps/dependabot))
21
+ - Dep auto [\#219](https://github.com/BoxcarsAI/boxcars/pull/219) ([francis](https://github.com/francis))
22
+ - \[infra\] Bump webmock from 3.23.1 to 3.24.0 [\#218](https://github.com/BoxcarsAI/boxcars/pull/218) ([dependabot[bot]](https://github.com/apps/dependabot))
23
+ - \[infra\] Bump sqlite3 from 1.7.3 to 2.0.4 [\#206](https://github.com/BoxcarsAI/boxcars/pull/206) ([dependabot[bot]](https://github.com/apps/dependabot))
24
+
3
25
  ## [v0.6.5](https://github.com/BoxcarsAI/boxcars/tree/v0.6.5) (2024-10-04)
4
26
 
5
27
  [Full Changelog](https://github.com/BoxcarsAI/boxcars/compare/v0.6.4...v0.6.5)
6
28
 
29
+ **Implemented enhancements:**
30
+
31
+ - use sample sql data in the prompts [\#11](https://github.com/BoxcarsAI/boxcars/issues/11)
32
+
7
33
  **Closed issues:**
8
34
 
9
35
  - Consider methods to prevent hallucinations and incorrect answers [\#89](https://github.com/BoxcarsAI/boxcars/issues/89)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boxcars (0.6.7)
4
+ boxcars (0.6.8)
5
5
  anthropic (~> 0.1)
6
6
  google_search_results (~> 2.2)
7
7
  gpt4all (~> 0.0.4)
@@ -77,16 +77,16 @@ GEM
77
77
  dotenv (3.1.4)
78
78
  drb (2.2.1)
79
79
  event_stream_parser (1.0.0)
80
- faraday (2.12.0)
81
- faraday-net_http (>= 2.0, < 3.4)
80
+ faraday (2.12.1)
81
+ faraday-net_http (>= 2.0, < 3.5)
82
82
  json
83
83
  logger
84
84
  faraday-http-cache (2.5.1)
85
85
  faraday (>= 0.8)
86
86
  faraday-multipart (1.0.4)
87
87
  multipart-post (~> 2)
88
- faraday-net_http (3.3.0)
89
- net-http
88
+ faraday-net_http (3.4.0)
89
+ net-http (>= 0.5.0)
90
90
  faraday-retry (2.2.1)
91
91
  faraday (~> 2.0)
92
92
  fiber-annotation (0.2.0)
@@ -127,7 +127,7 @@ GEM
127
127
  minitest (5.25.4)
128
128
  multi_json (1.15.0)
129
129
  multipart-post (2.4.1)
130
- net-http (0.4.1)
130
+ net-http (0.6.0)
131
131
  uri
132
132
  netrc (0.11.0)
133
133
  nio4r (2.7.3)
@@ -224,7 +224,7 @@ GEM
224
224
  tzinfo (2.0.6)
225
225
  concurrent-ruby (~> 1.0)
226
226
  unicode-display_width (2.6.0)
227
- uri (0.13.1)
227
+ uri (1.0.2)
228
228
  vcr (6.3.1)
229
229
  base64
230
230
  webmock (3.24.0)
@@ -32,8 +32,8 @@ module Boxcars
32
32
  super(description: description, name: name)
33
33
  end
34
34
 
35
- def conversation_model?(model)
36
- @conversation_model ||= (extract_model_version(model) > 3.49)
35
+ def conversation_model?(_model)
36
+ true
37
37
  end
38
38
 
39
39
  def anthropic_client(anthropic_api_key: nil)
@@ -45,34 +45,27 @@ module Boxcars
45
45
  # @param anthropic_api_key [String] Optional api key to use when asking the engine.
46
46
  # Defaults to Boxcars.configuration.anthropic_api_key.
47
47
  # @param kwargs [Hash] Additional parameters to pass to the engine if wanted.
48
- # rubocop:disable Metrics/PerceivedComplexity
49
48
  def client(prompt:, inputs: {}, **kwargs)
50
49
  model_params = llm_params.merge(kwargs)
51
50
  api_key = Boxcars.configuration.anthropic_api_key(**kwargs)
52
51
  aclient = anthropic_client(anthropic_api_key: api_key)
53
52
  prompt = prompt.first if prompt.is_a?(Array)
54
-
55
- if conversation_model?(model_params[:model])
56
- params = convert_to_anthropic(prompt.as_messages(inputs).merge(model_params))
57
- if Boxcars.configuration.log_prompts
58
- if params[:messages].length < 2 && params[:system].present?
59
- Boxcars.debug(">>>>>> Role: system <<<<<<\n#{params[:system]}")
60
- end
61
- Boxcars.debug(params[:messages].last(2).map { |p| ">>>>>> Role: #{p[:role]} <<<<<<\n#{p[:content]}" }.join("\n"), :cyan)
53
+ params = convert_to_anthropic(prompt.as_messages(inputs).merge(model_params))
54
+ if Boxcars.configuration.log_prompts
55
+ if params[:messages].length < 2 && params[:system].present?
56
+ Boxcars.debug(">>>>>> Role: system <<<<<<\n#{params[:system]}")
62
57
  end
63
- response = aclient.messages(parameters: params)
64
- response['completion'] = response.dig('content', 0, 'text')
65
- response.delete('content')
66
- response
67
- else
68
- params = prompt.as_prompt(inputs: inputs, prefixes: default_prefixes, show_roles: true).merge(model_params)
69
- params[:prompt] = "\n\n#{params[:prompt]}" unless params[:prompt].start_with?("\n\n")
70
- params[:stop_sequences] = params.delete(:stop) if params.key?(:stop)
71
- Boxcars.debug("Prompt after formatting:#{params[:prompt]}", :cyan) if Boxcars.configuration.log_prompts
72
- aclient.complete(parameters: params)
58
+ Boxcars.debug(params[:messages].last(2).map { |p| ">>>>>> Role: #{p[:role]} <<<<<<\n#{p[:content]}" }.join("\n"), :cyan)
73
59
  end
60
+ response = aclient.messages(parameters: params)
61
+ response['completion'] = response.dig('content', 0, 'text')
62
+ response.delete('content')
63
+ response
64
+ rescue StandardError => e
65
+ err = e.respond_to?(:response) ? e.response[:body] : e
66
+ Boxcars.warn("Anthropic Error #{e.class.name}: #{err}", :red)
67
+ raise
74
68
  end
75
- # rubocop:enable Metrics/PerceivedComplexity
76
69
 
77
70
  # get an answer from the engine for a question.
78
71
  # @param question [String] The question to ask the engine.
@@ -45,7 +45,7 @@ module Boxcars
45
45
  def self.open_ai_client(openai_access_token: nil)
46
46
  access_token = Boxcars.configuration.openai_access_token(openai_access_token: openai_access_token)
47
47
  organization_id = Boxcars.configuration.organization_id
48
- ::OpenAI::Client.new(access_token: access_token, organization_id: organization_id)
48
+ ::OpenAI::Client.new(access_token: access_token, organization_id: organization_id, log_errors: true)
49
49
  end
50
50
 
51
51
  def conversation_model?(model)
@@ -76,6 +76,10 @@ module Boxcars
76
76
  Boxcars.debug("Prompt after formatting:\n#{params[:prompt]}", :cyan) if Boxcars.configuration.log_prompts
77
77
  clnt.completions(parameters: params)
78
78
  end
79
+ rescue StandardError => e
80
+ err = e.respond_to?(:response) ? e.response[:body] : e
81
+ Boxcars.warn("OpenAI Error #{e.class.name}: #{err}", :red)
82
+ raise
79
83
  end
80
84
 
81
85
  # get an answer from the engine for a question.
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Boxcars
4
4
  # The current version of the gem.
5
- VERSION = "0.6.7"
5
+ VERSION = "0.6.8"
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.6.7
4
+ version: 0.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Sullivan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-12-04 00:00:00.000000000 Z
12
+ date: 2024-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: anthropic