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

Send selected_language for ratings / feedback #26376

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions components/ai_chat/core/browser/ai_chat_feedback_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void AIChatFeedbackAPI::SendRating(
bool is_premium,
const base::span<const mojom::ConversationTurnPtr>& history,
const std::string& model_name,
const std::string& selected_language,
api_request_helper::APIRequestHelper::ResultCallback on_complete_callback) {
base::Value::Dict payload;

Expand All @@ -102,6 +103,7 @@ void AIChatFeedbackAPI::SendRating(
payload.Set("locale",
base::StrCat({brave_l10n::GetDefaultISOLanguageCodeString(), "_",
brave_l10n::GetDefaultISOCountryCodeString()}));
payload.Set("selected_language", selected_language);
payload.Set("rating", static_cast<int>(is_liked));
payload.Set("channel", channel_name_);
payload.Set("platform", brave_stats::GetPlatformIdentifier());
Expand All @@ -122,6 +124,7 @@ void AIChatFeedbackAPI::SendFeedback(
const std::string& feedback,
const std::string& rating_id,
const std::optional<std::string>& hostname,
const std::string& selected_language,
api_request_helper::APIRequestHelper::ResultCallback on_complete_callback) {
base::Value::Dict dict;

Expand All @@ -132,6 +135,7 @@ void AIChatFeedbackAPI::SendFeedback(
dict.Set("locale",
base::StrCat({brave_l10n::GetDefaultISOLanguageCodeString(), "_",
brave_l10n::GetDefaultISOCountryCodeString()}));
dict.Set("selected_language", selected_language);

if (hostname.has_value()) {
dict.Set("domain", hostname.value());
Expand Down
2 changes: 2 additions & 0 deletions components/ai_chat/core/browser/ai_chat_feedback_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ class AIChatFeedbackAPI {
bool is_premium,
const base::span<const mojom::ConversationTurnPtr>& history,
const std::string& model_name,
const std::string& selected_language,
api_request_helper::APIRequestHelper::ResultCallback
on_complete_callback);

void SendFeedback(const std::string& category,
const std::string& feedback,
const std::string& rating_id,
const std::optional<std::string>& hostname,
const std::string& selected_language,
api_request_helper::APIRequestHelper::ResultCallback
on_complete_callback);

Expand Down
9 changes: 5 additions & 4 deletions components/ai_chat/core/browser/conversation_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,10 @@ void ConversationHandler::RateMessage(bool is_liked,
base::span<const mojom::ConversationTurnPtr> history_slice =
base::make_span(history).first(current_turn_id);

feedback_api_->SendRating(
is_liked, ai_chat_service_->IsPremiumStatus(), history_slice,
model.options->get_leo_model_options()->name, std::move(on_complete));
feedback_api_->SendRating(is_liked, ai_chat_service_->IsPremiumStatus(),
history_slice,
model.options->get_leo_model_options()->name,
selected_language_, std::move(on_complete));

return;
}
Expand Down Expand Up @@ -425,7 +426,7 @@ void ConversationHandler::SendFeedback(const std::string& category,
(send_hostname && page_url.SchemeIsHTTPOrHTTPS())
? std::optional<std::string>(page_url.host())
: std::nullopt,
std::move(on_complete));
selected_language_, std::move(on_complete));
}

void ConversationHandler::GetConversationUuid(
Expand Down
Loading