Describe the bug
When the Name of FunctionDescriptionAttribute is manually specified, FunctionCallingHelper.CallFunction is not working properly
Your code piece
public class Tools
{
[FunctionDescription("A awesome method", Name = "awesome_method")]
pubilc string AwesomeMethod() => "I will crash your program";
}
var tools = new Tools();
var res = await openAiService.ChatCompletion.CreateCompletion(new ChatCompletionCreateRequest()
{
Messages = [ChatMessage.FromSystem("free to use any tools"), ChatMessage.FromUser("Call some awesome function and tell me the result")],
Tools = FunctionCallingHelper.GetToolDefinitions(tools);
}, "gpt-3.5-turbo-1106");
if (resMsg.ToolCalls != null)
{
foreach (var toolCall in resMsg.ToolCalls)
{
var toolResponse= FunctionCallingHelper.CallFunction<string>(toolCall.FunctionCall!, tools);
/* It will throw an exception
* OpenAI.Utilities.FunctionCalling.InvalidFunctionCallException: Method 'awesome_method' on type 'Test.Tools' not found
*/
}
}
Result
It will throw an exception __OpenAI.Utilities.FunctionCalling.InvalidFunctionCallException: Method 'awesome_method' on type 'Test.Tools' not found__ When the code running to CallFunction;
Expected behavior
Call AwesomeMethod and get the result
Screenshots
I think I explained it very clearly
Desktop (please complete the following information):
Describe the bug When the Name of FunctionDescriptionAttribute is manually specified, FunctionCallingHelper.CallFunction is not working properly
Your code piece
Result It will throw an exception __OpenAI.Utilities.FunctionCalling.InvalidFunctionCallException: Method 'awesome_method' on type 'Test.Tools' not found__ When the code running to
CallFunction
;Expected behavior Call
AwesomeMethod
and get the resultScreenshots I think I explained it very clearly
Desktop (please complete the following information):