by tuchsen · 3y ago · 0 comments
I'm a little unclear on one thing though. How are you handling the parsing of parameter names when passing prompts to the model? In your example you ask the LLM to "Find the sum of 1 and 8" and then that ends up being bound to x and y somehow. I know it doesn't matter in the case of adding two numbers because they're commutative, but that's hardly ever the case. I must be missing some magic somewhere.
Regarding the parameters, I prompt GPT to to return the function name as well as an object for the params in JSON. The acceptable params are passed in the prompt just by stringifying the 'parameters' object passed in the addFunction() function.
This means it works best when the function parameters are extremely descriptive. I've also found it is important to check all params to ensure they're the correct type, not null, etc, directly in the function.
I've also been meaning to implement some retry logic so that if a passed parameter is wrong, the function can throw an error and this error will be passed back to GPT to allow it to retry.