-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AI Chat] Introduces support for host-specific distiller scripts (#25722
) This change introduces host-specific site distiller scripts, improving how content is parsed and presented for AI-driven text distillation. We’ve refined host retrieval from page origins, improved parsing and decoding logic, and addressed unsafe buffer issues. Distiller resources have been reorganized into a dedicated directory, while unnecessary complexity and reliance on regex-based lookups have been removed. We’ve switched from creating XML documents to HTML documents for more relaxed parsing rules, simplified the distillation process by removing events, and adopted absl::StrFormat for cleaner string handling. Namespace isolation and resource visibility controls have been tightened, and a disabled-by-default feature flag is now available for incremental rollout. Additional improvements include better handling of profile pages on X.com (formerly Twitter), clearer metadata prefaces to help LLMs understand where the page content begins, early returns on failed script lookups, and consistency in naming and formatting. Debugging logs and other extraneous elements have been removed to streamline the final implementation.
- Loading branch information
1 parent
8aeb9e5
commit 97fccd9
Showing
27 changed files
with
1,384 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
components/ai_chat/resources/custom_site_distiller_scripts/BUILD.gn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
import("//brave/components/common/typescript.gni") | ||
import("//tools/grit/repack.gni") | ||
|
||
transpile_web_ui("custom_site_distiller_scripts") { | ||
resource_name = "custom_site_distiller_scripts" | ||
visibility = [ ":*" ] | ||
entry_points = [ | ||
[ | ||
"x_com", | ||
rebase_path("scripts/x.com/index.ts"), | ||
], | ||
[ | ||
"github_com", | ||
rebase_path("scripts/github.com/index.ts"), | ||
], | ||
] | ||
output_module = true | ||
} | ||
|
||
pack_web_resources("generated_resources") { | ||
resource_name = "custom_site_distiller_scripts" | ||
output_dir = "$root_gen_dir/brave/components/ai_chat/resources/custom_site_distiller_scripts" | ||
deps = [ ":custom_site_distiller_scripts" ] | ||
} |
11 changes: 11 additions & 0 deletions
11
components/ai_chat/resources/custom_site_distiller_scripts/scripts/distillation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at https://mozilla.org/MPL/2.0/. */ | ||
|
||
export enum LEO_DISTILLATION_LEVEL { | ||
LOW = 0, | ||
MEDIUM = 1, | ||
HIGH = 2, | ||
FULL = 3 | ||
} |
Oops, something went wrong.