Skip to content

Commit

Permalink
chore: Change Config Format for Openai
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Aug 29, 2023
1 parent fe07e72 commit 01624ef
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/i18n/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions src/i18n/locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@
"service": "服务提供商",
"openai": "OpenAI",
"azure": "Azure",
"url_path": "Url Path",
"custom_url": "自定义域名",
"request_path": "请求地址",
"api_key": "Api Key",
"model": "模型",
"stream": "流式输出"
Expand Down
23 changes: 4 additions & 19 deletions src/services/translate/openai/Config.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -79,29 +78,15 @@ export function Config(props) {
/>
</div>
<div className='config-item'>
<h3 className='my-auto'>{t('services.translate.openai.custom_url')}</h3>
<h3 className='my-auto'>{t('services.translate.openai.request_path')}</h3>
<Input
value={openaiConfig['customUrl']}
value={openaiConfig['requestPath']}
variant='bordered'
className='max-w-[50%]'
onValueChange={(value) => {
setOpenaiConfig({
...openaiConfig,
customUrl: value,
});
}}
/>
</div>
<div className={`config-item ${openaiConfig.service === 'openai' && 'hidden'}`}>
<h3 className='my-auto'>{t('services.translate.openai.url_path')}</h3>
<Input
value={openaiConfig['urlPath']}
variant='bordered'
className='max-w-[50%]'
onValueChange={(value) => {
setOpenaiConfig({
...openaiConfig,
urlPath: value,
requestPath: value,
});
}}
/>
Expand Down
1 change: 1 addition & 0 deletions src/window/Translate/components/TargetArea/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 01624ef

Please sign in to comment.