perf: save chat and del chat content;UI

This commit is contained in:
archer
2023-04-30 13:18:54 +08:00
parent c971adaabd
commit f109f1cf60
19 changed files with 100 additions and 95 deletions

View File

@@ -1,6 +1,6 @@
import crypto from 'crypto';
import jwt from 'jsonwebtoken';
import { ChatItemType } from '@/types/chat';
import { ChatItemSimpleType } from '@/types/chat';
import { countChatTokens } from '@/utils/tools';
import { ChatCompletionRequestMessageRoleEnum, ChatCompletionRequestMessage } from 'openai';
import { ChatModelEnum } from '@/constants/model';
@@ -45,7 +45,7 @@ export const openaiChatFilter = ({
maxTokens
}: {
model: `${ChatModelEnum}`;
prompts: ChatItemType[];
prompts: ChatItemSimpleType[];
maxTokens: number;
}) => {
// role map
@@ -94,7 +94,7 @@ export const openaiChatFilter = ({
/* 整体 tokens 超出范围 */
if (tokens >= maxTokens) {
break;
return systemPrompt ? [systemPrompt, ...chats.slice(1)] : chats.slice(1);
}
}