mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 00:17:31 +00:00
fix: refresh page
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
### Fast GPT V3.8.4
|
### Fast GPT V3.8.8
|
||||||
|
|
||||||
1. 新增 - mermaid 导图兼容,可以在应用市场 'mermaid 导图' 进行体验。
|
1. 新增 - V2 版 OpenAPI,可以在任意第三方套壳 ChatGpt 项目中直接使用 FastGpt 的应用,注意!是直接。
|
||||||
2. 优化 - 部分 UI 和账号页。
|
2. 新增 - 应用配置最大回复长度。
|
||||||
2. 优化 - 知识库搜索速度
|
3. 新增 - 更多的知识库配置项:相似度、最大搜索数量、自定义空搜索结果回复。
|
||||||
|
4. 新增 - 知识库搜索测试,方便调试。
|
||||||
|
5. 优化 - 知识库提示词位置,拥有更强的引导。
|
||||||
|
6. 优化 - 应用编辑页面。
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||||
import { connectToDatabase } from '@/service/mongo';
|
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 { modelServiceToolMap, V2_StreamResponse } from '@/service/utils/chat';
|
||||||
import { jsonRes } from '@/service/response';
|
import { jsonRes } from '@/service/response';
|
||||||
import { ChatModelMap } from '@/constants/model';
|
import { ChatModelMap } from '@/constants/model';
|
||||||
|
@@ -156,6 +156,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
|
|||||||
onSuccess(res) {
|
onSuccess(res) {
|
||||||
res && reset(res);
|
res && reset(res);
|
||||||
modelId && setLastModelId(modelId);
|
modelId && setLastModelId(modelId);
|
||||||
|
setRefresh(!refresh);
|
||||||
},
|
},
|
||||||
onError(err: any) {
|
onError(err: any) {
|
||||||
toast({
|
toast({
|
||||||
@@ -278,6 +279,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
|
|||||||
width={['100%', '260px']}
|
width={['100%', '260px']}
|
||||||
min={100}
|
min={100}
|
||||||
max={tokenLimit}
|
max={tokenLimit}
|
||||||
|
step={50}
|
||||||
activeVal={getValues('chat.maxToken')}
|
activeVal={getValues('chat.maxToken')}
|
||||||
setVal={(val) => {
|
setVal={(val) => {
|
||||||
setValue('chat.maxToken', val);
|
setValue('chat.maxToken', val);
|
||||||
|
@@ -20,15 +20,17 @@ export const adaptBill = (bill: BillSchema): UserBillType => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const gptMessage2ChatType = (messages: MessageItemType[]): ChatItemType[] => {
|
export const gptMessage2ChatType = (messages: MessageItemType[]): ChatItemType[] => {
|
||||||
const roleMap = {
|
const roleMap: Record<`${ChatCompletionRequestMessageRoleEnum}`, `${ChatRoleEnum}`> = {
|
||||||
[ChatCompletionRequestMessageRoleEnum.Assistant]: ChatRoleEnum.AI,
|
[ChatCompletionRequestMessageRoleEnum.Assistant]: ChatRoleEnum.AI,
|
||||||
[ChatCompletionRequestMessageRoleEnum.User]: ChatRoleEnum.Human,
|
[ChatCompletionRequestMessageRoleEnum.User]: ChatRoleEnum.Human,
|
||||||
[ChatCompletionRequestMessageRoleEnum.System]: ChatRoleEnum.System
|
[ChatCompletionRequestMessageRoleEnum.System]: ChatRoleEnum.System,
|
||||||
|
[ChatCompletionRequestMessageRoleEnum.Function]: ChatRoleEnum.Human
|
||||||
};
|
};
|
||||||
|
|
||||||
return messages.map((item) => ({
|
return messages.map((item) => ({
|
||||||
_id: item._id,
|
_id: item._id,
|
||||||
obj: roleMap[item.role],
|
obj: roleMap[item.role],
|
||||||
value: item.content
|
value: item.content || ''
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { encoding_for_model, type Tiktoken } from '@dqbd/tiktoken';
|
import { encoding_for_model, type Tiktoken } from '@dqbd/tiktoken';
|
||||||
import type { ChatItemType } from '@/types/chat';
|
import type { ChatItemType } from '@/types/chat';
|
||||||
import { ChatRoleEnum } from '@/constants/chat';
|
import { ChatRoleEnum } from '@/constants/chat';
|
||||||
import { ChatCompletionRequestMessageRoleEnum } from 'openai';
|
import { type ChatCompletionRequestMessage, ChatCompletionRequestMessageRoleEnum } from 'openai';
|
||||||
import { OpenAiChatEnum } from '@/constants/model';
|
import { OpenAiChatEnum } from '@/constants/model';
|
||||||
import Graphemer from 'graphemer';
|
import Graphemer from 'graphemer';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
@@ -113,11 +113,7 @@ export function countOpenAIToken({
|
|||||||
model: `${OpenAiChatEnum}`;
|
model: `${OpenAiChatEnum}`;
|
||||||
}) {
|
}) {
|
||||||
function getChatGPTEncodingText(
|
function getChatGPTEncodingText(
|
||||||
messages: {
|
messages: ChatCompletionRequestMessage[],
|
||||||
role: 'system' | 'user' | 'assistant';
|
|
||||||
content: string;
|
|
||||||
name?: string;
|
|
||||||
}[],
|
|
||||||
model: `${OpenAiChatEnum}`
|
model: `${OpenAiChatEnum}`
|
||||||
) {
|
) {
|
||||||
const isGpt3 = model.startsWith('gpt-3.5-turbo');
|
const isGpt3 = model.startsWith('gpt-3.5-turbo');
|
||||||
|
Reference in New Issue
Block a user