Skip to content

Commit 9652f79

Browse files
authored
Use ConversationId instead of ChatThreadId (#6367)
1 parent fd92ff7 commit 9652f79

File tree

1 file changed

+10
-10
lines changed
  • src/Libraries/Microsoft.Extensions.AI.Abstractions

1 file changed

+10
-10
lines changed

src/Libraries/Microsoft.Extensions.AI.Abstractions/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ while (true)
396396
}
397397
```
398398

399-
For stateful services, you may know ahead of time an identifier used for the relevant conversation. That identifier can be put into `ChatOptions.ChatThreadId`.
399+
For stateful services, you may know ahead of time an identifier used for the relevant conversation. That identifier can be put into `ChatOptions.ConversationId`.
400400
Usage then follows the same pattern, except there's no need to maintain a history manually.
401401
```csharp
402-
ChatOptions options = new() { ChatThreadId = "my-conversation-id" };
402+
ChatOptions options = new() { ConversationId = "my-conversation-id" };
403403
while (true)
404404
{
405405
Console.Write("Q: ");
@@ -409,8 +409,8 @@ while (true)
409409
}
410410
```
411411

412-
Some services may support automatically creating a thread ID for a request that doesn't have one. In such cases, you can transfer the `ChatResponse.ChatThreadId` over
413-
to the `ChatOptions.ChatThreadId` for subsequent requests, e.g.
412+
Some services may support automatically creating a thread ID for a request that doesn't have one. In such cases, you can transfer the `ChatResponse.ConversationId` over
413+
to the `ChatOptions.ConversationId` for subsequent requests, e.g.
414414
```csharp
415415
ChatOptions options = new();
416416
while (true)
@@ -421,13 +421,13 @@ while (true)
421421
ChatResponse response = await client.GetResponseAsync(message, options);
422422
Console.WriteLine(response);
423423

424-
options.ChatThreadId = response.ChatThreadId;
424+
options.ConversationId = response.ConversationId;
425425
}
426426
```
427427

428-
If you don't know ahead of time whether the service is stateless or stateful, both can be accomodated by checking the response `ChatThreadId`
429-
and acting based on its value. Here, if the response `ChatThreadId` is set, then that value is propagated to the options and the history
430-
cleared so as to not resend the same history again. If, however, the `ChatThreadId` is not set, then the response message is added to the
428+
If you don't know ahead of time whether the service is stateless or stateful, both can be accomodated by checking the response `ConversationId`
429+
and acting based on its value. Here, if the response `ConversationId` is set, then that value is propagated to the options and the history
430+
cleared so as to not resend the same history again. If, however, the `ConversationId` is not set, then the response message is added to the
431431
history so that it's sent back to the service on the next turn.
432432
```csharp
433433
List<ChatMessage> history = [];
@@ -440,8 +440,8 @@ while (true)
440440
ChatResponse response = await client.GetResponseAsync(history);
441441
Console.WriteLine(response);
442442

443-
options.ChatThreadId = response.ChatThreadId;
444-
if (response.ChatThreadId is not null)
443+
options.ConversationId = response.ConversationId;
444+
if (response.ConversationId is not null)
445445
{
446446
history.Clear();
447447
}

0 commit comments

Comments
 (0)