Error with JSON parsing
Closed this issue · 1 comments
The subtitle translator is working pretty nicely, and the attention paid to backing off, and keeping numbers in sync is appreciated. Unfortunately, it threw an exception, which resulted in no file being generated. That's a bit unfortunate.
I can split the file up in pieces and run them separately, so I think that will be a workaround.
I wonder, though, if it would be possible to update the output file incrementally. That would help when recovering from errors such as this. I'm happy to help debug this, however javascript is not my strongest language.
cli/translator.mjs --stream --temperature 0 --to Spanish --file ../translate/files/subtitle.srt
...
node:internal/process/esm_loader:42
internalBinding('errors').triggerUncaughtException(
^
[Error_TranslationPrompt] Thu May 18 2023 17:50:19 GMT+0200 (Central European Summer Time) unknown error SyntaxError: Could not JSON parse stream message: Expected property name or '}' in JSON at position 151
(Use `node --trace-uncaught ...` to show where the exception was thrown)
I am aware of this issue, will take a closer look. It seems to happen only in stream mode.
For incremental saving, it is already implemented (the output files consist of a csv
file to keep track the progress, running the same command will pick it where it was left if it was interrupted by error or CTRL+C), however it will only update after a batch is successfully streamed completely (default every 100 lines). It appears that your request failed during the generation of the very first batch, therefore no file output is saved