From d3a6c3310c2f7910bb02406ff6de9ee8a7fa7591 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Thu, 24 Jul 2025 13:19:55 -0400 Subject: [PATCH 1/8] Add Chrome AI RTD Provider documentation --- dev-docs/modules/chromeAiRtdProvider.md | 244 ++++++++++++++++++++++++ 1 file changed, 244 insertions(+) create mode 100644 dev-docs/modules/chromeAiRtdProvider.md diff --git a/dev-docs/modules/chromeAiRtdProvider.md b/dev-docs/modules/chromeAiRtdProvider.md new file mode 100644 index 0000000000..69dff7cbb6 --- /dev/null +++ b/dev-docs/modules/chromeAiRtdProvider.md @@ -0,0 +1,244 @@ +--- +layout: page_v2 +title: Chrome AI RTD Provider +display_name: Chrome AI RTD Provider +description: Use Chrome AI APIs for language detection and summarization. +page_type: module +module_type: rtd +module_code : chromeAiRtdProvider +enable_download : true +sidebarType : 1 +--- + +# Chrome AI RTD Provider + +## Overview + +The Chrome AI RTD Provider is a Prebid.js Real-Time Data (RTD) module that enhances bidding by leveraging Chrome's built-in AI capabilities. It can automatically detect page language using the [Chrome AI Language Detection API](https://developer.chrome.com/docs/ai/language-detection) and generate page summaries or keywords using the [Chrome AI Summarizer API](https://developer.chrome.com/docs/ai/summarizer-api). This information is added to the OpenRTB bid request objects, allowing bid adapters to optimize bids based on content language and context. + +## Features + +- Automatic language detection using the Chrome AI Language Detection API. +- Automatic page summarization or keyword generation using the Chrome AI Summarizer API. +- Caching of detected language and summaries/keywords in localStorage to reduce redundant API calls (configurable for summarizer). +- Configurable options for both language detection (e.g., confidence threshold) and summarization (e.g., type, format, length). +- Flexible ORTB2 path configuration for placing detected data. +- Ability to enable/disable each feature independently. +- Compatible with the Prebid.js RTD framework. + +## Integration + +### Build Setup + +To include the Chrome AI RTD Provider in your Prebid.js build, use the following command: + +```bash +gulp build --modules=rtdModule,chromeAiRtdProvider +``` + +### Basic Integration + +Add the Chrome AI RTD Provider to your Prebid.js configuration: + +```javascript +pbjs.setConfig({ + realTimeData: { + dataProviders: [{ + name: 'chromeAi', + waitForIt: true // Optional: delays the auction until language detection completes + }] + } +}); +``` + +### Advanced Configuration + +Configure language detection and summarization with additional options: + +```javascript +pbjs.setConfig({ + realTimeData: { + dataProviders: [{ + name: 'chromeAi', + waitForIt: true, // Set to true if auction should wait for both enabled features + params: { + languageDetector: { + enabled: true, // Set to false to disable language detection + confidence: 0.9, // Set minimum confidence threshold (0.0 - 1.0) + ortb2Path: 'site.content.language' // Default path for language + }, + summarizer: { + enabled: false, // Set to true to enable summarization/keyword generation + type: 'headline', // 'headline','key-points', 'tldr' or 'teaser' + format: 'markdown', // 'plain-text' or 'markdown' + length: 'short', // 'short', 'medium', or 'long' + ortb2Path: 'site.content.keywords', // Path for summary/keywords + cacheInLocalStorage: true // Whether to cache generated summary/keywords + } + } + }] + } +}); +``` + +## Configuration Options + +| Parameter | Scope | Type | Description | Default | +|-----------|-------|------|-------------|---------| +| `waitForIt` | Optional | Boolean | Whether to delay auction for data retrieval | `false` | +| `languageDetector.enabled` | Optional | Boolean | Enable or disable language detection | `true` | +| `languageDetector.confidence` | Optional | Number | Minimum confidence threshold for detected language (0.0 - 1.0) | `0.8` | +| `languageDetector.ortb2Path` | Optional | String | Path in ORTB2 to store the detected language | `'site.content.language'` | +| `summarizer.enabled` | Optional | Boolean | Enable or disable summarization/keyword generation | `false` | +| `summarizer.type` | Optional | String | Type of summary: `'headline'`, `'key-points'`, `'tldr'`, or `'teaser'` | `'headline'` | +| `summarizer.format` | Optional | String | Format of the summary: `'plain-text'` or `'markdown'` | `'mark-down'` | +| `summarizer.length` | Optional | String | Length of the summary: `'short'`, `'medium'`, or `'long'` | `'short'` | +| `summarizer.ortb2Path` | Optional | String | Path in ORTB2 to store the generated summary/keywords | `'site.content.keywords'` | +| `summarizer.cacheInLocalStorage` | Optional | Boolean | Whether to cache the generated summary/keywords in localStorage | `true` | + +## How It Works + +The module initializes configured features (language detection, summarization) asynchronously. + +### Language Detection (`languageDetector`) + +1. **Data Prioritization**: On initialization or when `getBidRequestData` is called, the module first checks for existing language information in this order: + - Auction-specific ORTB2 data (from `reqBidsConfigObj` passed to `getBidRequestData`). + - Data cached in localStorage for the current page URL (from a previous detection). +2. **API Call**: If no language is found and the feature is enabled, it attempts to detect the language of the visible page content using the Chrome AI Language Detection API. + - The API's `availability()` method is checked. If 'unavailable', detection is skipped. If 'after-download', the module may proceed if the model downloads. +3. **Data Handling**: The detected language (if it meets the confidence threshold) is: + - Stored in localStorage for future page loads on the same URL. + - Added to the OpenRTB bid requests at the configured `languageDetector.ortb2Path` (default: `site.content.language`). + +### Summarization / Keyword Generation (`summarizer`) + +1. **Data Prioritization**: Similar to language detection, it checks for existing summary/keywords: + - Auction-specific ORTB2 data. + - Data cached in localStorage (if `cacheInLocalStorage: true`). +2. **API Call**: If no data is found and the feature is enabled, it attempts to generate a summary/keywords from the page content using the Chrome AI Summarizer API. + - The API's `availability()` method is checked. If 'unavailable', summarization is skipped. If 'after-download', the module may proceed. +3. **Data Handling**: The generated summary/keywords are: + - Stored in localStorage (if `cacheInLocalStorage: true`). + - Added to the OpenRTB bid requests at the configured `summarizer.ortb2Path` (default: `site.content.keywords`). + +If `waitForIt: true` is set in the RTD config, the auction will be delayed until all enabled and available Chrome AI features complete their processing. + +## Requirements + +- The browser must support the Chrome AI APIs being used (Language Detection, Summarizer). +- The specific Chrome AI models (e.g., for language detection or summarization) must be 'available' or become 'available-after-download'. The module handles these states. +- Sufficient text content must be available on the page (minimum 20 characters for language detection and summarization). +- If using the `waitForIt: true` option, consider the potential impact on auction latency. + +## Limitations + +- Relies on browser support for Chrome AI APIs. +- Requires sufficient and meaningful visible text content on the page for accurate results. +- Language detection may not be accurate for pages with multiple languages mixed together. +- Summarization quality depends on the page content and the capabilities of the underlying Chrome AI model. + +## Browser Compatibility + +- Chrome: 138(Beta)+ +- Firefox, Safari: Not supported (lacks Chrome AI API) + +## Example Use Cases + +### Standard Implementation + +```javascript +pbjs.setConfig({ + realTimeData: { + dataProviders: [{ + name: 'chromeAi', + waitForIt: true + }] + } +}); +``` + +### Disable Language Detection for Specific Sites + +```javascript +pbjs.setConfig({ + realTimeData: { + dataProviders: [{ + name: 'chromeAi', + params: { + languageDetector: { + enabled: false + } + } + }] + } +}); +``` + +### Higher Confidence Requirement for Language Detection + +```javascript +pbjs.setConfig({ + realTimeData: { + dataProviders: [{ + name: 'chromeAi', + waitForIt: true, + params: { + languageDetector: { + enabled: true, + confidence: 0.95 // Only use high-confidence detections + } + } + }] + } +}); +``` + +### Enable Summarizer with Custom Settings + +```javascript +pbjs.setConfig({ + realTimeData: { + dataProviders: [{ + name: 'chromeAi', + waitForIt: true, + params: { + languageDetector: { + enabled: false // Example: only using summarizer + }, + summarizer: { + enabled: true, + type: 'teaser', + format: 'markdown', // In markdown format + length: 'medium', + ortb2Path: 'site.ext.data.summary', // Custom ORTB2 path + } + } + }] + } +}); +``` + +## Integration with Other Modules + +The Chrome AI RTD Provider is compatible with other Prebid.js modules and can be used alongside other RTD providers: + +```javascript +pbjs.setConfig({ + realTimeData: { + dataProviders: [ + { + name: 'chromeAi', + waitForIt: false + }, + { + name: 'anotherProvider', + waitForIt: true, + params: { + // other provider config + } + } + ] + } +}); +``` From 1ad446baf7d96a9dd295dc33e9cf2798a0cd9979 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Wed, 30 Jul 2025 11:32:20 -0400 Subject: [PATCH 2/8] Update dev-docs/modules/chromeAiRtdProvider.md Co-authored-by: Muki Seiler --- dev-docs/modules/chromeAiRtdProvider.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev-docs/modules/chromeAiRtdProvider.md b/dev-docs/modules/chromeAiRtdProvider.md index 69dff7cbb6..6a5fdb15af 100644 --- a/dev-docs/modules/chromeAiRtdProvider.md +++ b/dev-docs/modules/chromeAiRtdProvider.md @@ -83,6 +83,8 @@ pbjs.setConfig({ ## Configuration Options + +{: .table .table-bordered .table-striped } | Parameter | Scope | Type | Description | Default | |-----------|-------|------|-------------|---------| | `waitForIt` | Optional | Boolean | Whether to delay auction for data retrieval | `false` | From 11b51b5e469b98908b1fe7ec0496ddbf7f131372 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Wed, 30 Jul 2025 11:32:29 -0400 Subject: [PATCH 3/8] Update dev-docs/modules/chromeAiRtdProvider.md Co-authored-by: Muki Seiler --- dev-docs/modules/chromeAiRtdProvider.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dev-docs/modules/chromeAiRtdProvider.md b/dev-docs/modules/chromeAiRtdProvider.md index 6a5fdb15af..3541dc7eeb 100644 --- a/dev-docs/modules/chromeAiRtdProvider.md +++ b/dev-docs/modules/chromeAiRtdProvider.md @@ -142,9 +142,7 @@ If `waitForIt: true` is set in the RTD config, the auction will be delayed until ## Browser Compatibility -- Chrome: 138(Beta)+ -- Firefox, Safari: Not supported (lacks Chrome AI API) - +[Language Detector API Support](https://caniuse.com/mdn-api_languagedetector) ## Example Use Cases ### Standard Implementation From b49ec29e8650eb75a1ce56e01104a5edc76d41f2 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Wed, 30 Jul 2025 11:32:34 -0400 Subject: [PATCH 4/8] Update dev-docs/modules/chromeAiRtdProvider.md Co-authored-by: Muki Seiler --- dev-docs/modules/chromeAiRtdProvider.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev-docs/modules/chromeAiRtdProvider.md b/dev-docs/modules/chromeAiRtdProvider.md index 3541dc7eeb..1589cb3536 100644 --- a/dev-docs/modules/chromeAiRtdProvider.md +++ b/dev-docs/modules/chromeAiRtdProvider.md @@ -126,7 +126,8 @@ The module initializes configured features (language detection, summarization) a If `waitForIt: true` is set in the RTD config, the auction will be delayed until all enabled and available Chrome AI features complete their processing. -## Requirements + +## Browser Compatibility - The browser must support the Chrome AI APIs being used (Language Detection, Summarizer). - The specific Chrome AI models (e.g., for language detection or summarization) must be 'available' or become 'available-after-download'. The module handles these states. From 1e65e21f6bd6798fe6df1467933bda56a48a591b Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Wed, 30 Jul 2025 11:32:43 -0400 Subject: [PATCH 5/8] Update dev-docs/modules/chromeAiRtdProvider.md Co-authored-by: Muki Seiler --- dev-docs/modules/chromeAiRtdProvider.md | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/dev-docs/modules/chromeAiRtdProvider.md b/dev-docs/modules/chromeAiRtdProvider.md index 1589cb3536..375c140fa9 100644 --- a/dev-docs/modules/chromeAiRtdProvider.md +++ b/dev-docs/modules/chromeAiRtdProvider.md @@ -220,26 +220,3 @@ pbjs.setConfig({ }); ``` -## Integration with Other Modules - -The Chrome AI RTD Provider is compatible with other Prebid.js modules and can be used alongside other RTD providers: - -```javascript -pbjs.setConfig({ - realTimeData: { - dataProviders: [ - { - name: 'chromeAi', - waitForIt: false - }, - { - name: 'anotherProvider', - waitForIt: true, - params: { - // other provider config - } - } - ] - } -}); -``` From 6c2f673268104878f02b0b164fbd997063ba57e6 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Wed, 30 Jul 2025 11:37:25 -0400 Subject: [PATCH 6/8] Update chromeAiRtdProvider.md --- dev-docs/modules/chromeAiRtdProvider.md | 1 - 1 file changed, 1 deletion(-) diff --git a/dev-docs/modules/chromeAiRtdProvider.md b/dev-docs/modules/chromeAiRtdProvider.md index 375c140fa9..8f7d217d5d 100644 --- a/dev-docs/modules/chromeAiRtdProvider.md +++ b/dev-docs/modules/chromeAiRtdProvider.md @@ -83,7 +83,6 @@ pbjs.setConfig({ ## Configuration Options - {: .table .table-bordered .table-striped } | Parameter | Scope | Type | Description | Default | |-----------|-------|------|-------------|---------| From d4220ceda3c8e07c7a1683ff7e0b9b6825ad2a0a Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Wed, 30 Jul 2025 11:37:49 -0400 Subject: [PATCH 7/8] Update chromeAiRtdProvider.md --- dev-docs/modules/chromeAiRtdProvider.md | 1 - 1 file changed, 1 deletion(-) diff --git a/dev-docs/modules/chromeAiRtdProvider.md b/dev-docs/modules/chromeAiRtdProvider.md index 8f7d217d5d..cf73728456 100644 --- a/dev-docs/modules/chromeAiRtdProvider.md +++ b/dev-docs/modules/chromeAiRtdProvider.md @@ -125,7 +125,6 @@ The module initializes configured features (language detection, summarization) a If `waitForIt: true` is set in the RTD config, the auction will be delayed until all enabled and available Chrome AI features complete their processing. - ## Browser Compatibility - The browser must support the Chrome AI APIs being used (Language Detection, Summarizer). From 8ed748836cc37fdb87b3145b67e8e707926df997 Mon Sep 17 00:00:00 2001 From: Patrick McCann Date: Wed, 30 Jul 2025 11:42:08 -0400 Subject: [PATCH 8/8] Update chromeAiRtdProvider.md --- dev-docs/modules/chromeAiRtdProvider.md | 1 - 1 file changed, 1 deletion(-) diff --git a/dev-docs/modules/chromeAiRtdProvider.md b/dev-docs/modules/chromeAiRtdProvider.md index cf73728456..e4c78a238e 100644 --- a/dev-docs/modules/chromeAiRtdProvider.md +++ b/dev-docs/modules/chromeAiRtdProvider.md @@ -217,4 +217,3 @@ pbjs.setConfig({ } }); ``` -