voidpenguin-28 / Textractor-ExtraExtensions

9 stars 1 forks source link

Error when using api translate with thread linker #2

Closed SVS002 closed 3 weeks ago

SVS002 commented 3 weeks ago

i meet error this Screenshot 2024-06-20 113021 i try using api translate with thread linker and set flush delay to 3000 to prevent thread not merger then when i play this error happen, do you know how it happen? Screenshot 2024-06-20 113046

voidpenguin-28 commented 3 weeks ago

I'm struggling to recreate this issue. Can you provide the following info to help debug this:

  1. What visual novel are you running into this issue with? (if you're comfortable sharing this info)
  2. What languages are you translating to/from?
  3. Which threads are you linking with the Thread Linker?
  4. For the GptApiTranslate extension, can you set 'DebugMode' to '1'? This will log your gpt requests to a file called 'gpt-request-log.txt'.
    • Then can you provide some log entries here?
  5. Can you copy/paste (or screenshot) some text examples here from Textractor on lines causing this error?
SVS002 commented 3 weeks ago

I'm struggling to recreate this issue. Can you provide the following info to help debug this:

  1. What visual novel are you running into this issue with? (if you're comfortable sharing this info)
  2. What languages are you translating to/from?
  3. Which threads are you linking with the Thread Linker?
  4. For the GptApiTranslate extension, can you set 'DebugMode' to '1'? This will log your gpt requests to a file called 'gpt-request-log.txt'.

    • Then can you provide some log entries here?
  5. Can you copy/paste (or screenshot) some text examples here from Textractor on lines causing this error?

Sorry,seem like the error not by thread linker, when i see error i turn on thread link and before it not happen so i thought it maybe by i using both in same.Now i try remove thread link and only have api trans, it still happen this error so maybe by my system file. i have turned on debug mode but when error happen, the textactor end work and don't have log file. Can you list the what dll file your extension using, i try to replace all that file to see the error disappear or not?

voidpenguin-28 commented 3 weeks ago

No problem. I tested this with the latest version of the extension (x86 version, called 'Textractor.GptApiTranslate.xdll'). https://github.com/voidpenguin-28/Textractor-ExtraExtensions/releases/tag/GptApiTranslate-v1.2.0

Here's an easy way you can grab some text from Textractor when this issue happens for you.

  1. Make a save slot in the visual novel.
  2. Run Textractor with the Link Thread & GptApiTranslate applied.
  3. After the issue happens, re-open Textractor and remove GptApiTranslate extension (keep the Link Thread enabled).
  4. Reload your save file and go back to the line where this issue happens.
  5. Hopefully now you should be able to paste here the line in Textractor that caused the issue.
SVS002 commented 3 weeks ago

No problem. I tested this with the latest version of the extension (x86 version, called 'Textractor.GptApiTranslate.xdll'). https://github.com/voidpenguin-28/Textractor-ExtraExtensions/releases/tag/GptApiTranslate-v1.2.0

Here's an easy way you can grab some text from Textractor when this issue happens for you.

  1. Make a save slot in the visual novel.
  2. Run Textractor with the Link Thread & GptApiTranslate applied.
  3. After the issue happens, re-open Textractor and remove GptApiTranslate extension (keep the Link Thread enabled).
  4. Reload your save file and go back to the line where this issue happens.
  5. Hopefully now you should be able to paste here the line in Textractor that caused the issue.

it can't,when the error appear, if i press ok, the current textactor crash and end work, the new work textactor can't inject a appliant aganin't excule the old has inject it end work. i see whenever i have api trans appear in extension, it cause this error so i only think may my computer have error in its file C drive so the code of api may work not proper.

voidpenguin-28 commented 3 weeks ago

Apologies if I'm misunderstanding your message. If you having problems opening Textractor because of this error, you can open file "SavedExtensions.txt" and remove extensions from that file.

SVS002 commented 3 weeks ago

Apologies if I'm misunderstanding your message. If you having problems opening Textractor because of this error, you can open file "SavedExtensions.txt" and remove extensions from that file.

No, texactor still work normal even have this, only when the thread text input text throught this api, it cause error.

voidpenguin-28 commented 3 weeks ago

Then you should be able to provide a text example here from Textractor if you just remove the translate extension, correct?

On Thu, Jun 20, 2024, 12:48 PM SVS002 @.***> wrote:

Apologies if I'm misunderstanding your message. If you having problems opening Textractor because of this error, you can open file "SavedExtensions.txt" and remove extensions from that file.

No, texactor still work normal even have this, only when the thread text input text throught this api, it cause error.

— Reply to this email directly, view it on GitHub https://github.com/voidpenguin-28/Textractor-ExtraExtensions/issues/2#issuecomment-2181129910, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFGCGD54CDDKZWS5SDHU3HTZIMBWPAVCNFSM6AAAAABJTFEILGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBRGEZDSOJRGA . You are receiving this because you commented.Message ID: @.***>

SVS002 commented 3 weeks ago

Then you should be able to provide a text example here from Textractor if you just remove the translate extension, correct? On Thu, Jun 20, 2024, 12:48 PM SVS002 @.> wrote: Apologies if I'm misunderstanding your message. If you having problems opening Textractor because of this error, you can open file "SavedExtensions.txt" and remove extensions from that file. No, texactor still work normal even have this, only when the thread text input text throught this api, it cause error. — Reply to this email directly, view it on GitHub <#2 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFGCGD54CDDKZWS5SDHU3HTZIMBWPAVCNFSM6AAAAABJTFEILGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBRGEZDSOJRGA . You are receiving this because you commented.Message ID: @.>

Sorry if i reply you so long,it is my bed time in my country. After some time tested again with this extension,i found what thing cause this. i delete textactor.ini file and make textactor created this file again. api trans it work normal but because i can't use chat gpt trans(i using free account),i change it to Google Gemini API, i found the thing cause this error, it maybe becasue CustomResponseMsgRegex option conflict with the change of flush delay in setting of textactor when using gemini(whatever i up or down this value). i input enough api key but by my account free it can't translate but the pic prove the text send is normal.

Screenshot 2024-06-21 125506

i change flush delay and run text, it still work normal.

Screenshot 2024-06-21 125557

i change to gemini trans and set value exclude CustomResponseMsgRegex and run it, it run normal and have error notice return, it is normal. After run,when i close current ini and reopen it,it disapper all " in CustomRequestTemplate text set value(is it normally?)

Screenshot 2024-06-21 130231 Screenshot 2024-06-21 130616

i set again CustomRequestTemplate with the text have " of you and run it again, it don't have any error notice return but no any translate have in text.Close and reopen again ini, it don't disappear " in text.

Screenshot 2024-06-21 131210

Now i set full value text of u in both CustomResponseMsgRegex and CustomRequestTemplate, it run normal and have return translate text.

Screenshot 2024-06-21 131545 Screenshot 2024-06-21 131910

But when i change value of flush delay Screenshot 2024-06-21 132038 And when i run text, it appear a red error, the text don't run till extra window, it run in api trans and meet error the system crash and if i click ok in this error, the textactor turn off and end work, it have dump file. Screenshot 2024-06-21 132108

Now if make this extension work normal again, i must delete current ini file and make chatgpt run text once time and set value all like before of gemini, if must change delay flush must change it in time gpt and run once then change to gemini. PS:I hope that information enough to you to check what thing happen .If can, can you create a cache option to store text translate?

voidpenguin-28 commented 3 weeks ago

Thank you, this information is extremely helpful. I may have narrowed this down and am working on resolving it.

voidpenguin-28 commented 3 weeks ago

A solution has been implemented. The following 2 steps should fix this issue.

  1. Download the latest version of the GptApiTranslate extension (v1.2.1)
  2. When trying to use the Gemini API, use the following config values instead.
    Url=https://generativelanguage.googleapis.com/v1beta/models/{1}:generateContent?key={0}
    ApiKey=***GEMINI API KEY HERE***
    Model=***DESIRED GEMINI MODEL HERE (ex: gemini-1.5-flash)***
    CustomRequestTemplate={\"systemInstruction\":{\"role\":\"user\", \"parts\":[{\"text\":\"{1}\"}]}, \"contents\":[{\"role\":\"user\", \"parts\":[{\"text\":\"{2}\"}]}], \"safetySettings\":[{\"category\":\"HARM_CATEGORY_SEXUALLY_EXPLICIT\", \"threshold\":\"BLOCK_NONE\"}, {\"category\":\"HARM_CATEGORY_HATE_SPEECH\", \"threshold\":\"BLOCK_NONE\"}, {\"category\":\"HARM_CATEGORY_HARASSMENT\", \"threshold\":\"BLOCK_NONE\"}, {\"category\":\"HARM_CATEGORY_DANGEROUS_CONTENT\", \"threshold\":\"BLOCK_NONE\"}]}
    CustomResponseMsgRegex=\"[Tt]ext\":\\s{0,}\"((?:\\\\\"|[^\"])*)\"
    CustomErrorMsgRegex=
    CustomHttpHeaders=Content-Type: application/json


To explain why this issue was happening. Textractor has its own ini formatting logic that it applies every time the app is opened or closed. I was not aware that part of this logic was to auto-strip out all double quotes that aren't escaped.

So Textractor was auto-removing the double quotes from the CustomRequestTemplate & CustomResponseMsgRegex config values, which broke the extension.

Hopefully this should be resolved now, let me know. Thank you for your patience.

SVS002 commented 3 weeks ago

Thank you very much. if have any issues, i will notify.