-
Notifications
You must be signed in to change notification settings - Fork 59
Description
The prompt API feels inconsistent because the create option AIAssistantCreateOptions takes AIAssistantPrompt, while the AIAssistant interface takes a DOMString as input.
dictionary AIAssistantCreateOptions {
AbortSignal signal;
AICreateMonitorCallback monitor;
DOMString systemPrompt;
sequence<AIAssistantPrompt> initialPrompts;
[EnforceRange] unsigned long topK;
float temperature;
};
dictionary AIAssistantPrompt {
AIAssistantPromptRole role;
DOMString content;
};
interface AIAssistant : EventTarget {
Promise<DOMString> prompt(DOMString input, optional AIAssistantPromptOptions options = {});
ReadableStream promptStreaming(DOMString input, optional AIAssistantPromptOptions options = {});
}
Practically this means that the prompt / promptStreaming methods assume that the new input is necessarily for the user role.
This limits the API, in that when function calling or multiple agents want to add a response to the conversation, they cannot breakout of the user role.
It would be better to have
Promise<DOMString> prompt(AIAssistantPrompt input, optional AIAssistantPromptOptions options = {});
ReadableStream promptStreaming(AIAssistantPrompt input, optional AIAssistantPromptOptions options = {});
This would allow tool call responses to be added to the chat as an assistant role.
Supporting multiple agents is still not possible, but this can be managed with an AIAssistantPrompt such as
<assistant> response from ratingAgent: This response looks appropriate </assistant>
for a hypothetical use case where the previous assistant message was a request for a rating agent to review a message.