You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the CompleteChatStreamingAsync method on the ChatClient. I have tools configured with the ToolChoice set to Auto. However, whenever I send a user message that should trigger the tool, the TooCallUpdates against the StreamingChatCompletionUpdate is always empty.
To test this I have a simple get_today tool that when executed the function will return the formatted datetime. I have provide the code below.
Not sure if this is something worng with
Steps to reproduce
Send a User Message "What is today's date?"
Expected:
Will raise the ToolCallUpdate that will then allow me to call the required method.
Actual:
No ToolCallUpdate are raised so the chat returns the text '{get_today}'
Code snippets
// Main Codevarendpoint="":var apiKey ="";vardeployment="";varcreds=newAzureKeyCredential(apiKey);varclient=newAzureOpenAIClient(endpoint,creds);varchatClient=client.GetChatClient(deployment);vartools=GetTools();// Returns Dictionary<string, ITool>varoptions=newChatCompletionOptions();if(tools.Any()){options.ToolChoice=ChatToolChoice.CreateAutoChoice();foreach(vartoolDataintools){vartool=toolData.Value;options.Tools.Add(ChatTool.CreateFunctionTool(tool.Name,tool.Description,tool.Parameters));}}varmessages=newList<ChatMessage>{newSystemChatMessage("You are a helpful assistant. Always lookup the current date and/or time using the tool 'get_today' when required."),newUserChatMessage("What is today's date?")};varcompletionUpdates=chatClient.CompleteChatStreamingAsync(messages,options);awaitforeach(varupdateincompletionUpdates){Console.WriteLine("Finish Reason: {0}",update.FinishReason);if(update.FinishReason==ChatFinishReason.FunctionCall){// Would expect here to be hit (1/2)}foreach(vartoolCallinupdate.ToolCallUpdates){// Would expect here to be hit (2/2)}foreach(varcontentPartinupdate.ContentUpdate){Console.WriteLine(contentPart.Text);}}// IToolpublicinterfaceITool{publicstringName{get;}publicstringDescription{get;}publicBinaryDataParameters{get;}Task<string>RunAsync(stringargs);}// GetTodayToolpublicclassGetTodayTool:ITool{publicstringName=>"get_today";publicstringDescription=>"Know the date and time of today. Will return in format dd/MM/yyyy HH:mm:ss";publicBinaryDataParameters=>BinaryData.FromString("{}");publicTask<string>RunAsync(stringargs){returnTask.FromResult(DateTime.Now.ToString("dd//MM/yyyy HH:mm:ss"));}}
OS
winOS
.NET version
8
Library version
2.1.0
The text was updated successfully, but these errors were encountered:
RichOwenMercury
changed the title
Calling Tools from Streaming Chat Completion not triggering
Tools from Streaming Chat Completion not triggering
Dec 23, 2024
Service
Azure OpenAI
Describe the bug
When using the CompleteChatStreamingAsync method on the ChatClient. I have tools configured with the ToolChoice set to Auto. However, whenever I send a user message that should trigger the tool, the TooCallUpdates against the StreamingChatCompletionUpdate is always empty.
To test this I have a simple get_today tool that when executed the function will return the formatted datetime. I have provide the code below.
Not sure if this is something worng with
Steps to reproduce
Expected:
Will raise the ToolCallUpdate that will then allow me to call the required method.
Actual:
No ToolCallUpdate are raised so the chat returns the text '{get_today}'
Code snippets
OS
winOS
.NET version
8
Library version
2.1.0
The text was updated successfully, but these errors were encountered: