2 ms·
There was another post today about using Pydantic for function enabled completions: https://github.com/jxnl/openai_function_call https://github.com/jxnl/openai_
by kordlessagain 3y ago
There was another post today about using Pydantic for function enabled completions: https://github.com/jxnl/openai_function_call https://github.com/jxnl/openai_function_call
I whipped up an example doing something similar last Friday using a decorator, inspect, ast and __doc__ usage: https://gist.github.com/kordless/7d306b0646bf0b56c44ebca2b8e96678 https://gist.github.com/kordless/7d306b0646bf0b56c44ebca2b8e.... The example pulls top results from Algoia's HN search and then chains them into another prompt for GPT-X. The blog post is here: https://www.featurebase.com/blog/function-integration-in-openais-completions https://www.featurebase.com/blog/function-integration-in-ope...
Currently integrating this approach into PythonGPT[1], which will build a function on the fly, extract the method info, then call the code in exec(). I would label it "very dangerous"...
[1] https://github.com/FeatureBaseDB/PythonGPT https://github.com/FeatureBaseDB/PythonGPT
- minimaxir 3y ago> There was another post today about using Pydantic for function enabled completions That post let me know that pydantic's schema() function actually worked to produce a valid JSON schema, so I was able to optimize from there. (there may be a few optimizations still to be done: schema() also returns an unnecessary title field and I need to experiment if I need to remove it)