#include "chrome/browser/ai/ai_summarizer.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/ai/ai_utils.h"
#include "components/optimization_guide/core/optimization_guide_util.h"
#include "components/optimization_guide/proto/features/summarize.pb.h"
#include "components/optimization_guide/proto/string_value.pb.h"
#include "third_party/blink/public/mojom/ai/model_streaming_responder.mojom.h"
namespace {
optimization_guide::proto::SummarizerOutputType ToProtoOutputType(
blink::mojom::AISummarizerType type) { … }
optimization_guide::proto::SummarizerOutputFormat ToProtoOutputFormat(
blink::mojom::AISummarizerFormat format) { … }
optimization_guide::proto::SummarizerOutputLength ToProtoOutputLength(
blink::mojom::AISummarizerLength length) { … }
}
AISummarizer::AISummarizer(
std::unique_ptr<optimization_guide::OptimizationGuideModelExecutor::Session>
summarize_session,
const blink::mojom::AISummarizerOptions& options,
const std::optional<std::string>& shared_context,
mojo::PendingReceiver<blink::mojom::AISummarizer> receiver)
: … { … }
AISummarizer::~AISummarizer() { … }
void AISummarizer::SetDeletionCallback(base::OnceClosure deletion_callback) { … }
void AISummarizer::ModelExecutionCallback(
const std::string& input,
mojo::RemoteSetElementId responder_id,
optimization_guide::OptimizationGuideModelStreamingExecutionResult result) { … }
void AISummarizer::Summarize(
const std::string& input,
const std::string& context,
mojo::PendingRemote<blink::mojom::ModelStreamingResponder>
pending_responder) { … }