-
-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new tool choices to the ChatCompletionCreateRequest and ChatMessa… #432
Conversation
…ge response messages. Mark the old function api as Obsolete. Added playground tests to test the new function calling and also get the streaming function calling example working (in a messy way).
Support has been added for passing as object to the function field in the tool.
Hi, I made some changes. I removed support for legacy functions as they can easily be converted to tools, which will make the SDK cleaner. I also added support for AsObject to the functionDefination in ToolDefinition, as some may need it. I have only one comment, please take a look. I think you may have forgotten to remove that class by mistake.If yes, please remove it. If no, could you please clarify what it is? |
Your changes looks good to me. What class are you referring to by 'may have forgotten to remove that class by mistake'? Do you mean the class ToolChoiceFunction? This is meant to be used with the ChatCompletionCreateRequest.ToolChoice field. request.ToolChoice = StaticValues.CompletionStatics.ToolChoice.Auto; or request.ToolChoice = StaticValues.CompletionStatics.ToolChoice.None; or a ToolChoiceFunction instance. request.ToolChoice = new ToolChoiceFunction() { Function = new FunctionTool() { Name = "get_current_weather" }}; That is why I setup the ToolChoice as a object. You can see I tested it by commenting out the code bits in this block of the RunChatFunctionCallTest method: ConsoleExtensions.WriteLine("Chat Function Call Test:", ConsoleColor.DarkCyan);
var completionResult = await sdk.ChatCompletion.CreateCompletion(new ChatCompletionCreateRequest
{
Messages = new List<ChatMessage>
{
ChatMessage.FromSystem("Don't make assumptions about what values to plug into functions. Ask for clarification if a user request is ambiguous."),
ChatMessage.FromUser("Give me a weather report for Chicago, USA, for the next 5 days.")
},
Tools = new List<ToolDefinition> { new() { Function = fn1 }, new() { Function = fn2 }, new() { Function = fn3 }, new() { Function = fn4 }, new() { Function = fn4 } },
// optionally, to force a specific function:
// ToolChoice = new ToolChoiceFunction() { Function = new FunctionTool() { Name = "get_current_weather" }},
// or auto tool choice:
// ToolChoice = StaticValues.CompletionStatics.ToolChoice.Auto,
MaxTokens = 50,
Model = Models.Gpt_3_5_Turbo
}); |
…es, updated playground regarding changes. Updated some documentation.
Oh, I see. That makes sense. I have made some changes to the usage. I don't like the given object as a default field because it may leave developers in the dark about which objects are acceptable. I will be merging these changes. Please leave a comment if you disagree with any of my changes so that we can further improve this pull request and merge again. (I removed default tool values, etc., because in the future, I think OpenAI will introduce different types, and using functions as defaults will lose its purpose and may create confusion for both new and existing developers.) |
Add new tool choices to the ChatCompletionCreateRequest and ChatMessage response messages.
Mark the old function api as Obsolete.
Added playground tests to test the new function calling and also get the streaming function calling example working (in a messy way).