From c1868d56e5d9e0c6627a199ca4632ff7f92ba846 Mon Sep 17 00:00:00 2001 From: xtyuns Date: Sun, 9 Jun 2024 19:14:41 +0800 Subject: [PATCH] fix: config openai translator (#829) * alway use config from options in openai * adjust requestPath correction rule * config openai arguments * completing the v1 prefix by default --- src/services/translate/openai/Config.jsx | 36 ++++++++++++++++++++++-- src/services/translate/openai/index.jsx | 21 ++++++-------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/services/translate/openai/Config.jsx b/src/services/translate/openai/Config.jsx index 27ea58bc89..d88710060a 100644 --- a/src/services/translate/openai/Config.jsx +++ b/src/services/translate/openai/Config.jsx @@ -15,6 +15,13 @@ import { translate } from './index'; import { Language } from './index'; import { INSTANCE_NAME_CONFIG_KEY } from '../../../utils/service_instance'; +export const defaultRequestArguments = JSON.stringify({ + temperature: 0, + top_p: 1, + frequency_penalty: 1, + presence_penalty: 1, +}) + export function Config(props) { const { instanceKey, updateServiceList, onClose } = props; const [openaiConfig, setOpenaiConfig] = useConfig( @@ -34,6 +41,7 @@ export function Config(props) { }, { role: 'user', content: `Translate into $to:\n"""\n$text\n"""` }, ], + requestArguments: defaultRequestArguments }, { sync: false } ); @@ -52,6 +60,12 @@ export function Config(props) { ], }); } + if(openaiConfig.requestArguments === undefined) { + setOpenaiConfig({ + ...openaiConfig, + requestArguments: defaultRequestArguments + }) + } } const [isLoading, setIsLoading] = useState(false); @@ -296,8 +310,8 @@ export function Config(props) { openaiConfig.promptList.length === 0 ? 'system' : openaiConfig.promptList.length % 2 === 0 - ? 'assistant' - : 'user', + ? 'assistant' + : 'user', content: '', }, ], @@ -308,6 +322,24 @@ export function Config(props) {
+ +

Request Arguments

+
+