Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/Libraries/Microsoft.Extensions.AI.Abstractions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@ while (true)
}
```

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

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
to the `ChatOptions.ChatThreadId` for subsequent requests, e.g.
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
to the `ChatOptions.ConversationId` for subsequent requests, e.g.
```csharp
ChatOptions options = new();
while (true)
Expand All @@ -421,13 +421,13 @@ while (true)
ChatResponse response = await client.GetResponseAsync(message, options);
Console.WriteLine(response);

options.ChatThreadId = response.ChatThreadId;
options.ConversationId = response.ConversationId;
}
```

If you don't know ahead of time whether the service is stateless or stateful, both can be accomodated by checking the response `ChatThreadId`
and acting based on its value. Here, if the response `ChatThreadId` is set, then that value is propagated to the options and the history
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
If you don't know ahead of time whether the service is stateless or stateful, both can be accomodated by checking the response `ConversationId`
and acting based on its value. Here, if the response `ConversationId` is set, then that value is propagated to the options and the history
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
history so that it's sent back to the service on the next turn.
```csharp
List<ChatMessage> history = [];
Expand All @@ -440,8 +440,8 @@ while (true)
ChatResponse response = await client.GetResponseAsync(history);
Console.WriteLine(response);

options.ChatThreadId = response.ChatThreadId;
if (response.ChatThreadId is not null)
options.ConversationId = response.ConversationId;
if (response.ConversationId is not null)
{
history.Clear();
}
Expand Down
Loading