Skip to content

Commit fab1496

Browse files
ZachhKZachary King
andauthored
listThreads snippet update (Azure#33984)
### Packages impacted by this PR ### Issues associated with this PR ### Describe the problem that is addressed by this PR updating snippet to match sample change ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary) --------- Co-authored-by: Zachary King <[email protected]>
1 parent 7968d68 commit fab1496

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

sdk/ai/ai-projects/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,14 @@ const thread = await client.agents.createThread({ toolResources: fileSearchTool.
476476
To list all threads attached to a given agent, use the list_threads API:
477477

478478
```ts snippet:listThreads
479-
const threads = client.agents.listThreads();
479+
const threads = await client.agents.listThreads();
480+
console.log(`Threads for agent ${agent.id}:`);
481+
for await (const t of (await threads).data) {
482+
console.log(`Thread ID: ${t.id}`);
483+
console.log(`Created at: ${t.createdAt}`);
484+
console.log(`Metadata: ${t.metadata}`);
485+
console.log(`---- `);
486+
}
480487
```
481488

482489
#### Create Message

sdk/ai/ai-projects/test/snippets.spec.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,15 @@ import {
1717
MessageStreamEvent,
1818
RunStreamEvent,
1919
ThreadRunOutput,
20+
MessageContentOutput,
21+
isOutputOfType,
22+
MessageTextContentOutput,
23+
MessageImageFileContentOutput,
2024
} from "@azure/ai-projects";
2125
import { createProjectsClient } from "./public/utils/createClient.js";
2226
import { DefaultAzureCredential } from "@azure/identity";
2327
import { beforeEach, it, describe } from "vitest";
2428
import * as fs from "fs";
25-
import path from "node:path";
26-
import {
27-
MessageContentOutput,
28-
isOutputOfType,
29-
MessageTextContentOutput,
30-
MessageImageFileContentOutput,
31-
} from "../src/index.js";
3229
import { delay } from "@azure/core-util";
3330
import { trace } from "@opentelemetry/api";
3431
import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter";
@@ -358,7 +355,14 @@ describe("snippets", function () {
358355
});
359356

360357
it("listThreads", async function () {
361-
const threads = client.agents.listThreads();
358+
const threads = await client.agents.listThreads();
359+
console.log(`Threads for agent ${agent.id}:`);
360+
for await (const t of (await threads).data) {
361+
console.log(`Thread ID: ${t.id}`);
362+
console.log(`Created at: ${t.createdAt}`);
363+
console.log(`Metadata: ${t.metadata}`);
364+
console.log(`---- `);
365+
}
362366
});
363367

364368
it("createMessage", async function () {

0 commit comments

Comments
 (0)