You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-6Lines changed: 60 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -232,6 +232,41 @@ Details:
232
232
233
233
* As described [above](#customizing-the-role-per-prompt), you can also supply a `role` value in these objects, so that the full form is `{ role, type, content }`. However, for now, using any role besides the default `"user"` role with an image or audio prompt will reject with a `"NotSupportedError"``DOMException`. (As we explore multimodal outputs, this restriction might be lifted in the future.)
234
234
235
+
### Multiple modalities in a single message
236
+
237
+
Consider a prompt such as `Here is an image: <<<image>>>. Please describe it.`. This is intended to be a single prompt from the user role. To express this, you can use an array for the `content` value:
238
+
239
+
```js
240
+
constresponse=awaitsession.prompt({
241
+
type:"user",
242
+
content: [
243
+
"Here is an image: ",
244
+
{ type:"image", content: imageBytes },
245
+
". Please describe it."
246
+
]
247
+
});
248
+
```
249
+
250
+
This has _different semantics_ than prompting with multiple user messages:
Those examples involve three separate user messages, which the underlying model will likely interpret differently. (To see this, compare with [our above multi-user example](#customizing-the-role-per-prompt), or with how you react when someone texts you three messages in a row vs. a single message.)
269
+
235
270
### Structured output or JSON output
236
271
237
272
To help with programmatic processing of language model responses, the prompt API supports structured outputs defined by a JSON schema.
0 commit comments