Cerlancism / chatgpt-subtitle-translator

Efficient translation tool based on ChatGPT API
https://cerlancism.github.io/chatgpt-subtitle-translator/
MIT License
145 stars 16 forks source link

add custom base_Url in web #16

Closed aliceric27 closed 4 months ago

aliceric27 commented 4 months ago

你好,我目前嘗試開發web版本 因為我呼叫的API domain不是open ai 原地址 https://api.openai.com 我嘗試在web版新增.env檔案並且嘗試設定OPENAI_BASE_URL,不過好像沒有效果 想詢問如果我要在web版底下,嘗試使用自訂 api domain,應該如何修改呢?

Hello, I am currently trying to develop a web version. Since the API domain I am calling is not the original OpenAI address https://api.openai.com, I tried to add a .env file in the web version and set OPENAI_BASE_URL, but it doesn't seem to have any effect. I would like to ask how I should modify it if I want to try using a custom API domain in the web version.

Cerlancism commented 4 months ago

使用我的 web 版吗?https://cerlancism.github.io/chatgpt-subtitle-translator Web 版支持 env 是行的,但我认为这不适合, 并且 Next.js 需要加上 NEXT_PUBLIC 将其变成 NEXT_PUBLIC_OPENAI_BASE_URL

因此我在 web 添加了 Base URL 输入

image

而对于 OPENAI_BASE_URL env 的支持,则在 cli 版支持了

aliceric27 commented 4 months ago

感謝更新這項功能,測試過後沒有問題

aliceric27 commented 4 months ago

另外有個關於 NextUI 的問題想請教 我嘗試將 From language 和 To Language 兩個 <input> 修改為 <select> 並設定一些預設的語言方便操作和轉換,不過我的 Switch button 是有作用的,但 <select> 內的 value 值不會改變 想詢問合適的 solution 或是哪邊我遺漏了,謝謝

https://github.com/aliceric27/chatgpt-subtitle-translator/commit/b1c6760172afb5122441b51b456cd6f35e4dd63e

Cerlancism commented 4 months ago

Select 使用 selectedKeys[] 不是 value

@@ -258,7 +258,7 @@ export function TranslatorApplication()
                       label="From Language"
                       className="w-full md:w-6/12"
                       placeholder="Auto"
-                      value={fromLanguage}
+                      selectedKeys={fromLanguage ? [fromLanguage] : []}
                       items={LANGUAGE}
                       onChange={(e) => setFromLanguage(e.target.value)}
                     >
@@ -277,7 +277,7 @@ export function TranslatorApplication()
                       label="To Language"
                       className="w-full md:w-6/12"
                       placeholder="English"
-                      value={toLanguage}
+                      selectedKeys={[toLanguage]}
                       onChange={(e) => setToLanguage(e.target.value)}
                     >
                       {LANGUAGE.map((language) => (
aliceric27 commented 4 months ago

非常感謝指點,沒有任何問題了

Cerlancism commented 4 months ago

不客气,感谢您对这个项目的兴趣。