Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,21 @@ public override async IAsyncEnumerable<AgentRunResponseUpdate> RunStreamingAsync
Transport = new HttpClientPipelineTransport(httpClient)
};

var openAiClient = new ChatClient(model: "myModel!", credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient();
await foreach (var update in openAiClient.GetStreamingResponseAsync(messages, cancellationToken: cancellationToken))
IChatClient openAiClient = new ChatClient(model: nameof(AgentWebChat), credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient();

ChatOptions chatOptions = new()
{
ConversationId = threadId,
RawRepresentationFactory = _ => new ChatCompletionOptions()
{
Metadata =
{
{ "entity_id", agentName }
}
},
};

await foreach (var update in openAiClient.GetStreamingResponseAsync(messages, options: chatOptions, cancellationToken: cancellationToken))
{
yield return new AgentRunResponseUpdate(update);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ public override async IAsyncEnumerable<AgentRunResponseUpdate> RunStreamingAsync
Transport = new HttpClientPipelineTransport(httpClient)
};

var openAiClient = new ResponsesClient(model: agentName, credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient();
var openAiClient = new ResponsesClient(model: nameof(AgentWebChat), credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient();

var chatOptions = new ChatOptions()
{
ConversationId = threadId
ConversationId = threadId,
RawRepresentationFactory = _ => new ResponseCreationOptions()
{
Metadata =
{
{ "entity_id", agentName }
}
},
};

await foreach (var update in openAiClient.GetStreamingResponseAsync(messages, chatOptions, cancellationToken: cancellationToken))
Expand Down