gristlabs_grist-core/test/formula-dataset
Alex Hall 52469c5a7e (core) Improve parsing formula from completion
Summary:
The previous code for extracting a Python formula from the LLM completion involved some shaky string manipulation which this improves on.
Overall the 'test results' from `runCompletion` went from 37/47 to 45/47 for `gpt-3.5-turbo-0613`.

The biggest problem that motivated these changes was that it assumed that code was always inside a markdown code block
(i.e. triple backticks) and so if there was no block there was no code. But the completion often consists of *only* code
with no accompanying explanation or markdown. By parsing the completion in Python instead of JS,
we can easily check if the entire completion is valid Python syntax and accept it if it is.

I also noticed one failure resulting from the completion containing the full function (instead of just the body)
and necessary imports before that function instead of inside. The new parsing moves import inside.

Test Plan: Added a Python unit test

Reviewers: paulfitz

Reviewed By: paulfitz

Subscribers: paulfitz

Differential Revision: https://phab.getgrist.com/D3922
2023-06-16 13:38:20 +02:00
..
data (core) Porting the AI evaluation script 2023-03-15 14:54:28 +01:00
.gitignore (core) Improve parsing formula from completion 2023-06-16 13:38:20 +02:00
runCompletion_impl.ts (core) Improve parsing formula from completion 2023-06-16 13:38:20 +02:00
runCompletion.js add support for conversational state to assistance endpoint (#506) 2023-05-08 14:15:22 -04:00