Automatic update from web-platform-tests [Prompt API] Decouple AIPromptAPILegacyParams from Web Origin Trial Unlink the legacy raw parameter surfaces (temperature, topK, and params()) from the active AIPromptAPIParams Web Origin Trial. Standard web pages participating in the Origin Trial will no longer have functional access to these legacy parameters (the values are ignored and trigger console deprecation warnings). These parameter surfaces remain fully functional in Extension contexts (which explicitly enable the legacy flag) and when manually enabled via command-line flags. Bug: 502214118 Change-Id: I151798b36d18b910edd031c21aaec073578c1c3c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7869250 Reviewed-by: Mike Wasserman <msw@chromium.org> Commit-Queue: Isaac Ahouma <iahouma@google.com> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1646755} -- wpt-commits: 4c8560de79d486b060273a8d8acb00d0a80a756e wpt-pr: 60629
62 lines
2.4 KiB
JavaScript
62 lines
2.4 KiB
JavaScript
// META: title=Language Model Prompt - Sampling Mode Availability
|
|
// META: script=/resources/testdriver.js
|
|
// META: script=/resources/testdriver-vendor.js
|
|
// META: script=../resources/util.js
|
|
// META: timeout=long
|
|
|
|
'use strict';
|
|
|
|
promise_test(async t => {
|
|
const modes = ['most-predictable', 'predictable', 'balanced', 'creative', 'most-creative'];
|
|
|
|
for (const mode of modes) {
|
|
const result = await LanguageModel.availability({ samplingMode: mode });
|
|
assert_true(kValidAvailabilities.includes(result),
|
|
`Availability returned valid result for ${mode} mode`
|
|
);
|
|
}
|
|
}, 'LanguageModel.availability() accepts all valid sampling modes');
|
|
|
|
const legacyParamsEnabled = ('params' in LanguageModel);
|
|
|
|
if (legacyParamsEnabled) {
|
|
promise_test(async t => {
|
|
await promise_rejects_js(
|
|
t,
|
|
TypeError,
|
|
LanguageModel.availability({ samplingMode: 'balanced', temperature: 0.8 })
|
|
);
|
|
}, 'LanguageModel.availability() rejects when both samplingMode and temperature are provided');
|
|
|
|
promise_test(async t => {
|
|
await promise_rejects_js(
|
|
t,
|
|
TypeError,
|
|
LanguageModel.availability({ samplingMode: 'balanced', topK: 10 })
|
|
);
|
|
}, 'LanguageModel.availability() rejects when both samplingMode and topK are provided');
|
|
|
|
promise_test(async t => {
|
|
await promise_rejects_js(
|
|
t,
|
|
TypeError,
|
|
LanguageModel.availability({ samplingMode: 'balanced', temperature: 0.8, topK: 10 })
|
|
);
|
|
}, 'LanguageModel.availability() rejects when samplingMode, temperature and topK are provided');
|
|
} else {
|
|
promise_test(async t => {
|
|
const result = await LanguageModel.availability({ samplingMode: 'balanced', temperature: 0.8 });
|
|
assert_true(kValidAvailabilities.includes(result));
|
|
}, 'LanguageModel.availability() accepts a sampling mode and ignores unsupported legacy temperature sampling option');
|
|
|
|
promise_test(async t => {
|
|
const result = await LanguageModel.availability({ samplingMode: 'balanced', topK: 10 });
|
|
assert_true(kValidAvailabilities.includes(result));
|
|
}, 'LanguageModel.availability() accepts a sampling mode and ignores unsupported legacy topK sampling option');
|
|
|
|
promise_test(async t => {
|
|
const result = await LanguageModel.availability({ samplingMode: 'balanced', temperature: 0.8, topK: 10 });
|
|
assert_true(kValidAvailabilities.includes(result));
|
|
}, 'LanguageModel.availability() accepts a sampling mode and ignores unsupported legacy sampling options');
|
|
}
|