diff --git a/src/_locales/de/main.json b/src/_locales/de/main.json index f53d5d7..3b4b804 100644 --- a/src/_locales/de/main.json +++ b/src/_locales/de/main.json @@ -129,5 +129,6 @@ "Explain": "Erklären", "Failed to get arkose token.": "Arkose-Token konnte nicht abgerufen werden.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "Bitte halten Sie https://chat.openai.com geöffnet und versuchen Sie es erneut. Wenn es immer noch nicht funktioniert, geben Sie einige Zeichen in das Eingabefeld der ChatGPT-Webseite ein und versuchen Sie es erneut.", - "Open Side Panel": "Seitenleiste öffnen" + "Open Side Panel": "Seitenleiste öffnen", + "Generating...": "Generieren..." } diff --git a/src/_locales/en/main.json b/src/_locales/en/main.json index c7f9947..4a4330a 100644 --- a/src/_locales/en/main.json +++ b/src/_locales/en/main.json @@ -129,5 +129,6 @@ "Explain": "Explain", "Failed to get arkose token.": "Failed to get arkose token.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.", - "Open Side Panel": "Open Side Panel" + "Open Side Panel": "Open Side Panel", + "Generating...": "Generating..." } diff --git a/src/_locales/es/main.json b/src/_locales/es/main.json index 15c7875..26071bd 100644 --- a/src/_locales/es/main.json +++ b/src/_locales/es/main.json @@ -129,5 +129,6 @@ "Explain": "Explicar", "Failed to get arkose token.": "No se pudo obtener el token de arkose.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "Por favor, mantenga https://chat.openai.com abierto e inténtelo de nuevo. Si aún no funciona, escriba algunos caracteres en el cuadro de entrada de la página web de chatgpt e inténtelo de nuevo.", - "Open Side Panel": "Abrir panel lateral" + "Open Side Panel": "Abrir panel lateral", + "Generating...": "Generando..." } diff --git a/src/_locales/fr/main.json b/src/_locales/fr/main.json index 895fd4a..f11fc17 100644 --- a/src/_locales/fr/main.json +++ b/src/_locales/fr/main.json @@ -129,5 +129,6 @@ "Explain": "Expliquer", "Failed to get arkose token.": "Échec de l'obtention du jeton arkose.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "Veuillez garder https://chat.openai.com ouvert et réessayer. Si cela ne fonctionne toujours pas, tapez quelques caractères dans la boîte de saisie de la page web chatgpt et réessayez.", - "Open Side Panel": "Ouvrir le panneau latéral" + "Open Side Panel": "Ouvrir le panneau latéral", + "Generating...": "Génération..." } diff --git a/src/_locales/in/main.json b/src/_locales/in/main.json index 835405e..a96b157 100644 --- a/src/_locales/in/main.json +++ b/src/_locales/in/main.json @@ -129,5 +129,6 @@ "Explain": "Jelaskan", "Failed to get arkose token.": "Gagal mendapatkan token arkose.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "Harap tetap buka https://chat.openai.com dan coba lagi. Jika masih tidak berhasil, ketik beberapa karakter di kotak masukan halaman web chatgpt dan coba lagi.", - "Open Side Panel": "Buka Panel Samping" + "Open Side Panel": "Buka Panel Samping", + "Generating...": "Menghasilkan..." } diff --git a/src/_locales/it/main.json b/src/_locales/it/main.json index 45bd122..fd1b8d4 100644 --- a/src/_locales/it/main.json +++ b/src/_locales/it/main.json @@ -129,5 +129,6 @@ "Explain": "Spiega", "Failed to get arkose token.": "Impossibile ottenere il token arkose", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "Per favore, mantieni aperto https://chat.openai.com e riprova. Se ancora non funziona, digita alcuni caratteri nella casella di input della pagina web di chatgpt e riprova.", - "Open Side Panel": "Apri il pannello laterale" + "Open Side Panel": "Apri il pannello laterale", + "Generating...": "Generazione..." } diff --git a/src/_locales/ja/main.json b/src/_locales/ja/main.json index d65f410..bd34e40 100644 --- a/src/_locales/ja/main.json +++ b/src/_locales/ja/main.json @@ -129,5 +129,6 @@ "Explain": "説明", "Failed to get arkose token.": "arkoseトークンの取得に失敗しました。", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "https://chat.openai.com を開いたままにして、もう一度試してください。それでもうまくいかない場合は、chatgpt webページの入力ボックスにいくつかの文字を入力してからもう一度試してください。", - "Open Side Panel": "サイドパネルを開く" + "Open Side Panel": "サイドパネルを開く", + "Generating...": "生成中..." } diff --git a/src/_locales/ko/main.json b/src/_locales/ko/main.json index 3a5f653..95a7b79 100644 --- a/src/_locales/ko/main.json +++ b/src/_locales/ko/main.json @@ -129,5 +129,6 @@ "Explain": "설명", "Failed to get arkose token.": "arkose 토큰을 가져오지 못했습니다.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "https://chat.openai.com 을 열어두고 다시 시도하세요. 여전히 작동하지 않으면 chatgpt 웹 페이지의 입력 상자에 몇 가지 문자를 입력한 다음 다시 시도하세요.", - "Open Side Panel": "사이드 패널 열기" + "Open Side Panel": "사이드 패널 열기", + "Generating...": "생성 중..." } diff --git a/src/_locales/pt/main.json b/src/_locales/pt/main.json index f77a4cb..d7871d2 100644 --- a/src/_locales/pt/main.json +++ b/src/_locales/pt/main.json @@ -129,5 +129,6 @@ "Explain": "Explicar", "Failed to get arkose token.": "Falha ao obter o token arkose.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "Por favor, mantenha https://chat.openai.com aberto e tente novamente. Se ainda não funcionar, digite alguns caracteres na caixa de entrada da página da web do chatgpt e tente novamente.", - "Open Side Panel": "Abrir Painel Lateral" + "Open Side Panel": "Abrir Painel Lateral", + "Generating...": "Gerando..." } diff --git a/src/_locales/ru/main.json b/src/_locales/ru/main.json index c1acc5c..efbd397 100644 --- a/src/_locales/ru/main.json +++ b/src/_locales/ru/main.json @@ -129,5 +129,6 @@ "Explain": "Объяснить", "Failed to get arkose token.": "Не удалось получить токен arkose.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "Пожалуйста, оставьте открытым https://chat.openai.com и попробуйте еще раз. Если это все еще не работает, введите несколько символов в поле ввода веб-страницы chatgpt и попробуйте еще раз.", - "Open Side Panel": "Открыть боковую панель" + "Open Side Panel": "Открыть боковую панель", + "Generating...": "Генерация..." } diff --git a/src/_locales/tr/main.json b/src/_locales/tr/main.json index 86e5223..bc0eb41 100644 --- a/src/_locales/tr/main.json +++ b/src/_locales/tr/main.json @@ -129,5 +129,6 @@ "Explain": "Açıkla", "Failed to get arkose token.": "Arkose jetonu alınamadı.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "Lütfen https://chat.openai.com adresini açık tutun ve tekrar deneyin. Hala çalışmazsa, chatgpt web sayfasının girdi kutusuna bazı karakterler yazın ve tekrar deneyin.", - "Open Side Panel": "Yan Paneli Aç" + "Open Side Panel": "Yan Paneli Aç", + "Generating...": "Üretiliyor..." } diff --git a/src/_locales/zh-hans/main.json b/src/_locales/zh-hans/main.json index b3cba10..bf357fd 100644 --- a/src/_locales/zh-hans/main.json +++ b/src/_locales/zh-hans/main.json @@ -129,5 +129,6 @@ "Explain": "解释", "Failed to get arkose token.": "获取arkose token失败.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "请保持 https://chat.openai.com 打开并重试. 如果仍然不起作用, 请在chatgpt网页的输入框中输入一些字符, 然后再试一次.", - "Open Side Panel": "打开侧边栏" + "Open Side Panel": "打开侧边栏", + "Generating...": "正在生成..." } diff --git a/src/_locales/zh-hant/main.json b/src/_locales/zh-hant/main.json index b91f900..b63607d 100644 --- a/src/_locales/zh-hant/main.json +++ b/src/_locales/zh-hant/main.json @@ -129,5 +129,6 @@ "Explain": "解釋", "Failed to get arkose token.": "無法取得 arkose token.", "Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.": "請保持 https://chat.openai.com 開啟並重試,如果還是無法通過驗證,請在 ChatGPT 網頁版輸入框輸入一些文字後再重試", - "Open Side Panel": "開啟側邊面板" + "Open Side Panel": "開啟側邊面板", + "Generating...": "產生中..." } diff --git a/src/services/apis/chatgpt-web.mjs b/src/services/apis/chatgpt-web.mjs index 0277de4..4b83409 100644 --- a/src/services/apis/chatgpt-web.mjs +++ b/src/services/apis/chatgpt-web.mjs @@ -114,6 +114,8 @@ export async function generateAnswersWithChatgptWebApi(port, question, session, ), ) let answer = '' + let generationPrefixAnswer = '' + let generatedImageUrl = '' await fetchSSE(`${config.customChatGptWebApiUrl}${config.customChatGptWebApiPath}`, { method: 'POST', signal: controller.signal, @@ -177,7 +179,38 @@ export async function generateAnswersWithChatgptWebApi(port, question, session, if (data.message?.id) session.parentMessageId = data.message.id const respAns = data.message?.content?.parts?.[0] - if (respAns) answer = respAns + const contentType = data.message?.content?.content_type + if (contentType === 'text' && respAns) { + answer = + generationPrefixAnswer + + (generatedImageUrl && `\n\n![](${generatedImageUrl})\n\n`) + + respAns + } else if (contentType === 'code' && data.message?.status === 'in_progress') { + const generationText = '\n\n' + t('Generating...') + if (answer && !answer.endsWith(generationText)) generationPrefixAnswer = answer + answer = generationPrefixAnswer + generationText + } else if ( + contentType === 'multimodal_text' && + respAns?.content_type === 'image_asset_pointer' + ) { + const imageAsset = respAns?.asset_pointer || '' + if (imageAsset) { + fetch( + `${config.customChatGptWebApiUrl}/backend-api/files/${imageAsset.replace( + 'file-service://', + '', + )}/download`, + { + credentials: 'include', + headers: { + Authorization: `Bearer ${accessToken}`, + ...(cookie && { Cookie: cookie }), + }, + }, + ).then((r) => r.json().then((json) => (generatedImageUrl = json?.download_url))) + } + } + if (answer) { port.postMessage({ answer: answer, done: false, session: null }) }