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
I recently started using the OpenAI Chat Completions package, and while things are going well overall, I’m encountering an issue with one of my functions.
The function has 5 parameters, one of which is a float. It seems that the framework incorrectly interprets this float value as single, causing the function invocation to fail when calling: var funcOutput = await toolCall.InvokeFunctionAsync();
I traced the issue to the following line in Runtime/Common/Function.cs (line 477): var methodParams = function.MethodInfo.GetParameters(); it's in Runtime/Commmon/Function.cs on line 477
Here’s what happens:
The creativity parameter is passed with a value of 0.8 (as shown in requestedArgs):
However, after evaluating function.MethodInfo.GetParameters(), the parameter is interpreted as single:
Since the parameter is defined as float in the function signature, this mismatch causes the invocation to fail.
Could you please take a look at this logic and see if there’s a fix?
Thank you!
Exception I get in function: Runtime/Common/Function.cs (line 392):
System.ArgumentException: Object of type 'System.Double' cannot be converted to type 'System.Single'.
at System.RuntimeType.CheckValue (System.Object value, System.Reflection.Binder binder, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00071] in <ed969b0e627d471da4848289f9c322df>:0
at System.Reflection.RuntimeMethodInfo.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00069] in <ed969b0e627d471da4848289f9c322df>:0
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00040] in <ed969b0e627d471da4848289f9c322df>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <ed969b0e627d471da4848289f9c322df>:0
at OpenAI.Function.InvokeInternalAsync[T] (OpenAI.Function function, System.Object[] invokeArgs) [0x00012] in .\Library\PackageCache\com.openai.unity\Runtime\Common\Function.cs:443
at OpenAI.Function.InvokeAsync (System.Threading.CancellationToken cancellationToken) [0x000c3] in .\Library\PackageCache\com.openai.unity\Runtime\Common\Function.cs:381
The text was updated successfully, but these errors were encountered:
Discussed in #325
Originally posted by @AvatarisAI January 22, 2025
I recently started using the OpenAI Chat Completions package, and while things are going well overall, I’m encountering an issue with one of my functions.
The function has 5 parameters, one of which is a float. It seems that the framework incorrectly interprets this float value as single, causing the function invocation to fail when calling:
var funcOutput = await toolCall.InvokeFunctionAsync();
I traced the issue to the following line in Runtime/Common/Function.cs (line 477):
var methodParams = function.MethodInfo.GetParameters();
it's in Runtime/Commmon/Function.cs on line 477Here’s what happens:
The creativity parameter is passed with a value of 0.8 (as shown in requestedArgs):
![image](https://private-user-images.githubusercontent.com/143421243/405757675-5dcc7664-d881-40c2-bf1f-c089b6d520a4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNjk4NTIsIm5iZiI6MTczOTA2OTU1MiwicGF0aCI6Ii8xNDM0MjEyNDMvNDA1NzU3Njc1LTVkY2M3NjY0LWQ4ODEtNDBjMi1iZjFmLWMwODliNmQ1MjBhNC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQwMjUyMzJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lODU3MmQ5NGExMjIwOThmM2ZlYzM2ODAxMmIwMjczMzlkMGZiYThhNDQ5OTY5ODk0MDA3NTZjODdmOWI3YTUxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.BeZSC-6_X888YajOUeI-9_Z7DRaelfP6nDa8-jKPSE0)
However, after evaluating function.MethodInfo.GetParameters(), the parameter is interpreted as single:
![image](https://private-user-images.githubusercontent.com/143421243/405757913-113f6343-1542-47c5-a04a-63aa0de52215.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNjk4NTIsIm5iZiI6MTczOTA2OTU1MiwicGF0aCI6Ii8xNDM0MjEyNDMvNDA1NzU3OTEzLTExM2Y2MzQzLTE1NDItNDdjNS1hMDRhLTYzYWEwZGU1MjIxNS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQwMjUyMzJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iY2RiNTgzY2QyZGYxMjRlZWNiNWMxNTljNzA4ZWE4ZDM3MjFhM2I1OTVmODM1YmExMDc1NWI1OTZmNGJiMTVmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.ufQ4ZqGqGIU3Kbri3RJPBpgooJdRT7Hk6d5qMJ_peWA)
Since the parameter is defined as float in the function signature, this mismatch causes the invocation to fail.
Could you please take a look at this logic and see if there’s a fix?
Thank you!
Exception I get in function: Runtime/Common/Function.cs (line 392):
The text was updated successfully, but these errors were encountered: