From f48d3d761070bdc1e82da448af594e1806dd9595 Mon Sep 17 00:00:00 2001 From: Grace Brigham Date: Fri, 8 Nov 2024 12:47:43 -0800 Subject: [PATCH 1/7] fix threads wrappers --- sdk/ai/ai-projects/src/agents/index.ts | 24 ++++++++++++------------ sdk/ai/ai-projects/src/agents/threads.ts | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/sdk/ai/ai-projects/src/agents/index.ts b/sdk/ai/ai-projects/src/agents/index.ts index 4a391f60d0dd..c59554e5e300 100644 --- a/sdk/ai/ai-projects/src/agents/index.ts +++ b/sdk/ai/ai-projects/src/agents/index.ts @@ -4,13 +4,13 @@ import { Client } from "@azure-rest/core-client"; import { AgentDeletionStatusOutput, AgentOutput, AgentThreadOutput, FileDeletionStatusOutput, FileListResponseOutput, OpenAIFileOutput, OpenAIPageableListOfAgentOutput, OpenAIPageableListOfThreadRunOutput, ThreadDeletionStatusOutput, ThreadMessageOutput, ThreadRunOutput } from "../generated/src/outputModels.js"; -import { CancelRunParameters, CreateMessageParameters, CreateRunParameters, CreateThreadAndRunParameters, CreateThreadParameters, DeleteFileParameters, DeleteThreadParameters, GetFileContentParameters, GetFileParameters, GetRunParameters, GetThreadParameters, ListAgentsQueryParamProperties, ListFilesParameters, ListMessagesParameters, ListRunsParameters, SubmitToolOutputsToRunParameters, UpdateMessageParameters, UpdateRunParameters, UpdateThreadParameters, UploadFileParameters } from "../generated/src/parameters.js"; +import { CancelRunParameters, CreateMessageParameters, CreateRunParameters, CreateThreadAndRunParameters, DeleteFileParameters, DeleteThreadParameters, GetFileContentParameters, GetFileParameters, GetRunParameters, GetThreadParameters, ListAgentsQueryParamProperties, ListFilesParameters, ListMessagesParameters, ListRunsParameters, SubmitToolOutputsToRunParameters, UpdateMessageParameters, UpdateRunParameters, UploadFileParameters } from "../generated/src/parameters.js"; import { createAgent, deleteAgent, getAgent, listAgents, updateAgent } from "./assistants.js"; import { deleteFile, getFile, getFileContent, listFiles, uploadFile } from "./files.js"; import { createThread, deleteThread, getThread, updateThread } from "./threads.js"; import { cancelRun, createRun, createThreadAndRun, getRun, listRuns, submitToolOutputsToRun, updateRun } from "./runs.js"; import { createMessage, listMessages, updateMessage } from "./messages.js"; -import { CreateAgentOptions, UpdateAgentOptions } from "../generated/src/models.js"; +import { AgentThreadCreationOptions, CreateAgentOptions, UpdateAgentOptions, UpdateAgentThreadOptions } from "../generated/src/models.js"; export interface AgentsOperations { /** Creates a new agent. */ @@ -37,7 +37,7 @@ export interface AgentsOperations { /** Creates a new thread. Threads contain messages and can be run by agents. */ createThread: ( - options: CreateThreadParameters, + options?: AgentThreadCreationOptions, ) => Promise; /** Gets information about an existing thread. */ getThread: ( @@ -47,7 +47,7 @@ export interface AgentsOperations { /** Modifies an existing thread. */ updateThread: ( threadId: string, - options: UpdateThreadParameters, + options?: UpdateAgentThreadOptions, ) => Promise; /** Deletes an existing thread. */ deleteThread: ( @@ -152,14 +152,14 @@ function getAgents(context: Client) : AgentsOperations { assistantId: string ) => deleteAgent(context, assistantId), - createThread: (options: CreateThreadParameters) => - createThread(context, options), - getThread: (threadId: string, options?: GetThreadParameters) => - getThread(context, threadId, options), - updateThread: (threadId: string, options: UpdateThreadParameters) => - updateThread(context, threadId, options), - deleteThread: (threadId: string, options?: DeleteThreadParameters) => - deleteThread(context, threadId, options), + createThread: (options?: AgentThreadCreationOptions) => + createThread(context, {body: options as Record}), + getThread: (threadId: string) => + getThread(context, threadId), + updateThread: (threadId: string, options?: UpdateAgentThreadOptions) => + updateThread(context, threadId, {body: options as Record}), + deleteThread: (threadId: string) => + deleteThread(context, threadId), createRun: (threadId: string, options: CreateRunParameters) => createRun(context, threadId, options), diff --git a/sdk/ai/ai-projects/src/agents/threads.ts b/sdk/ai/ai-projects/src/agents/threads.ts index 8d54cf3981ca..1a046b0989ca 100644 --- a/sdk/ai/ai-projects/src/agents/threads.ts +++ b/sdk/ai/ai-projects/src/agents/threads.ts @@ -1,24 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. - + import { Client, createRestError } from "@azure-rest/core-client"; import { CreateThreadParameters, DeleteThreadParameters, GetThreadParameters, UpdateThreadParameters } from "../generated/src/parameters.js"; import { AgentThreadOutput, ThreadDeletionStatusOutput } from "../generated/src/outputModels.js"; - + const expectedStatuses = ["200"]; - + /** Creates a new thread. Threads contain messages and can be run by agents. */ export async function createThread( context: Client, - options: CreateThreadParameters, + options?: CreateThreadParameters, ): Promise { const result = await context.path("/threads").post(options); if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return result.body; + return result.body; } - + /** Gets information about an existing thread. */ export async function getThread( context: Client, @@ -31,14 +31,14 @@ export async function getThread( if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return result.body; + return result.body; } - + /** Modifies an existing thread. */ export async function updateThread( context: Client, threadId: string, - options: UpdateThreadParameters, + options?: UpdateThreadParameters, ): Promise { const result = await context .path("/threads/{threadId}", threadId) @@ -46,9 +46,9 @@ export async function updateThread( if (!expectedStatuses.includes(result.status)) { throw createRestError(result); } - return result.body; + return result.body; } - + /** Deletes an existing thread. */ export async function deleteThread( context: Client, From 0b3028432ae823a11adafc4b091a8300ce89385d Mon Sep 17 00:00:00 2001 From: Grace Brigham Date: Mon, 11 Nov 2024 09:02:45 -0800 Subject: [PATCH 2/7] initial tests --- .../test/public/agents/threads.spec.ts | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sdk/ai/ai-projects/test/public/agents/threads.spec.ts diff --git a/sdk/ai/ai-projects/test/public/agents/threads.spec.ts b/sdk/ai/ai-projects/test/public/agents/threads.spec.ts new file mode 100644 index 000000000000..aea2af5e5696 --- /dev/null +++ b/sdk/ai/ai-projects/test/public/agents/threads.spec.ts @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; +import { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; +import { createRecorder, createProjectsClient } from "../utils/createClient.js"; +import { assert, beforeEach, afterEach, it, describe } from "vitest"; + +describe("Agents - threads", () => { + let recorder: Recorder; + let projectsClient : AIProjectsClient; + let agents: AgentsOperations + + beforeEach(async function (context: VitestTestContext) { + recorder = await createRecorder(context); + projectsClient = createProjectsClient(recorder); + agents = projectsClient.agents + }); + + afterEach(async function () { + await recorder.stop(); + }); + + it("client and agents operations are accessible", async function () { + assert.isNotNull(projectsClient); + assert.isNotNull(agents); + }); + + it("should create thread", async function () { + const thread = await agents.createThread() + assert.isNotNull(thread); + assert.isNotNull(thread.id); + agents.deleteThread(thread.id); + }); + + it("should retrieve thread", async function () { + const thread = await agents.createThread() + const _thread = await agents.getThread(thread.id); + agents.deleteThread(thread.id); + assert.isNotEmpty(_thread); + assert.equal(_thread.id, thread.id) + }); + + it("should update thread", async function () { + // TODO + }); + + it("should delete thread", async function () { + const thread = await agents.createThread() + const deleted = await agents.deleteThread(thread.id); + assert.isNotNull(deleted); + }); + +}); From a1ffef2eb02de975341bba41f82ce1614b3e5033 Mon Sep 17 00:00:00 2001 From: Grace Brigham Date: Mon, 11 Nov 2024 09:59:27 -0800 Subject: [PATCH 3/7] Sample and update test --- sdk/ai/ai-projects/review/ai-projects.api.md | 3 +- .../ai-projects/samples-dev/agents/threads.ts | 30 +++++++++++++++++++ .../test/public/agents/threads.spec.ts | 7 ++++- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 sdk/ai/ai-projects/samples-dev/agents/threads.ts diff --git a/sdk/ai/ai-projects/review/ai-projects.api.md b/sdk/ai/ai-projects/review/ai-projects.api.md index dfc4cfe8dc25..2d3d566f16b1 100644 --- a/sdk/ai/ai-projects/review/ai-projects.api.md +++ b/sdk/ai/ai-projects/review/ai-projects.api.md @@ -129,8 +129,7 @@ export interface AgentsOperations { updateMessage: (threadId: string, messageId: string, options: UpdateMessageParameters) => Promise; // Warning: (ae-forgotten-export) The symbol "UpdateRunParameters" needs to be exported by the entry point index.d.ts updateRun: (threadId: string, runId: string, options: UpdateRunParameters) => Promise; - // Warning: (ae-forgotten-export) The symbol "UpdateThreadParameters" needs to be exported by the entry point index.d.ts - updateThread: (threadId: string, options: UpdateThreadParameters) => Promise; + updateThread: (threadId: string, options?: UpdateAgentThreadOptions) => Promise; // Warning: (ae-forgotten-export) The symbol "UploadFileParameters" needs to be exported by the entry point index.d.ts uploadFile: (options: UploadFileParameters) => Promise; } diff --git a/sdk/ai/ai-projects/samples-dev/agents/threads.ts b/sdk/ai/ai-projects/samples-dev/agents/threads.ts new file mode 100644 index 000000000000..759b58334980 --- /dev/null +++ b/sdk/ai/ai-projects/samples-dev/agents/threads.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import {AIProjectsClient} from "@azure/ai-projects" +import { DefaultAzureCredential } from "@azure/identity"; + +import * as dotenv from "dotenv"; +dotenv.config(); + +const connectionString = process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ">;;;"; + +export async function main(): Promise { + const client = AIProjectsClient.fromConnectionString(connectionString || "", new DefaultAzureCredential()); + + const thread = await client.agents.createThread(); + + console.log(`Created thread, thread ID : ${thread.id}`); + + const _thread = await client.agents.getThread(thread.id); + + console.log(`Retrieved thread, thread ID : ${_thread.id}`); + + client.agents.deleteThread(thread.id); + + console.log(`Deleted thread`); +} + +main().catch((err) => { + console.error("The sample encountered an error:", err); +}); diff --git a/sdk/ai/ai-projects/test/public/agents/threads.spec.ts b/sdk/ai/ai-projects/test/public/agents/threads.spec.ts index aea2af5e5696..5a799d39a013 100644 --- a/sdk/ai/ai-projects/test/public/agents/threads.spec.ts +++ b/sdk/ai/ai-projects/test/public/agents/threads.spec.ts @@ -42,7 +42,12 @@ describe("Agents - threads", () => { }); it("should update thread", async function () { - // TODO + const thread = await agents.createThread() + await agents.updateThread(thread.id, { metadata: {"key": "value"} }); + const _thread = await agents.getThread(thread.id); + assert.equal(_thread.id, thread.id); + assert.isNotEmpty(_thread.metadata); + assert.equal(_thread.metadata?.key, "value"); }); it("should delete thread", async function () { From d095562c87122c3fa3771e07de86c45756caee07 Mon Sep 17 00:00:00 2001 From: Grace Brigham Date: Mon, 11 Nov 2024 10:19:46 -0800 Subject: [PATCH 4/7] add requestParameters to threads methods --- sdk/ai/ai-projects/review/ai-projects.api.md | 10 ++++---- sdk/ai/ai-projects/src/agents/index.ts | 24 +++++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/sdk/ai/ai-projects/review/ai-projects.api.md b/sdk/ai/ai-projects/review/ai-projects.api.md index 2d3d566f16b1..91b8436a1503 100644 --- a/sdk/ai/ai-projects/review/ai-projects.api.md +++ b/sdk/ai/ai-projects/review/ai-projects.api.md @@ -96,15 +96,14 @@ export interface AgentsOperations { // Warning: (ae-forgotten-export) The symbol "CreateRunParameters" needs to be exported by the entry point index.d.ts createRun: (threadId: string, options: CreateRunParameters) => Promise; createRunStreaming: (threadId: string, assistantId: string, options?: Omit, requestParams?: RequestParameters) => AsyncIterable; - createThread: (options?: AgentThreadCreationOptions) => Promise; + createThread: (options?: AgentThreadCreationOptions, requestParams?: RequestParameters) => Promise; // Warning: (ae-forgotten-export) The symbol "CreateThreadAndRunParameters" needs to be exported by the entry point index.d.ts createThreadAndRun: (options: CreateThreadAndRunParameters) => Promise; createThreadAndRunStreaming: (assistantId: string, options?: Omit, requestParams?: RequestParameters) => AsyncIterable; deleteAgent: (assistantId: string) => Promise; // Warning: (ae-forgotten-export) The symbol "DeleteFileParameters" needs to be exported by the entry point index.d.ts deleteFile: (fileId: string, options?: DeleteFileParameters) => Promise; - // Warning: (ae-forgotten-export) The symbol "DeleteThreadParameters" needs to be exported by the entry point index.d.ts - deleteThread: (threadId: string, options?: DeleteThreadParameters) => Promise; + deleteThread: (threadId: string, requestParams?: RequestParameters) => Promise; getAgent: (assistantId: string) => Promise; // Warning: (ae-forgotten-export) The symbol "GetFileParameters" needs to be exported by the entry point index.d.ts getFile: (fileId: string, options?: GetFileParameters) => Promise; @@ -112,8 +111,7 @@ export interface AgentsOperations { getFileContent: (fileId: string, options?: GetFileContentParameters) => Promise; // Warning: (ae-forgotten-export) The symbol "GetRunParameters" needs to be exported by the entry point index.d.ts getRun: (threadId: string, runId: string, options?: GetRunParameters) => Promise; - // Warning: (ae-forgotten-export) The symbol "GetThreadParameters" needs to be exported by the entry point index.d.ts - getThread: (threadId: string, options?: GetThreadParameters) => Promise; + getThread: (threadId: string, requestParams?: RequestParameters) => Promise; // Warning: (ae-forgotten-export) The symbol "ListAgentsQueryParamProperties" needs to be exported by the entry point index.d.ts listAgents: (options?: ListAgentsQueryParamProperties) => Promise; // Warning: (ae-forgotten-export) The symbol "ListFilesParameters" needs to be exported by the entry point index.d.ts @@ -129,7 +127,7 @@ export interface AgentsOperations { updateMessage: (threadId: string, messageId: string, options: UpdateMessageParameters) => Promise; // Warning: (ae-forgotten-export) The symbol "UpdateRunParameters" needs to be exported by the entry point index.d.ts updateRun: (threadId: string, runId: string, options: UpdateRunParameters) => Promise; - updateThread: (threadId: string, options?: UpdateAgentThreadOptions) => Promise; + updateThread: (threadId: string, options?: UpdateAgentThreadOptions, requestParams?: RequestParameters) => Promise; // Warning: (ae-forgotten-export) The symbol "UploadFileParameters" needs to be exported by the entry point index.d.ts uploadFile: (options: UploadFileParameters) => Promise; } diff --git a/sdk/ai/ai-projects/src/agents/index.ts b/sdk/ai/ai-projects/src/agents/index.ts index fa7a50b7b5c7..4be99a132a57 100644 --- a/sdk/ai/ai-projects/src/agents/index.ts +++ b/sdk/ai/ai-projects/src/agents/index.ts @@ -4,7 +4,7 @@ import { Client, RequestParameters } from "@azure-rest/core-client"; import { AgentDeletionStatusOutput, AgentOutput, AgentThreadOutput, FileDeletionStatusOutput, FileListResponseOutput, OpenAIFileOutput, OpenAIPageableListOfAgentOutput, OpenAIPageableListOfThreadRunOutput, ThreadDeletionStatusOutput, ThreadMessageOutput, ThreadRunOutput } from "../generated/src/outputModels.js"; -import { CancelRunParameters, CreateRunParameters, CreateThreadAndRunParameters, DeleteFileParameters, DeleteThreadParameters, GetFileContentParameters, GetFileParameters, GetRunParameters, GetThreadParameters, ListAgentsQueryParamProperties, ListFilesParameters, ListMessagesParameters, ListRunsParameters, SubmitToolOutputsToRunParameters, UpdateMessageParameters, UpdateRunParameters, UploadFileParameters } from "../generated/src/parameters.js"; +import { CancelRunParameters, CreateRunParameters, CreateThreadAndRunParameters, DeleteFileParameters, GetFileContentParameters, GetFileParameters, GetRunParameters, ListAgentsQueryParamProperties, ListFilesParameters, ListMessagesParameters, ListRunsParameters, SubmitToolOutputsToRunParameters, UpdateMessageParameters, UpdateRunParameters, UploadFileParameters } from "../generated/src/parameters.js"; import { createAgent, deleteAgent, getAgent, listAgents, updateAgent } from "./assistants.js"; import { deleteFile, getFile, getFileContent, listFiles, uploadFile } from "./files.js"; import { createThread, deleteThread, getThread, updateThread } from "./threads.js"; @@ -47,21 +47,23 @@ export interface AgentsOperations { /** Creates a new thread. Threads contain messages and can be run by agents. */ createThread: ( options?: AgentThreadCreationOptions, + requestParams?: RequestParameters ) => Promise; /** Gets information about an existing thread. */ getThread: ( threadId: string, - options?: GetThreadParameters, + requestParams?: RequestParameters ) => Promise; /** Modifies an existing thread. */ updateThread: ( threadId: string, options?: UpdateAgentThreadOptions, + requestParams?: RequestParameters ) => Promise; /** Deletes an existing thread. */ deleteThread: ( threadId: string, - options?: DeleteThreadParameters, + requestParams?: RequestParameters ) => Promise; /** Creates and starts a new run of the specified thread using the specified agent. */ @@ -169,14 +171,14 @@ function getAgents(context: Client): AgentsOperations { assistantId: string ) => deleteAgent(context, assistantId), - createThread: (options?: AgentThreadCreationOptions) => - createThread(context, {body: options as Record}), - getThread: (threadId: string) => - getThread(context, threadId), - updateThread: (threadId: string, options?: UpdateAgentThreadOptions) => - updateThread(context, threadId, {body: options as Record}), - deleteThread: (threadId: string) => - deleteThread(context, threadId), + createThread: (options?: AgentThreadCreationOptions, requestParams?: RequestParameters) => + createThread(context, {...requestParams, body: {...options}}), + getThread: (threadId: string, requestParams?: RequestParameters) => + getThread(context, threadId, requestParams), + updateThread: (threadId: string, options?: UpdateAgentThreadOptions, requestParams?: RequestParameters) => + updateThread(context, threadId, {...requestParams, body: {...options}}), + deleteThread: (threadId: string, requestParams?: RequestParameters) => + deleteThread(context, threadId, requestParams), createRun: (threadId: string, options: CreateRunParameters) => createRun(context, threadId, options), From bbe66bbf79f21c5082652bf698458661e691d45d Mon Sep 17 00:00:00 2001 From: Grace Brigham Date: Mon, 11 Nov 2024 10:23:23 -0800 Subject: [PATCH 5/7] remove extra spaces --- sdk/ai/ai-projects/src/agents/threads.ts | 12 ++++++------ .../ai-projects/test/public/agents/threads.spec.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sdk/ai/ai-projects/src/agents/threads.ts b/sdk/ai/ai-projects/src/agents/threads.ts index 1a046b0989ca..5a34addb5e6f 100644 --- a/sdk/ai/ai-projects/src/agents/threads.ts +++ b/sdk/ai/ai-projects/src/agents/threads.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. - + import { Client, createRestError } from "@azure-rest/core-client"; import { CreateThreadParameters, DeleteThreadParameters, GetThreadParameters, UpdateThreadParameters } from "../generated/src/parameters.js"; import { AgentThreadOutput, ThreadDeletionStatusOutput } from "../generated/src/outputModels.js"; - + const expectedStatuses = ["200"]; - + /** Creates a new thread. Threads contain messages and can be run by agents. */ export async function createThread( context: Client, @@ -18,7 +18,7 @@ export async function createThread( } return result.body; } - + /** Gets information about an existing thread. */ export async function getThread( context: Client, @@ -33,7 +33,7 @@ export async function getThread( } return result.body; } - + /** Modifies an existing thread. */ export async function updateThread( context: Client, @@ -48,7 +48,7 @@ export async function updateThread( } return result.body; } - + /** Deletes an existing thread. */ export async function deleteThread( context: Client, diff --git a/sdk/ai/ai-projects/test/public/agents/threads.spec.ts b/sdk/ai/ai-projects/test/public/agents/threads.spec.ts index 5a799d39a013..ce529e989c08 100644 --- a/sdk/ai/ai-projects/test/public/agents/threads.spec.ts +++ b/sdk/ai/ai-projects/test/public/agents/threads.spec.ts @@ -10,29 +10,29 @@ describe("Agents - threads", () => { let recorder: Recorder; let projectsClient : AIProjectsClient; let agents: AgentsOperations - + beforeEach(async function (context: VitestTestContext) { recorder = await createRecorder(context); projectsClient = createProjectsClient(recorder); agents = projectsClient.agents }); - + afterEach(async function () { await recorder.stop(); }); - + it("client and agents operations are accessible", async function () { assert.isNotNull(projectsClient); assert.isNotNull(agents); }); - + it("should create thread", async function () { const thread = await agents.createThread() assert.isNotNull(thread); assert.isNotNull(thread.id); agents.deleteThread(thread.id); }); - + it("should retrieve thread", async function () { const thread = await agents.createThread() const _thread = await agents.getThread(thread.id); @@ -49,7 +49,7 @@ describe("Agents - threads", () => { assert.isNotEmpty(_thread.metadata); assert.equal(_thread.metadata?.key, "value"); }); - + it("should delete thread", async function () { const thread = await agents.createThread() const deleted = await agents.deleteThread(thread.id); From ed8325ddfc6cb9e60a43d7cbf69d49d4c8008ca7 Mon Sep 17 00:00:00 2001 From: Grace Brigham Date: Mon, 11 Nov 2024 10:24:29 -0800 Subject: [PATCH 6/7] remove extra spaces from sample --- sdk/ai/ai-projects/samples-dev/agents/threads.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/ai/ai-projects/samples-dev/agents/threads.ts b/sdk/ai/ai-projects/samples-dev/agents/threads.ts index 759b58334980..93108cfce501 100644 --- a/sdk/ai/ai-projects/samples-dev/agents/threads.ts +++ b/sdk/ai/ai-projects/samples-dev/agents/threads.ts @@ -11,7 +11,7 @@ const connectionString = process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || " export async function main(): Promise { const client = AIProjectsClient.fromConnectionString(connectionString || "", new DefaultAzureCredential()); - + const thread = await client.agents.createThread(); console.log(`Created thread, thread ID : ${thread.id}`); @@ -19,7 +19,7 @@ export async function main(): Promise { const _thread = await client.agents.getThread(thread.id); console.log(`Retrieved thread, thread ID : ${_thread.id}`); - + client.agents.deleteThread(thread.id); console.log(`Deleted thread`); From 27803c4269476b31ce982940df47e9ad7ff379ff Mon Sep 17 00:00:00 2001 From: Grace Brigham Date: Mon, 11 Nov 2024 11:15:03 -0800 Subject: [PATCH 7/7] delete thread after test --- sdk/ai/ai-projects/test/public/agents/threads.spec.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/ai/ai-projects/test/public/agents/threads.spec.ts b/sdk/ai/ai-projects/test/public/agents/threads.spec.ts index ce529e989c08..dac361c3964e 100644 --- a/sdk/ai/ai-projects/test/public/agents/threads.spec.ts +++ b/sdk/ai/ai-projects/test/public/agents/threads.spec.ts @@ -30,15 +30,15 @@ describe("Agents - threads", () => { const thread = await agents.createThread() assert.isNotNull(thread); assert.isNotNull(thread.id); - agents.deleteThread(thread.id); + await agents.deleteThread(thread.id); }); it("should retrieve thread", async function () { const thread = await agents.createThread() const _thread = await agents.getThread(thread.id); - agents.deleteThread(thread.id); assert.isNotEmpty(_thread); assert.equal(_thread.id, thread.id) + await agents.deleteThread(thread.id); }); it("should update thread", async function () { @@ -48,6 +48,7 @@ describe("Agents - threads", () => { assert.equal(_thread.id, thread.id); assert.isNotEmpty(_thread.metadata); assert.equal(_thread.metadata?.key, "value"); + await agents.deleteThread(thread.id); }); it("should delete thread", async function () {