Enhanced AI Functions: Introducing a new Flavor of AI Functions for Improved Results #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This commit introduces an enhanced approach for generating AI functions' results, referred to as
code-execution AI functions
in this PR. These functions prompt the GPT model to generate code for the desired function and then execute it with the specified arguments. To run the GPT-provided code, we utilize a customexec_with_return
function that returns the result, in contrast to the commonly usedexec
function, which does not provide a return value.The new approach achieves superior outcomes:
The only failure occurs with
Encrypt text
under GPT-3.5-turbo.Further Improvements
One significant advantage of
code-execution AI functions
is their ability to detect GPT failures. Consequently, we can employ two strategies to overcome these failures:code-less AI functions
Attempting Error Correction
If the generated code cannot be compiled, the error message can be fed back into the GPT model, prompting it to refine the code. Although error correction can attempt to improve
Encrypt text
in GPT-3.5-turbo, it cannot enhance it to the extent that it becomes executable.Fallback to
code-less AI functions
Fortunately, the original approach, termed
code-less AI functions
, can serve as a fallback whencode-execution AI functions
fail. For instance,code-less AI functions
can produce a result for theEncrypt text
test when using GPT-3.5-turbo. As a result, I have integratedcode-less AI functions
as a fallback for cases whencode-execution AI functions
are unsuccessful. This combined approach enables AI functions to pass all tests accurately:Conclusion
code-execution AI functions
deliver superior results for two reasons:Combining both
code-execution AI functions
andcode-less AI functions
yields the best results at this stage. It would be beneficial to incorporate additional tests in the future to further evaluate the capabilities and limitations of AI functions.