feat: History Message Number

This commit is contained in:
josc146 2024-02-04 23:11:23 +08:00
parent 1c025c3d29
commit f1986fa9d0
5 changed files with 34 additions and 8 deletions

View File

@ -338,5 +338,8 @@
"If you don't know what it is, keep it default.": "何であるかわからない場合はデフォルトのままにしてください。", "If you don't know what it is, keep it default.": "何であるかわからない場合はデフォルトのままにしてください。",
"Failed to find the base model, please try to change your base model.": "ベースモデルが見つかりませんでした、ベースモデルを変更してみてください。", "Failed to find the base model, please try to change your base model.": "ベースモデルが見つかりませんでした、ベースモデルを変更してみてください。",
"Markdown Renderer": "Markdownレンダリング", "Markdown Renderer": "Markdownレンダリング",
"Load Conversation": "会話を読み込む" "Load Conversation": "会話を読み込む",
"The latest X messages will be sent to the server. If you are using the RWKV-Runner server, please use the default value because RWKV-Runner has built-in state cache management which only calculates increments. Sending all messages will have lower cost. If you are using ChatGPT, adjust this value according to your needs to reduce ChatGPT expenses.": "最新のX件のメッセージがサーバーに送信されます。RWKV-Runnerサーバーを使用している場合は、デフォルト値を使用してください。RWKV-Runnerには組み込みの状態キャッシュ管理があり、増分のみを計算します。すべてのメッセージを送信すると、コストが低くなります。ChatGPTを使用している場合は、ChatGPTの費用を削減するために必要に応じてこの値を調整してください。",
"History Message Number": "履歴メッセージ数",
"Send All Message": "すべてのメッセージを送信"
} }

View File

@ -338,5 +338,8 @@
"If you don't know what it is, keep it default.": "如果你不知道这是什么,保持默认", "If you don't know what it is, keep it default.": "如果你不知道这是什么,保持默认",
"Failed to find the base model, please try to change your base model.": "未找到基底模型,请尝试更换基底模型", "Failed to find the base model, please try to change your base model.": "未找到基底模型,请尝试更换基底模型",
"Markdown Renderer": "Markdown渲染", "Markdown Renderer": "Markdown渲染",
"Load Conversation": "读取对话" "Load Conversation": "读取对话",
"The latest X messages will be sent to the server. If you are using the RWKV-Runner server, please use the default value because RWKV-Runner has built-in state cache management which only calculates increments. Sending all messages will have lower cost. If you are using ChatGPT, adjust this value according to your needs to reduce ChatGPT expenses.": "最近的X条消息会发送至服务器. 如果你正在使用RWKV-Runner服务器, 请使用默认值, 因为RWKV-Runner内置了state缓存管理, 只计算增量, 发送所有消息将具有更低的成本. 如果你正在使用ChatGPT, 则根据你的需要调整此值, 这可以降低ChatGPT的费用",
"History Message Number": "历史消息数量",
"Send All Message": "发送所有消息"
} }

View File

@ -231,7 +231,7 @@ const SidePanel: FC = observer(() => {
onClick={() => commonStore.setSidePanelCollapsed(true)} onClick={() => commonStore.setSidePanelCollapsed(true)}
/> />
</div> </div>
<div className="flex flex-col gap-1 overflow-x-hidden overflow-y-auto p-1"> <div className="flex flex-col gap-1 overflow-x-hidden overflow-y-auto p-0.5">
<Labeled flex breakline label={t('Max Response Token')} <Labeled flex breakline label={t('Max Response Token')}
desc={t('By default, the maximum number of tokens that can be answered in a single response, it can be changed by the user by specifying API parameters.')} desc={t('By default, the maximum number of tokens that can be answered in a single response, it can be changed by the user by specifying API parameters.')}
content={ content={
@ -299,6 +299,19 @@ const SidePanel: FC = observer(() => {
}); });
}} /> }} />
} /> } />
<Labeled flex breakline
label={t('History Message Number') + (params.historyN === 0 ? ` (${t('Default')})` : '')}
desc={params.historyN === 0 ? t('Send All Message') : t('The latest X messages will be sent to the server. If you are using the RWKV-Runner server, please use the default value because RWKV-Runner has built-in state cache management which only calculates increments. Sending all messages will have lower cost. If you are using ChatGPT, adjust this value according to your needs to reduce ChatGPT expenses.')
.replace('X', String(params.historyN))}
content={
<ValuedSlider value={params.historyN} min={0} max={20}
step={1} input
onChange={(e, data) => {
commonStore.setChatParams({
historyN: data.value
});
}} />
} />
</div> </div>
<div className="grow" /> <div className="grow" />
<Labeled flex spaceBetween <Labeled flex spaceBetween
@ -518,7 +531,7 @@ const ChatPanel: FC = observer(() => {
Authorization: `Bearer ${commonStore.settings.apiKey}` Authorization: `Bearer ${commonStore.settings.apiKey}`
}, },
body: JSON.stringify({ body: JSON.stringify({
messages, messages: messages.slice(-commonStore.chatParams.historyN),
stream: true, stream: true,
model: commonStore.settings.apiChatModelName, // 'gpt-3.5-turbo' model: commonStore.settings.apiChatModelName, // 'gpt-3.5-turbo'
temperature: commonStore.chatParams.temperature, temperature: commonStore.chatParams.temperature,
@ -594,7 +607,7 @@ const ChatPanel: FC = observer(() => {
style={{ zIndex: 1 }} style={{ zIndex: 1 }}
icon={commonStore.sidePanelCollapsed ? <TextAlignJustify24Regular /> : <TextAlignJustifyRotate9024Regular />} icon={commonStore.sidePanelCollapsed ? <TextAlignJustify24Regular /> : <TextAlignJustifyRotate9024Regular />}
onClick={() => commonStore.setSidePanelCollapsed(!commonStore.sidePanelCollapsed)} /> onClick={() => commonStore.setSidePanelCollapsed(!commonStore.sidePanelCollapsed)} />
<div ref={bodyRef} className="grow overflow-y-scroll overflow-x-hidden pr-2"> <div ref={bodyRef} className="grow overflow-y-auto overflow-x-hidden pr-2">
{commonStore.conversationOrder.map(uuid => {commonStore.conversationOrder.map(uuid =>
<ChatMessageItem key={uuid} uuid={uuid} onSubmit={onSubmit} /> <ChatMessageItem key={uuid} uuid={uuid} onSubmit={onSubmit} />
)} )}

View File

@ -3,7 +3,12 @@ import { getUserLanguage, isSystemLightMode, saveCache, saveConfigs, savePresets
import { WindowSetDarkTheme, WindowSetLightTheme } from '../../wailsjs/runtime'; import { WindowSetDarkTheme, WindowSetLightTheme } from '../../wailsjs/runtime';
import manifest from '../../../manifest.json'; import manifest from '../../../manifest.json';
import i18n from 'i18next'; import i18n from 'i18next';
import { defaultCompositionPrompt, defaultModelConfigs, defaultModelConfigsMac } from '../pages/defaultConfigs'; import {
defaultCompositionPrompt,
defaultModelConfigs,
defaultModelConfigsMac,
defaultPenaltyDecay
} from '../pages/defaultConfigs';
import { ChartData } from 'chart.js'; import { ChartData } from 'chart.js';
import { Preset } from '../types/presets'; import { Preset } from '../types/presets';
import { AboutContent } from '../types/about'; import { AboutContent } from '../types/about';
@ -80,7 +85,8 @@ class CommonStore {
topP: 0.3, topP: 0.3,
presencePenalty: 0, presencePenalty: 0,
frequencyPenalty: 1, frequencyPenalty: 1,
penaltyDecay: 0.996, penaltyDecay: defaultPenaltyDecay,
historyN: 0,
markdown: true markdown: true
}; };
sidePanelCollapsed: boolean | 'auto' = 'auto'; sidePanelCollapsed: boolean | 'auto' = 'auto';

View File

@ -35,5 +35,6 @@ export type Attachment = {
content: string; content: string;
} }
export type ChatParams = Omit<ApiParameters, 'apiPort'> & { export type ChatParams = Omit<ApiParameters, 'apiPort'> & {
markdown: boolean historyN: number;
markdown: boolean;
} }