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: index.bs
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -190,6 +190,8 @@ typedef (
190
190
191
191
1. If |message|["{{LanguageModelMessage/role}}"] is not "{{LanguageModelMessageRole/assistant}}", then throw a "{{SyntaxError}}" {{DOMException}}.
192
192
193
+
<p class="note">Per the below validation steps, this will also guarantee that |message|["{{LanguageModelMessage/content}}"] only contains text content.
194
+
193
195
1. If |message| is not the last item in |messages|, then throw a "{{SyntaxError}}" {{DOMException}}.
194
196
195
197
1. [=list/For each=] |content| of |message|["{{LanguageModelMessage/content}}"]:
@@ -218,6 +220,32 @@ typedef (
218
220
219
221
1. If |content|["{{LanguageModelMessageContent/value}}"] is not an {{AudioBuffer}}, {{BufferSource}}, or {{Blob}}, then throw a {{TypeError}}.
220
222
223
+
1. Let |contentWithContiguousTextCollapsed| be an empty [=list=] of {{LanguageModelMessageContent}}s.
224
+
225
+
1. Let |lastTextContent| be null.
226
+
227
+
1. [=list/For each=] |content| of |message|["{{LanguageModelMessage/content}}"]:
228
+
229
+
1. If |content|["{{LanguageModelMessageContent/type}}"] is "{{LanguageModelMessageType/text}}":
230
+
231
+
1. If |lastTextContent| is null:
232
+
233
+
1. [=list/Append=] |content| to |contentWithContiguousTextCollapsed|.
234
+
235
+
1. Set |lastTextContent| to |content|.
236
+
237
+
1. Otherwise, set |lastTextContent|["{{LanguageModelMessageContent/value}}"] to the concatenation of |lastTextContent|["{{LanguageModelMessageContent/value}}"] and |content|["{{LanguageModelMessageContent/value}}"].
238
+
239
+
<p class="note">No space or other character is added. Thus, « «[ "{{LanguageModelMessageContent/type}}" → "{{LanguageModelMessageType/text}}", "`foo`" ]», «[ "{{LanguageModelMessageContent/type}}" → "{{LanguageModelMessageType/text}}", "`bar`" ]» » is canonicalized to « «[ "{{LanguageModelMessageContent/type}}" → "{{LanguageModelMessageType/text}}", "`foobar`" ]».</p>
240
+
241
+
1. Otherwise:
242
+
243
+
1. [=list/Append=] |content| to |contentWithContiguousTextCollapsed|.
244
+
245
+
1. Set |lastTextContent| to null.
246
+
247
+
1. Set |message|["{{LanguageModelMessage/content}}"] to |contentWithContiguousTextCollapsed|.
248
+
221
249
1. [=list/Append=] |message| to |messages|.
222
250
223
251
1. If |messages| [=list/is empty=], then throw a "{{SyntaxError}}" {{DOMException}}.
0 commit comments