mirror of
https://github.com/cs-lazy-tools/ChatGPT-On-CS.git
synced 2026-08-28 18:17:40 +08:00
fix: 修复上下文数量问题
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user