Skip to content

Commit

Permalink
Send selected_language for ratings
Browse files Browse the repository at this point in the history
  • Loading branch information
bbondy committed Nov 5, 2024
1 parent dbcaadf commit bad3411
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
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

0 comments on commit bad3411

Please sign in to comment.