Chat Client Streaming
This example assumes using Writer; is in scope and apiKey contains your Writer API key.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 | using var client = new WriterClient(apiKey);
Meai.IChatClient chatClient = client;
// Stream chat responses using the MEAI IChatClient interface.
var enumerable = chatClient.GetStreamingResponseAsync(
messages: [new Meai.ChatMessage(Meai.ChatRole.User, "Generate 5 random words.")],
new Meai.ChatOptions
{
ModelId = "palmyra-x-004",
});
var deltas = new List<string>();
await foreach (var update in enumerable)
{
Console.Write(update.Text);
deltas.Add(update.Text ?? string.Empty);
}
|