Skip to content

Commit 2e96217

Browse files
committed
Add GenerateNextMessage and supporting domain mappers and types
1 parent f991d4b commit 2e96217

File tree

18 files changed

+660
-28
lines changed

18 files changed

+660
-28
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.0.13] - 2025-06-27
2+
3+
- Add GenerateChatCompletion command
4+
15
## [0.0.12] - 2025-05-27
26

37
- Do not load service models in parallel due to undiagnosed race condition somewhere

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ group :development do
1919
end
2020

2121
group :development, :test do
22-
gem "foobara-anthropic-api"
23-
gem "foobara-ollama-api"
22+
gem "foobara-anthropic-api" # , path: "../anthropic-api"
23+
gem "foobara-ollama-api" # , path: "../ollama-api"
2424
gem "foobara-open-ai-api" # , path: "../open-ai-api"
2525
gem "pry"
2626
gem "pry-byebug"

Gemfile.lock

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
PATH
22
remote: .
33
specs:
4-
foobara-ai (0.0.12)
4+
foobara-ai (0.0.13)
55

66
GEM
77
remote: https://rubygems.org/
88
specs:
99
addressable (2.8.7)
1010
public_suffix (>= 2.0.2, < 7.0)
1111
ast (2.4.3)
12-
base64 (0.2.0)
13-
bigdecimal (3.1.9)
12+
base64 (0.3.0)
13+
bigdecimal (3.2.2)
1414
byebug (12.0.0)
1515
coderay (1.1.3)
1616
crack (1.0.0)
@@ -55,12 +55,12 @@ GEM
5555
foobara-type-generator (~> 0.0.1)
5656
foobara-typescript-react-command-form-generator (~> 0.0.1)
5757
foobara-typescript-remote-command-generator (~> 0.0.1)
58-
foobara (0.0.127)
58+
foobara (0.0.134)
5959
bigdecimal
6060
foobara-lru-cache (~> 0.0.2)
61-
foobara-util (~> 0.0.11)
61+
foobara-util (>= 1.0.0)
6262
inheritable-thread-vars (~> 0.0.1)
63-
foobara-anthropic-api (0.0.10)
63+
foobara-anthropic-api (0.0.11)
6464
foobara-cached-command
6565
foobara-http-api-command
6666
foobara-cached-command (0.0.2)
@@ -76,7 +76,7 @@ GEM
7676
foobara-files-generator
7777
foobara-dotenv-loader (0.0.3)
7878
dotenv
79-
foobara-empty-ruby-project-generator (0.0.22)
79+
foobara-empty-ruby-project-generator (0.0.23)
8080
extract-repo (~> 0.0.1)
8181
foobara (~> 0.0.116)
8282
foobara-files-generator (~> 0.0.1)
@@ -93,9 +93,9 @@ GEM
9393
foobara-lru-cache (0.0.2)
9494
foobara-mcp-connector-generator (0.0.6)
9595
foobara (~> 0.0.99)
96-
foobara-ollama-api (0.0.4)
96+
foobara-ollama-api (0.0.5)
9797
foobara-http-api-command
98-
foobara-open-ai-api (0.0.12)
98+
foobara-open-ai-api (0.0.13)
9999
foobara-cached-command
100100
foobara-http-api-command
101101
foobara-organization-generator (0.0.2)
@@ -115,10 +115,10 @@ GEM
115115
foobara-resque-scheduler-connector-generator (0.0.2)
116116
foobara
117117
foobara-files-generator
118-
foobara-rubocop-rules (0.0.10)
118+
foobara-rubocop-rules (1.0.0)
119119
rubocop
120120
rubocop-rspec
121-
foobara-sh-cli-connector (0.0.17)
121+
foobara-sh-cli-connector (0.0.18)
122122
foobara (~> 0.0.88)
123123
foobara-sh-cli-connector-generator (0.0.5)
124124
foobara-files-generator (~> 0.0.1)
@@ -131,7 +131,7 @@ GEM
131131
foobara-typescript-remote-command-generator (~> 0.0.1)
132132
foobara-typescript-remote-command-generator (0.0.24)
133133
foobara-files-generator (~> 0.0.1)
134-
foobara-util (0.0.12)
134+
foobara-util (1.0.0)
135135
formatador (1.1.0)
136136
guard (2.19.1)
137137
formatador (>= 0.2.4)
@@ -150,7 +150,7 @@ GEM
150150
guard-compat (~> 1.1)
151151
rspec (>= 2.99.0, < 4.0)
152152
hashdiff (1.2.0)
153-
inheritable-thread-vars (0.0.2)
153+
inheritable-thread-vars (0.0.3)
154154
io-console (0.8.0)
155155
irb (1.15.2)
156156
pp (>= 0.6.0)
@@ -169,7 +169,7 @@ GEM
169169
notiffany (0.1.3)
170170
nenv (~> 0.1)
171171
shellany (~> 0.0)
172-
ostruct (0.6.1)
172+
ostruct (0.6.2)
173173
parallel (1.27.0)
174174
parser (3.3.8.0)
175175
ast (~> 2.4.1)
@@ -190,11 +190,11 @@ GEM
190190
public_suffix (6.0.2)
191191
racc (1.8.1)
192192
rainbow (3.1.1)
193-
rake (13.2.1)
193+
rake (13.3.0)
194194
rb-fsevent (0.11.2)
195195
rb-inotify (0.11.1)
196196
ffi (~> 1.0)
197-
rdoc (6.14.0)
197+
rdoc (6.14.1)
198198
erb
199199
psych (>= 4.0.0)
200200
regexp_parser (2.10.0)
@@ -205,7 +205,7 @@ GEM
205205
rspec-core (~> 3.13.0)
206206
rspec-expectations (~> 3.13.0)
207207
rspec-mocks (~> 3.13.0)
208-
rspec-core (3.13.4)
208+
rspec-core (3.13.5)
209209
rspec-support (~> 3.13.0)
210210
rspec-expectations (3.13.5)
211211
diff-lcs (>= 1.2.0, < 2.0)
@@ -217,18 +217,18 @@ GEM
217217
diff-lcs (>= 1.2.0, < 2.0)
218218
rspec-support (~> 3.13.0)
219219
rspec-support (3.13.4)
220-
rubocop (1.75.7)
220+
rubocop (1.77.0)
221221
json (~> 2.3)
222222
language_server-protocol (~> 3.17.0.2)
223223
lint_roller (~> 1.1.0)
224224
parallel (~> 1.10)
225225
parser (>= 3.3.0.2)
226226
rainbow (>= 2.2.2, < 4.0)
227227
regexp_parser (>= 2.9.3, < 3.0)
228-
rubocop-ast (>= 1.44.0, < 2.0)
228+
rubocop-ast (>= 1.45.1, < 2.0)
229229
ruby-progressbar (~> 1.7)
230230
unicode-display_width (>= 2.4.0, < 4.0)
231-
rubocop-ast (1.44.1)
231+
rubocop-ast (1.45.1)
232232
parser (>= 3.3.7.2)
233233
prism (~> 1.4)
234234
rubocop-rake (0.7.1)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
RSpec.describe Foobara::Ai::AnswerBot::GenerateNextMessage do
2+
let(:command) { described_class.new(inputs) }
3+
let(:outcome) { command.run }
4+
let(:result) { outcome.result }
5+
let(:errors) { outcome.errors }
6+
let(:errors_hash) { outcome.errors_hash }
7+
8+
let(:inputs) do
9+
{
10+
chat:,
11+
temperature:,
12+
model:
13+
}
14+
end
15+
let(:chat) do
16+
Foobara::Ai::AnswerBot::Types::Chat.new(
17+
messages: [
18+
{
19+
role: :system,
20+
content: "You are like a scientist that answers questions very concisely and accurately."
21+
},
22+
{
23+
role: :user,
24+
content: "What is the pH of honey?"
25+
},
26+
{
27+
content: "Honey typically has a pH between 3.4 and 6.1, with an average pH of about 3.9. " \
28+
"The acidity of honey is due to the presence of organic acids, primarily gluconic acid, " \
29+
"which is produced by glucose oxidase during honey formation.",
30+
role: :assistant
31+
},
32+
{
33+
role: :user,
34+
content: "What about vinegar?"
35+
}
36+
]
37+
)
38+
end
39+
let(:temperature) { 0 }
40+
41+
context "when using open-ai" do
42+
let(:model) { "gpt-3.5-turbo" }
43+
44+
it "is successful", vcr: { record: :none } do
45+
expect(outcome).to be_success
46+
expect(result.content).to match(/vinegar/i)
47+
end
48+
end
49+
50+
context "when using anthropic" do
51+
let(:model) { "claude-3-5-sonnet-20241022" }
52+
53+
it "is successful", vcr: { record: :once } do
54+
expect(outcome).to be_success
55+
expect(result.content).to match(/vinegar/i)
56+
end
57+
end
58+
59+
context "when using ollama" do
60+
let(:model) { "smollm2:135m" }
61+
62+
it "is successful", vcr: { record: :none } do
63+
expect(outcome).to be_success
64+
expect(result.content).to match(/vinegar/i)
65+
end
66+
end
67+
end

spec/vcr_cassettes/Foobara_Ai_AnswerBot_GenerateNextMessage/when_using_anthropic/is_successful.yml

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/vcr_cassettes/Foobara_Ai_AnswerBot_GenerateNextMessage/when_using_ollama/is_successful.yml

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)