mirror of
https://github.com/mozilla-firefox/firefox
synced 2026-08-12 12:35:33 +00:00
Bug 2037306 [wpt PR 59678] - Track whether a LanguageModel has initial context for enforcing role sequence, a=testonly
Automatic update from web-platform-tests Track whether a LanguageModel has initial context for enforcing role sequence - Update the logic for `has_context_` to account for non-empty `initialPrompts` - This flag is propagated during cloning. - Add new WPT tests Bug: 507881464 Change-Id: I51355786fe564da4b2eda29b6ca8a70906c3f9a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7815022 Auto-Submit: Jingyun Liu <jingyun@google.com> Commit-Queue: Mike Wasserman <msw@chromium.org> Reviewed-by: Mike Wasserman <msw@chromium.org> Cr-Commit-Position: refs/heads/main@{#1625972} -- wpt-commits: 93bfb55926e0a42956dd0ddf3d448a3a67d0ec01 wpt-pr: 59678
This commit is contained in:
committed by
wptsync@mozilla.com
parent
fff09d37a3
commit
9a09478f65
+9
@@ -66,3 +66,12 @@ promise_test(async (t) => {
|
||||
await model.append([{ role: 'user', content: [] }]);
|
||||
await model.append([{role: 'user', content: [{type: 'text', value: ''}]}]);
|
||||
}, 'LanguageModel.append() allows empty and coerced inputs');
|
||||
|
||||
promise_test(async t => {
|
||||
await ensureLanguageModel();
|
||||
const session = await createLanguageModel(
|
||||
{initialPrompts: [{role: 'user', content: 'initial user prompt'}]});
|
||||
await promise_rejects_js(
|
||||
t, TypeError,
|
||||
session.append([{role: 'system', content: 'append system prompt'}]));
|
||||
}, 'append() after initializing with user prompt should reject system role');
|
||||
+1
-1
@@ -27,7 +27,7 @@ promise_test(async () => {
|
||||
assert_greater_than(usage, 0);
|
||||
assert_equals(session.contextUsage, usage);
|
||||
assert_regexp_match(
|
||||
await session.prompt([{role: 'system', content: ''}]), kValidAudioRegex);
|
||||
await session.prompt([{role: 'user', content: ''}]), kValidAudioRegex);
|
||||
}, 'Test Audio initialPrompt');
|
||||
|
||||
promise_test(async () => {
|
||||
|
||||
@@ -12,3 +12,5 @@ promise_test(async () => {
|
||||
const result = await session.prompt(kTestPrompt);
|
||||
assert_equals(typeof result, 'string');
|
||||
}, 'Simple LanguageModel.prompt() call');
|
||||
|
||||
|
||||
+9
@@ -26,3 +26,12 @@ promise_test(async t => {
|
||||
t, TypeError, session.prompt([{role: 'system', content: 'bar'}]));
|
||||
await result3;
|
||||
}, 'prompt() should reject system role messages after other messages');
|
||||
|
||||
promise_test(async t => {
|
||||
await ensureLanguageModel();
|
||||
const session = await createLanguageModel(
|
||||
{initialPrompts: [{role: 'user', content: 'initial user prompt'}]});
|
||||
await promise_rejects_js(
|
||||
t, TypeError,
|
||||
session.prompt([{role: 'system', content: 'prompt system prompt'}]));
|
||||
}, 'prompt() after initializing with user prompt should reject system role');
|
||||
Reference in New Issue
Block a user