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
// Create an executor that can execute StreamToolCalls
104
+
constexecutor=newStreamToolExecutor(tools);
105
+
106
+
// We'll stream two updates: a partial update and a full update
107
+
// to use streaming operations, we need to get a writer
113
108
constwriter=executor.writable.getWriter();
109
+
110
+
// write a partial update
114
111
writer.write({
115
112
operation: {
116
113
type: "update",
117
114
id: blockToChange,
118
115
block:
119
116
"<p>This Open source software like Hello World refers to computer programs, this is a longer update, let's write a first sentence that's quite long long long long here.",
120
117
},
118
+
// this is not an update to an earlier "update" StreamToolCall
121
119
isUpdateToPreviousOperation: false,
120
+
// this operation is a partial update and will be "completed" by the next update
@@ -129,55 +128,73 @@ export default function App() {
129
128
block:
130
129
"<p>This Open source software like Hello World refers to computer programs, this is a longer update, let's write a first sentence that's quite long long long long here. And now let's write a second sentence.</p>",
131
130
},
131
+
// this is an update to an earlier "update" StreamToolCall
132
132
isUpdateToPreviousOperation: true,
133
+
// this operation is not a partial update, we've received the entire invocation
// add the default AI slash menu items, or define your own
176
-
...getAISlashMenuItems(props.editor),
177
-
],
178
-
query,
179
-
)
180
-
}
181
-
/>
162
+
// Create an executor that can execute StreamToolCalls
163
+
constexecutor=newStreamToolExecutor(tools);
164
+
165
+
// We'll stream two updates: a partial update and a full update
166
+
// to use streaming operations, we need to get a writer
167
+
constwriter=executor.writable.getWriter();
168
+
169
+
// write a partial update, notice how the JSON is cut off (simulating a streaming json response)
170
+
writer.write(
171
+
`{
172
+
"type": "update",
173
+
"id": ${JSON.stringify(blockToChange+"$")},
174
+
"block": "<p>This Open source software like Hello World refers to computer programs, this is a longer update, let's write a first sentence that's quite long long long long here.`,
"<p>This Open source software like Hello World refers to computer programs, this is a longer update, let's write a first sentence that's quite long long long long here. And now let's write a second sentence.</p>"
0 commit comments