@azure/ai-projects 1.0.0-alpha.20250205.1 → 1.0.0-alpha.20250213.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ Use the AI Projects client library (in preview) to:
|
|
|
69
69
|
### Install the package
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
|
-
npm install @azure/ai-projects
|
|
72
|
+
npm install @azure/ai-projects @azure/identity
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
## Key concepts
|
|
@@ -440,7 +440,7 @@ const agent = await client.agents.createAgent("gpt-4-1106-preview", {
|
|
|
440
440
|
});
|
|
441
441
|
console.log(`Created agent, agent ID: ${agent.id}`);
|
|
442
442
|
|
|
443
|
-
const thread = client.agents.createThread();
|
|
443
|
+
const thread = await client.agents.createThread();
|
|
444
444
|
console.log(`Created thread, thread ID: ${thread.id}`);
|
|
445
445
|
|
|
446
446
|
const message = await client.agents.createMessage(thread.id, {
|
|
@@ -479,7 +479,16 @@ To have the SDK poll on your behalf, use the `createThreadAndRun` method.
|
|
|
479
479
|
Here is an example:
|
|
480
480
|
|
|
481
481
|
```javascript
|
|
482
|
-
const run = await client.agents.createThreadAndRun(
|
|
482
|
+
const run = await client.agents.createThreadAndRun(agent.id, {
|
|
483
|
+
thread: {
|
|
484
|
+
messages: [
|
|
485
|
+
{
|
|
486
|
+
role: "user",
|
|
487
|
+
content: "hello, world!"
|
|
488
|
+
}
|
|
489
|
+
]
|
|
490
|
+
}
|
|
491
|
+
});
|
|
483
492
|
```
|
|
484
493
|
|
|
485
494
|
With streaming, polling also need not be considered.
|
|
@@ -530,6 +539,12 @@ To retrieve messages from agents, use the following example:
|
|
|
530
539
|
|
|
531
540
|
```javascript
|
|
532
541
|
const messages = await client.agents.listMessages(thread.id);
|
|
542
|
+
while (messages.hasMore) {
|
|
543
|
+
const nextMessages = await client.agents.listMessages(currentRun.threadId, { after: messages.lastId });
|
|
544
|
+
messages.data = messages.data.concat(nextMessages.data);
|
|
545
|
+
messages.hasMore = nextMessages.hasMore;
|
|
546
|
+
messages.lastId = nextMessages.lastId;
|
|
547
|
+
}
|
|
533
548
|
|
|
534
549
|
// The messages are following in the reverse order,
|
|
535
550
|
// we will iterate them and output only text contents.
|