fix: refresh page

This commit is contained in:
archer
2023-06-18 22:19:49 +08:00
parent ff2043c0fb
commit 6c62d80a4c
5 changed files with 17 additions and 14 deletions

View File

@@ -1,5 +1,8 @@
### Fast GPT V3.8.4
### Fast GPT V3.8.8
1. 新增 - mermaid 导图兼容,可以在应用市场 'mermaid 导图' 进行体验
2. 优化 - 部分 UI 和账号页
2. 优化 - 知识库搜索速度
1. 新增 - V2 版 OpenAPI可以在任意第三方套壳 ChatGpt 项目中直接使用 FastGpt 的应用,注意!是直接
2. 新增 - 应用配置最大回复长度
3. 新增 - 更多的知识库配置项:相似度、最大搜索数量、自定义空搜索结果回复。
4. 新增 - 知识库搜索测试,方便调试。
5. 优化 - 知识库提示词位置,拥有更强的引导。
6. 优化 - 应用编辑页面。

View File

@@ -1,6 +1,6 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { connectToDatabase } from '@/service/mongo';
import { authUser, authModel, getApiKey, authShareChat, type AuthType } from '@/service/utils/auth';
import { authUser, authModel, getApiKey, authShareChat } from '@/service/utils/auth';
import { modelServiceToolMap, V2_StreamResponse } from '@/service/utils/chat';
import { jsonRes } from '@/service/response';
import { ChatModelMap } from '@/constants/model';

View File

@@ -156,6 +156,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
onSuccess(res) {
res && reset(res);
modelId && setLastModelId(modelId);
setRefresh(!refresh);
},
onError(err: any) {
toast({
@@ -278,6 +279,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
width={['100%', '260px']}
min={100}
max={tokenLimit}
step={50}
activeVal={getValues('chat.maxToken')}
setVal={(val) => {
setValue('chat.maxToken', val);

View File

@@ -20,15 +20,17 @@ export const adaptBill = (bill: BillSchema): UserBillType => {
};
export const gptMessage2ChatType = (messages: MessageItemType[]): ChatItemType[] => {
const roleMap = {
const roleMap: Record<`${ChatCompletionRequestMessageRoleEnum}`, `${ChatRoleEnum}`> = {
[ChatCompletionRequestMessageRoleEnum.Assistant]: ChatRoleEnum.AI,
[ChatCompletionRequestMessageRoleEnum.User]: ChatRoleEnum.Human,
[ChatCompletionRequestMessageRoleEnum.System]: ChatRoleEnum.System
[ChatCompletionRequestMessageRoleEnum.System]: ChatRoleEnum.System,
[ChatCompletionRequestMessageRoleEnum.Function]: ChatRoleEnum.Human
};
return messages.map((item) => ({
_id: item._id,
obj: roleMap[item.role],
value: item.content
value: item.content || ''
}));
};

View File

@@ -1,7 +1,7 @@
import { encoding_for_model, type Tiktoken } from '@dqbd/tiktoken';
import type { ChatItemType } from '@/types/chat';
import { ChatRoleEnum } from '@/constants/chat';
import { ChatCompletionRequestMessageRoleEnum } from 'openai';
import { type ChatCompletionRequestMessage, ChatCompletionRequestMessageRoleEnum } from 'openai';
import { OpenAiChatEnum } from '@/constants/model';
import Graphemer from 'graphemer';
import axios from 'axios';
@@ -113,11 +113,7 @@ export function countOpenAIToken({
model: `${OpenAiChatEnum}`;
}) {
function getChatGPTEncodingText(
messages: {
role: 'system' | 'user' | 'assistant';
content: string;
name?: string;
}[],
messages: ChatCompletionRequestMessage[],
model: `${OpenAiChatEnum}`
) {
const isGpt3 = model.startsWith('gpt-3.5-turbo');