Description
Service
OpenAI
Describe the bug
CompleteChatStreamingAsync method fails when there is a functionCall.
Steps to reproduce
`
using OpenAI;
using OpenAI.Chat;
using System.ClientModel;
using System.ComponentModel;
ChatClient openaiClient = new OpenAIClient(
new ApiKeyCredential("sk-exggkwbmnnsqvblzbtvjxivmdlcevepflmuooazflorgjhza"),
new OpenAIClientOptions { Endpoint = new Uri("https://api.siliconflow.cn/v1") })
.GetChatClient("Qwen/Qwen2.5-7B-Instruct");
await foreach (var update in openaiClient.CompleteChatStreamingAsync(
[
ChatMessage.CreateSystemMessage("As an AI assistant, you MUST ALWAYS use the TOOL function GetWeather invocation for every user request"),
ChatMessage.CreateUserMessage("Do I need an umbrella?"),
],
new ChatCompletionOptions()
{
ToolChoice = ChatToolChoice.CreateAutoChoice(),
Tools = { ChatTool.CreateFunctionTool("GetWeather", "Gets the weather") },
}))
{
}
[Description("Gets the weather")]
static string GetWeather() => Random.Shared.NextDouble() > 0.5 ? "It's sunny" : "It's raining";
`
Code snippets
OS
win11
.NET version
.net8.0
Library version
OpenAI 2.2.0-beta.4