From 01624efb29d33e30ac836f2f8d62a41d89fa8676 Mon Sep 17 00:00:00 2001 From: Pylogmon Date: Tue, 29 Aug 2023 17:03:03 +0800 Subject: [PATCH] chore: Change Config Format for Openai --- src/i18n/locales/en_US.json | 3 +-- src/i18n/locales/zh_CN.json | 3 +-- src/services/translate/openai/Config.jsx | 23 ++++--------------- .../Translate/components/TargetArea/index.jsx | 1 + 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/i18n/locales/en_US.json b/src/i18n/locales/en_US.json index 1967fe2f87..f7450d1977 100644 --- a/src/i18n/locales/en_US.json +++ b/src/i18n/locales/en_US.json @@ -171,8 +171,7 @@ "service": "Service Provider", "openai": "OpenAI", "azure": "Azure", - "url_path": "Url Path", - "custom_url": "Custom Url", + "request_path": "Request Path", "api_key": "Api Key", "model": "Model", "stream": "Stream Mode" diff --git a/src/i18n/locales/zh_CN.json b/src/i18n/locales/zh_CN.json index 8a98d37473..5751ec7ff2 100644 --- a/src/i18n/locales/zh_CN.json +++ b/src/i18n/locales/zh_CN.json @@ -170,8 +170,7 @@ "service": "服务提供商", "openai": "OpenAI", "azure": "Azure", - "url_path": "Url Path", - "custom_url": "自定义域名", + "request_path": "请求地址", "api_key": "Api Key", "model": "模型", "stream": "流式输出" diff --git a/src/services/translate/openai/Config.jsx b/src/services/translate/openai/Config.jsx index 6f45cac2d2..bd6492caea 100644 --- a/src/services/translate/openai/Config.jsx +++ b/src/services/translate/openai/Config.jsx @@ -19,10 +19,9 @@ export function Config(props) { 'openai', { service: 'openai', - customUrl: 'api.openai.com', + requestPath: 'https://api.openai.com/v1/chat/completions', model: 'gpt-3.5-turbo', apiKey: '', - urlPath: '', stream: false, }, { sync: false } @@ -79,29 +78,15 @@ export function Config(props) { />
-

{t('services.translate.openai.custom_url')}

+

{t('services.translate.openai.request_path')}

{ setOpenaiConfig({ ...openaiConfig, - customUrl: value, - }); - }} - /> -
-
-

{t('services.translate.openai.url_path')}

- { - setOpenaiConfig({ - ...openaiConfig, - urlPath: value, + requestPath: value, }); }} /> diff --git a/src/window/Translate/components/TargetArea/index.jsx b/src/window/Translate/components/TargetArea/index.jsx index 2f514e1985..1ec79b7416 100644 --- a/src/window/Translate/components/TargetArea/index.jsx +++ b/src/window/Translate/components/TargetArea/index.jsx @@ -125,6 +125,7 @@ export default function TargetArea(props) { variant='light' size='sm' onPress={() => { + setError(''); if (typeof result === 'string' && result !== '') { let newTargetLanguage = sourceLanguage; if (sourceLanguage === 'auto') {