gristlabs_grist-core/app
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
..
client (core) Fix scrolling and column title bugs 2023-06-15 14:51:10 -04:00
common (core) Fix recording of signups, and record as telemetry too. 2023-06-15 00:15:18 -04:00
gen-server (core) Improve the look and behavior of /welcome/teams page (also shown for /welcome/start) 2023-06-13 20:40:59 -04:00
plugin Use relative imports only in plugin folder (#328) 2022-10-26 10:41:38 -04:00
server (core) Improve parsing formula from completion 2023-06-16 13:38:20 +02:00
tsconfig.json (core) move home server into core 2020-07-21 20:39:10 -04:00