frontend feature adaptation for api params (user_name, assistant_name, presystem)

This commit is contained in:
josc146 2023-09-16 13:02:06 +08:00
parent f89e89c1c9
commit fcfaa5944e
4 changed files with 44 additions and 5 deletions

View File

@ -250,5 +250,8 @@
"VRAM": "VRAM", "VRAM": "VRAM",
"GPU Usage": "GPU使用率", "GPU Usage": "GPU使用率",
"Use Custom Tokenizer": "カスタムトークナイザーを使用する", "Use Custom Tokenizer": "カスタムトークナイザーを使用する",
"Tokenizer Path (e.g. backend-python/rwkv_pip/20B_tokenizer.json)": "トークナイザーパス (例: backend-python/rwkv_pip/20B_tokenizer.json)" "Tokenizer Path (e.g. backend-python/rwkv_pip/20B_tokenizer.json)": "トークナイザーパス (例: backend-python/rwkv_pip/20B_tokenizer.json)",
"User Name": "ユーザー名",
"Assistant Name": "アシスタント名",
"Insert default system prompt at the beginning": "最初にデフォルトのシステムプロンプトを挿入"
} }

View File

@ -250,5 +250,8 @@
"VRAM": "显存", "VRAM": "显存",
"GPU Usage": "GPU占用", "GPU Usage": "GPU占用",
"Use Custom Tokenizer": "使用自定义Tokenizer", "Use Custom Tokenizer": "使用自定义Tokenizer",
"Tokenizer Path (e.g. backend-python/rwkv_pip/20B_tokenizer.json)": "Tokenizer路径 (例如: backend-python/rwkv_pip/20B_tokenizer.json)" "Tokenizer Path (e.g. backend-python/rwkv_pip/20B_tokenizer.json)": "Tokenizer路径 (例如: backend-python/rwkv_pip/20B_tokenizer.json)",
"User Name": "用户名称",
"Assistant Name": "AI名称",
"Insert default system prompt at the beginning": "在开头自动插入默认系统提示"
} }

View File

@ -312,7 +312,10 @@ const ChatPanel: FC = observer(() => {
stream: true, stream: true,
model: commonStore.settings.apiChatModelName, // 'gpt-3.5-turbo' model: commonStore.settings.apiChatModelName, // 'gpt-3.5-turbo'
temperature: apiParams.temperature, temperature: apiParams.temperature,
top_p: apiParams.topP top_p: apiParams.topP,
user_name: commonStore.activePreset?.userName,
assistant_name: commonStore.activePreset?.assistantName,
presystem: commonStore.activePreset?.presystem
}), }),
signal: chatSseController?.signal, signal: chatSseController?.signal,
onmessage(e) { onmessage(e) {

View File

@ -56,6 +56,9 @@ export type Preset = {
stop: string, stop: string,
injectStart: string, injectStart: string,
injectEnd: string, injectEnd: string,
presystem?: boolean,
userName?: string,
assistantName?: string
} }
export const defaultPreset: Preset = { export const defaultPreset: Preset = {
@ -255,9 +258,36 @@ export const ChatPresetEditor: FC<{
} /> } />
{ {
editingMessages ? editingMessages ?
<MessagesEditor /> : <div className="flex flex-col gap-1">
<Labeled flex spaceBetween label={t('Insert default system prompt at the beginning')}
content={
<Switch checked={editingPreset.presystem === undefined ? true : editingPreset.presystem}
onChange={(e, data) => {
setEditingPreset({
presystem: data.checked
});
}} />
} />
<Labeled flex breakline label={t('User Name')}
content={
<Input placeholder="User" value={editingPreset.userName} onChange={(e, data) => {
setEditingPreset({
userName: data.value
});
}} />
} />
<Labeled flex breakline label={t('Assistant Name')}
content={
<Input placeholder="Assistant" value={editingPreset.assistantName} onChange={(e, data) => {
setEditingPreset({
assistantName: data.value
});
}} />
} />
<MessagesEditor />
</div> :
<div className="flex flex-col gap-1 p-2 overflow-x-hidden overflow-y-auto"> <div className="flex flex-col gap-1 p-2 overflow-x-hidden overflow-y-auto">
<Labeled flex breakline label={`${t('Description')} (${t("Preview Only")})`} <Labeled flex breakline label={`${t('Description')} (${t('Preview Only')})`}
content={ content={
<Input value={editingPreset.desc} onChange={(e, data) => { <Input value={editingPreset.desc} onChange={(e, data) => {
setEditingPreset({ setEditingPreset({