fix: 修复上下文数量问题

This commit is contained in:
lrhh123
2024-06-25 16:40:38 +08:00
parent e25ebc643e
commit 3e6eaae1c9
2 changed files with 32 additions and 21 deletions
+9 -1
View File
@@ -1,5 +1,4 @@
import fs from 'fs/promises';
import { BrowserWindow } from 'electron';
import { KeywordReplyController } from '../controllers/keywordReplyController';
import {
MessageDTO,
@@ -77,6 +76,12 @@ export class MessageService {
return reply;
}
// 再根据 context_count 去保留最后几条消息
if (cfg.context_count > 0) {
// eslint-disable-next-line no-param-reassign
messages = messages.slice(-cfg.context_count);
}
// 等待随机时间
await new Promise((resolve) => {
const min = cfg.reply_speed;
@@ -239,6 +244,9 @@ export class MessageService {
// const chatCompletion = await client.chat.completions.create
if ('chat' in llmClient) {
try {
console.log('开始使用 GPT 生成回复....');
console.log('messages:', messages);
// @ts-ignore
const response = await llmClient.chat.completions.create({
model: cfg.model,
+23 -20
View File
@@ -20,7 +20,6 @@ import {
} from '@chakra-ui/react';
import { loader } from '@monaco-editor/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import AccountSettings from './components/Settings/AccountSettings';
import GeneralSettings from './components/Settings/GeneralSettings';
import LLMSettings from './components/Settings/LLMSettings';
import PluginSettings from './components/Settings/PluginSettings';
@@ -200,15 +199,17 @@ const App = () => {
{settings.appId || settings.instanceId ? '' : '全局'}
</Tab>
{!settings.appId && (
<Tab
_selected={{ bg: 'gray.200' }}
_hover={{ bg: 'gray.300' }}
textAlign="left"
>
使
</Tab>
)}
{
// {!settings.appId && (
// <Tab
// _selected={{ bg: 'gray.200' }}
// _hover={{ bg: 'gray.300' }}
// textAlign="left"
// >
// 使用激活码
// </Tab>
// )}
}
{!settings.appId && (
<Tab
@@ -250,16 +251,18 @@ const App = () => {
instanceId={settings.instanceId}
/>
</TabPanel>
{!settings.appId && (
<>
<TabPanel>
<Heading as="h3" size="md" mb={4}>
</Heading>
<AccountSettings />
</TabPanel>
</>
)}
{
// {!settings.appId && (
// <>
// <TabPanel>
// <Heading as="h3" size="md" mb={4}>
// 账户设置
// </Heading>
// <AccountSettings />
// </TabPanel>
// </>
// )}
}
{!settings.appId && (
<>
<TabPanel>