Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Use full URL for problem check message #1165

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions app/services/problem_check/ai_llm_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ def call
llm_errors
end

def base_path
Discourse.base_path
end

private

def llm_errors
Expand All @@ -26,20 +22,21 @@ def try_validate(model, &blk)
blk.call
nil
rescue => e
error_message = parse_error_message(e.message)
message =
"#{I18n.t("dashboard.problem.ai_llm_status", { base_path: base_path, model_name: model.display_name, model_id: model.id })}"
details = {
model_id: model.id,
model_name: model.display_name,
error: parse_error_message(e.message),
url: "#{Discourse.base_path}/admin/plugins/discourse-ai/ai-llms/#{model.id}/edit",
}

message = I18n.t("dashboard.problem.ai_llm_status", details)

Problem.new(
message,
priority: "high",
identifier: "ai_llm_status",
target: model.id,
details: {
model_id: model.id,
model_name: model.display_name,
error: error_message,
},
details:,
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,4 @@ en:
prompt_message_length: The message %{idx} is over the 1000 character limit.
dashboard:
problem:
ai_llm_status: "The LLM model: %{model_name} is encountering issues. Please check the <a href='%{base_path}/admin/plugins/discourse-ai/ai-llms/%{model_id}/edit'>model's configuration page</a>."
ai_llm_status: "The LLM model: %{model_name} is encountering issues. Please check the <a href='%{url}'>model's configuration page</a>."
9 changes: 8 additions & 1 deletion spec/services/problem_check/ai_llm_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
it "returns a problem with an LLM model" do
stub_request(:post, post_url).to_return(status: 403, body: error_response, headers: {})
message =
"#{I18n.t("dashboard.problem.ai_llm_status", { base_path: Discourse.base_path, model_name: llm_model.display_name, model_id: llm_model.id })}"
I18n.t(
"dashboard.problem.ai_llm_status",
{
model_name: llm_model.display_name,
url: "/admin/plugins/discourse-ai/ai-llms/#{llm_model.id}/edit",
},
)

expect(described_class.new.call).to contain_exactly(
have_attributes(
Expand All @@ -53,6 +59,7 @@
details: {
model_id: llm_model.id,
model_name: llm_model.display_name,
url: "/admin/plugins/discourse-ai/ai-llms/#{llm_model.id}/edit",
error: JSON.parse(error_response)["message"],
},
),
Expand Down