machinewrapped / gpt-subtrans

Open Source project using LLMs to translate SRT subtitles
Other
311 stars 36 forks source link

In the 0.4.4 macOS version, the error code and error message are returned. #73

Closed neohob closed 8 months ago

neohob commented 9 months ago

Tuesday, 10:33:17 - error_code=None error_message='This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?' error_param=model error_type=invalid_request_error message='OpenAI API error received' stream_error=False Tuesday, 10:33:17 - Failed to translate scene 1 (This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?)... finishing

image
neohob commented 9 months ago

I encountered another bug: the app crashes when I change settings, regardless of whether I click 'Cancel' or 'OK.' Below is the error message:

Qt has caught an exception thrown from an event handler. Throwing exceptions from an event handler is not supported in Qt. You must not let any exception whatsoever propagate through Qt code. Fatal Python error: PyGILState_Release: thread state 0x11019b2c8 must be current when releasing Python runtime state: initialized

Current thread 0x00007ff847839700 (most recent call first): File [1] 68698 segmentation fault /xxx/gui-subtrans/gui-subtrans

machinewrapped commented 9 months ago

The first error must be because of the turbo-instruct model - apparently it only supports the "Completions" API endpoint, not the "Conversations" API endpoint: https://platform.openai.com/docs/guides/gpt/completions-api

It might be worth experimenting with that to see if it gives better translations, but it will require a new client class and prompt format so you'll need to stick to the non-instruct models for the time being. I usually use gpt3.5-turbo-16k these days, with a max batch size of 100.

The second error is interesting but there's not enough information in the error to know where the uncaught exception was raised - I'll see if I can reproduce it on the mac, but if you can get a more complete error dump it would be helpful.

neohob commented 9 months ago

Thank you for your reply. I'm using the GPT-3.5 Turbo model, and it's working. However, I've encountered another issue. I was translating some subtitles into a non-English language. The first batch was in the correct language, but the second batch is consistently only in English. The third batch goes back to the correct language. I stopped testing it, so I don't know if there are more instances of English translation.

machinewrapped commented 9 months ago

Translating to another language shouldn't be a problem, but the fact the instructions are written in English does predispose it to respond in English.

Can you check the GPT Settings in Project Options (the icon in the sidebar on the left). Make sure the prompt is "Please translate these subtitles[ for movie][ to language]." - movie and language should be substituted automatically but you could specify the language explicitly to be safe, and writing the whole prompt in that language would be even better.

Assuming you're using the default instructions, the first line should be "You are a translator, your task is to accurately translate subtitles into a target language." - you could replace "target language" with the language you want to make the instructions more explicit.

I notice in your first post that you raised the temperature to 0.9 - that is very high and will introduce a lot of randomness into the responses, setting it back to 0.0 might help GPT stick to following instructions.

If you're still having issues then try editing the instructions to include an example of translating to your target language. As a last resort translate the whole instructions text into that language (ChatGPT can do the translation).