Skip to content

Commit b1deb6e

Browse files
committed
Fix IDL for prompts, again
The previous IDL had an invalid union of two sequence<dictionaries>, which are not distinguishable. This new approach is mostly the same. However, it also allows mixtures of shorthand and non-shorthand contents, e.g. [{ role: "user", content: "Foo" }, { role: "user", content: [{ type: "text", value: "Bar" }] }]. That seems like a good thing.
1 parent d44020d commit b1deb6e

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

README.md

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ dictionary LanguageModelCreateOptions : LanguageModelCreateCoreOptions {
745745
AbortSignal signal;
746746
AICreateMonitorCallback monitor;
747747
748-
LanguageModelInitialPrompts initialPrompts;
748+
sequence<LanguageModelMessage> initialPrompts;
749749
};
750750
751751
dictionary LanguageModelPromptOptions {
@@ -769,32 +769,16 @@ dictionary LanguageModelExpected {
769769
// The argument to the prompt() method and others like it
770770
771771
typedef (
772-
// Canonical format
773772
sequence<LanguageModelMessage>
774-
// Shorthand per the below comment
775-
or sequence<LanguageModelMessageShorthand>
776-
// Shorthand for [{ role: "user", content: [{ type: "text", value: providedValue }] }]
773+
// Shorthand for `[{ role: "user", content: [{ type: "text", value: providedValue }] }]`
777774
or DOMString
778775
) LanguageModelPrompt;
779776
780-
// The initialPrompts value omits the single string shorthand
781-
typedef (
782-
// Canonical format
783-
sequence<LanguageModelMessage>
784-
// Shorthand per the below comment
785-
or sequence<LanguageModelMessageShorthand>
786-
) LanguageModelInitialPrompts;
787-
788-
789777
dictionary LanguageModelMessage {
790778
required LanguageModelMessageRole role;
791-
required sequence<LanguageModelMessageContent> content;
792-
};
793779
794-
// Shorthand for { role: providedValue.role, content: [{ type: "text", value: providedValue.content }] }
795-
dictionary LanguageModelMessageShorthand {
796-
required LanguageModelMessageRole role;
797-
required DOMString content;
780+
// The DOMString branch is shorthand for `[{ type: "text", value: providedValue }]`
781+
required (DOMString or sequence<LanguageModelMessageContent>) content;
798782
};
799783
800784
dictionary LanguageModelMessageContent {

0 commit comments

Comments
 (0)