coral: Add language to initialize param
Add language to initialize param such that we can load the correct model on initialization. The mojom change was introduced in https://crrev.com/c/6380256. Bug: b:399282851 Test: CQ Change-Id: Icc9f4b15eff32982a8424312d679d69a77b12df0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6382173 Reviewed-by: Achuith Bhandarkar <achuith@chromium.org> Reviewed-by: Xiaodan Zhu <zxdan@chromium.org> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org> Commit-Queue: Howard Yang <hcyang@google.com> Cr-Commit-Position: refs/heads/main@{#1437306}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
ab30fc6afa
commit
8607ececdb
ash
chrome/browser/ash/main_parts
chromeos/ash/services/coral/public/mojom
@ -880,6 +880,10 @@ void BirchCoralProvider::CacheTabEmbedding(TabClusterUIItem* tab_item) {
|
||||
coral::mojom::Entity::NewTab(std::move(tab_mojom)));
|
||||
CoralRequest request;
|
||||
request.set_content(std::move(active_tab_app_data));
|
||||
if (!system_language_.has_value()) {
|
||||
GetAndCheckLanguageAvailability();
|
||||
}
|
||||
request.set_language(*system_language_);
|
||||
Shell::Get()->coral_controller()->CacheEmbeddings(std::move(request));
|
||||
}
|
||||
|
||||
|
@ -129,8 +129,8 @@ CoralController::CoralController() = default;
|
||||
|
||||
CoralController::~CoralController() = default;
|
||||
|
||||
void CoralController::Initialize() {
|
||||
CoralProcessor* coral_processor = EnsureCoralProcessor();
|
||||
void CoralController::Initialize(std::string language) {
|
||||
CoralProcessor* coral_processor = EnsureCoralProcessor(std::move(language));
|
||||
if (!coral_processor) {
|
||||
LOG(ERROR) << "Failed to connect to coral processor.";
|
||||
}
|
||||
@ -147,7 +147,7 @@ void CoralController::GenerateContentGroups(
|
||||
return;
|
||||
}
|
||||
|
||||
CoralProcessor* coral_processor = EnsureCoralProcessor();
|
||||
CoralProcessor* coral_processor = EnsureCoralProcessor(request.language());
|
||||
if (!coral_processor) {
|
||||
LOG(ERROR) << "Failed to connect to coral processor.";
|
||||
std::move(callback).Run(nullptr);
|
||||
@ -182,7 +182,7 @@ void CoralController::GenerateContentGroups(
|
||||
}
|
||||
|
||||
void CoralController::CacheEmbeddings(const CoralRequest& request) {
|
||||
CoralProcessor* coral_processor = EnsureCoralProcessor();
|
||||
CoralProcessor* coral_processor = EnsureCoralProcessor(request.language());
|
||||
if (!coral_processor) {
|
||||
LOG(ERROR) << "Failed to connect to coral processor.";
|
||||
return;
|
||||
@ -303,7 +303,8 @@ void CoralController::OpenFeedbackDialog(const std::string& group_description) {
|
||||
weak_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
CoralController::CoralProcessor* CoralController::EnsureCoralProcessor() {
|
||||
CoralController::CoralProcessor* CoralController::EnsureCoralProcessor(
|
||||
std::string language) {
|
||||
// Generate a fake processor if --force-birch-fake-coral-backend is enabled.
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kForceBirchFakeCoralBackend)) {
|
||||
@ -333,7 +334,8 @@ CoralController::CoralProcessor* CoralController::EnsureCoralProcessor() {
|
||||
->BindMachineLearningService(
|
||||
ml_service.InitWithNewPipeAndPassReceiver());
|
||||
coral_service_->Initialize(std::move(ml_service),
|
||||
coral_processor_.BindNewPipeAndPassReceiver());
|
||||
coral_processor_.BindNewPipeAndPassReceiver(),
|
||||
language);
|
||||
coral_processor_.reset_on_disconnect();
|
||||
}
|
||||
|
||||
|
@ -105,10 +105,10 @@ class ASH_EXPORT CoralController {
|
||||
~CoralController();
|
||||
|
||||
// Claims necessary resources (dlc download / model loading) for processing
|
||||
// `GenerateContentGroups` and `CacheEmbeddings` requests. It is not necessary
|
||||
// to call `Initialize` before calling other methods, but in that case
|
||||
// the first method request might take longer to run.
|
||||
void Initialize();
|
||||
// `GenerateContentGroups` and `CacheEmbeddings` requests. This should be
|
||||
// run before other methods to ensure models are ready, and set up the
|
||||
// language.
|
||||
void Initialize(std::string language);
|
||||
|
||||
// GenerateContentGroups clusters the input ContentItems (which includes web
|
||||
// tabs, apps, etc.) into suitable groups based on their topics, and gives
|
||||
@ -147,7 +147,7 @@ class ASH_EXPORT CoralController {
|
||||
|
||||
// Requests coral processor from service manager and returns the pointer of
|
||||
// the processor instance.
|
||||
CoralProcessor* EnsureCoralProcessor();
|
||||
CoralProcessor* EnsureCoralProcessor(std::string language);
|
||||
|
||||
// Used as the callback of mojom::CoralProcessor::Group.
|
||||
void HandleGroupResult(CoralSource source,
|
||||
|
@ -287,6 +287,7 @@
|
||||
#include "ui/base/ime/ash/ime_keyboard.h"
|
||||
#include "ui/base/ime/ash/input_method_manager.h"
|
||||
#include "ui/base/ime/ash/input_method_util.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/pointer/pointer_device.h"
|
||||
#include "ui/base/ui_base_features.h"
|
||||
#include "ui/events/ash/pref_names.h"
|
||||
@ -1055,7 +1056,8 @@ void ChromeBrowserMainPartsAsh::PreProfileInit() {
|
||||
// CoralController depends on machine_learning::ServiceConnection, so needs to
|
||||
// be initialized after it.
|
||||
if (features::IsCoralFeatureEnabled()) {
|
||||
Shell::Get()->coral_controller()->Initialize();
|
||||
Shell::Get()->coral_controller()->Initialize(
|
||||
l10n_util::GetLanguage(g_browser_process->GetApplicationLocale()));
|
||||
}
|
||||
|
||||
// Needs to be initialized after crosapi_manager_.
|
||||
|
@ -240,5 +240,6 @@ interface CoralService {
|
||||
Initialize@3(
|
||||
pending_remote<chromeos.machine_learning.mojom.MachineLearningService>?
|
||||
ml_service,
|
||||
pending_receiver<CoralProcessor> processor);
|
||||
pending_receiver<CoralProcessor> processor,
|
||||
[MinVersion=2] string? language_code);
|
||||
};
|
||||
|
Reference in New Issue
Block a user