Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 8a619fa

Browse files
committed
more tests
1 parent 55530b3 commit 8a619fa

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

lib/ai_bot/bot_context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def initialize(
1818
participants: nil,
1919
user: nil,
2020
skip_tool_details: nil,
21-
messages:,
21+
messages: [],
2222
custom_instructions: nil
2323
)
2424
@participants = participants

lib/ai_bot/tools/read_artifact.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def discourse_artifact?(uri)
5959
end
6060

6161
def post
62-
@post ||= Post.find_by(id: context[:post_id])
62+
@post ||= Post.find_by(id: context.post_id)
6363
end
6464

6565
def handle_discourse_artifact(uri)

lib/ai_helper/assistant.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,10 @@ def generate_image_caption(upload, user)
188188
messages: [
189189
{
190190
type: :user,
191-
content:
191+
content: [
192192
"Describe this image in a single sentence#{custom_locale_instructions(user)}",
193-
upload_ids: [upload.id],
193+
{ upload_id: upload.id },
194+
],
194195
},
195196
],
196197
)

spec/lib/modules/ai_bot/tools/read_artifact_spec.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
{ url: "#{Discourse.base_url}/discourse-ai/ai-bot/artifacts/#{artifact.id}" },
2626
bot_user: bot_user,
2727
llm: llm_model.to_llm,
28-
context: {
29-
post_id: post2.id,
30-
},
28+
context: DiscourseAi::AiBot::BotContext.new(post: post),
3129
)
3230

3331
result = tool.invoke {}
@@ -46,9 +44,7 @@
4644
{ url: "invalid-url" },
4745
bot_user: bot_user,
4846
llm: llm_model.to_llm,
49-
context: {
50-
post_id: post.id,
51-
},
47+
context: DiscourseAi::AiBot::BotContext.new(post: post),
5248
)
5349

5450
result = tool.invoke {}
@@ -62,9 +58,7 @@
6258
{ url: "#{Discourse.base_url}/discourse-ai/ai-bot/artifacts/99999" },
6359
bot_user: bot_user,
6460
llm: llm_model.to_llm,
65-
context: {
66-
post_id: post.id,
67-
},
61+
context: DiscourseAi::AiBot::BotContext.new(post: post),
6862
)
6963

7064
result = tool.invoke {}
@@ -97,9 +91,7 @@
9791
{ url: "https://example.com" },
9892
bot_user: bot_user,
9993
llm: llm_model.to_llm,
100-
context: {
101-
post_id: post.id,
102-
},
94+
context: DiscourseAi::AiBot::BotContext.new(post: post),
10395
)
10496

10597
result = tool.invoke {}
@@ -128,9 +120,7 @@
128120
{ url: "https://example.com" },
129121
bot_user: bot_user,
130122
llm: llm_model.to_llm,
131-
context: {
132-
post_id: post.id,
133-
},
123+
context: DiscourseAi::AiBot::BotContext.new(post: post),
134124
)
135125

136126
result = tool.invoke {}

0 commit comments

Comments
 (0)