Use updated (not-released) client

This commit is contained in:
Tat Dat Duong
2025-05-06 03:22:25 +02:00
parent 46b1da4979
commit 27eaa1ed49
2 changed files with 24 additions and 26 deletions
+24 -25
View File
@@ -2597,35 +2597,34 @@ it("resumable streams", { timeout: 10_000 }, async () => {
const assistant = await client.assistants.create({ graphId: "agent" });
const thread = await client.threads.create();
const [monitor, stream] = ReadableStream.from(
client.runs.stream(thread.thread_id, assistant.assistant_id, {
input: {
messages: [{ role: "human", content: "input" }],
sleep: { steps: 3, ms: 1000 },
},
streamMode: ["values", "custom"],
config: globalConfig,
}),
).tee();
type RunMetadata = { run_id: string; thread_id?: string };
const metadata = await new Promise<{ run_id: string; thread_id: string }>(
async (resolve, reject) => {
for await (const chunk of monitor)
if (chunk.event === "metadata") resolve(chunk.data);
setTimeout(() => reject(new Error("Timeout waiting for metadata")), 1000);
let onRunCreated: ((params: RunMetadata) => void) | undefined = undefined;
const waitRun = new Promise<RunMetadata>((r) => (onRunCreated = r));
const stream = client.runs.stream(thread.thread_id, assistant.assistant_id, {
input: {
messages: [{ role: "human", content: "input" }],
sleep: { steps: 3, ms: 1000 },
},
);
streamMode: ["values", "custom"],
config: globalConfig,
onRunCreated,
});
const [join, source] = await Promise.all([
new Promise((resolve) => setTimeout(resolve, 1500)).then(() =>
gatherIterator(
new Client<any>({
apiUrl: API_URL,
// TODO: expose the `lastEventId` option
defaultHeaders: { "Last-Event-Id": "0" },
}).runs.joinStream(thread.thread_id, metadata.run_id),
),
),
(async () => {
const [{ thread_id, run_id }] = await Promise.all([
waitRun,
new Promise((resolve) => setTimeout(resolve, 1500)),
]);
return gatherIterator(
client.runs.joinStream(thread_id, run_id, { lastEventId: "0" }),
);
})(),
gatherIterator(stream),
]);
-1
View File
@@ -2,7 +2,6 @@
"compilerOptions": {
"strict": true,
"esModuleInterop": true,
"lib": ["ESNext"],
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,