1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module optimization_guide.mojom;
import "mojo/public/mojom/base/proto_wrapper.mojom";
import "services/on_device_model/public/mojom/on_device_model.mojom";
enum ModelBasedCapabilityKey {
kCompose = 1,
kTabOrganization = 2,
kWallpaperSearch = 3,
kTest = 4,
kTextSafety = 5,
kPromptApi = 6,
kHistorySearch = 7,
kSummarize = 8,
kHistoryQueryIntent = 12,
kBlingPrototyping = 13,
kPasswordChangeSubmission = 14,
kScamDetection = 15,
kPermissionsAi = 17,
kWritingAssistanceApi = 18,
kFormsClassifications = 20,
kEnhancedCalendar = 23,
kZeroStateSuggestions = 24,
};
// Describes how a particular set of models can be used to implement a
// model based capability.
struct ModelSolutionConfig {
mojo_base.mojom.ProtoWrapper feature_config;
mojo_base.mojom.ProtoWrapper text_safety_config;
mojo_base.mojom.ProtoWrapper model_versions;
int32 max_tokens;
};
// An interface for creating the models required for a particular
// ModelSolutionConfig. The remote end may be held by any process, the
// receiver should be in the browser process.
interface ModelSolution {
// Creates a session for the language model described by the
// ModelSolutionConfig. The session receiver will be bound in the ODM
// process.
CreateSession(
pending_receiver<on_device_model.mojom.Session> session,
on_device_model.mojom.SessionParams params);
// Creates a session for the text-safety model described by the
// ModelSolutionConfig. The session receiver will be bound in the ODM
// process.
CreateTextSafetySession(
pending_receiver<on_device_model.mojom.TextSafetySession> session);
// Report to the broker that model execution worked correctly.
ReportHealthyCompletion();
};
enum ModelUnavailableReason {
// Availability not determined yet.
kUnknown = 0,
// Skipping 1 to be consistent with Modelavailability::kAvailable = 1,
// Model solution won't become available.
kNotSupported = 2,
// Model solution should become available.
kPendingAssets = 3,
// Model solution might become available if requested.
kPendingUsage = 4,
};
// A consumer that needs to the current configs and models for some model based
// capability. The receiver end may be held by any process, the remote will be
// in the browser process.
interface ModelSubscriber {
// Indicates that a model solution is currently unavailable and whether it is
// expected to become available. A disconnect may be sent shortly if the
// model will not become available later.
Unavailable(ModelUnavailableReason reason);
// Indicates that the model solution is available, and provides the config for
// how to use it. The solution may still become unavailable later or be
// replaced with a different solution.
Available(
ModelSolutionConfig config, pending_remote<ModelSolution> capability);
};
// Options for ModelBroker::Subscribe
struct ModelSubscriptionOptions {
ModelBasedCapabilityKey id;
bool mark_used;
};
// Broker for using the on-device models. The remote end may be held by any
// process, the receiver should be in the browser process.
interface ModelBroker {
// Starts listening for models that provide the requested capability.
Subscribe(
ModelSubscriptionOptions opts,
pending_remote<ModelSubscriber> client);
};
|