mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00
v4.6.4 (#585)
* perf: md format * add systemConfig schema (#2) * fix: markdown * fix: root * fix: root --------- Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
This commit is contained in:
@@ -151,6 +151,7 @@ export const splitText2Chunks = (props: {
|
||||
const maxLen = splitTexts.length > 1 ? stepReges[step].maxLen : chunkLen;
|
||||
const minChunkLen = chunkLen * 0.7;
|
||||
const miniChunkLen = 30;
|
||||
// console.log(splitTexts, stepReges[step].reg);
|
||||
|
||||
const chunks: string[] = [];
|
||||
for (let i = 0; i < splitTexts.length; i++) {
|
||||
|
13
packages/global/common/system/config/constants.ts
Normal file
13
packages/global/common/system/config/constants.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export enum SystemConfigsTypeEnum {
|
||||
fastgpt = 'fastgpt',
|
||||
fastgptPro = 'fastgptPro'
|
||||
}
|
||||
|
||||
export const SystemConfigsTypeMap = {
|
||||
[SystemConfigsTypeEnum.fastgpt]: {
|
||||
label: 'fastgpt'
|
||||
},
|
||||
[SystemConfigsTypeEnum.fastgptPro]: {
|
||||
label: 'fastgptPro'
|
||||
}
|
||||
};
|
8
packages/global/common/system/config/type.d.ts
vendored
Normal file
8
packages/global/common/system/config/type.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { SystemConfigsTypeEnum } from "./constants";
|
||||
|
||||
export type SystemConfigsType = {
|
||||
_id: string;
|
||||
type: `${SystemConfigsTypeEnum}`;
|
||||
value: Record<string, any>;
|
||||
createTime: Date;
|
||||
};
|
32
packages/service/common/system/config/schema.ts
Normal file
32
packages/service/common/system/config/schema.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { SystemConfigsType } from '@fastgpt/global/common/system/config/type';
|
||||
import { connectionMongo, type Model } from '../../../common/mongo';
|
||||
import { SystemConfigsTypeMap } from '@fastgpt/global/common/system/config/constants';
|
||||
|
||||
const { Schema, model, models } = connectionMongo;
|
||||
|
||||
const collectionName = 'systemConfigs';
|
||||
const systemConfigSchema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
enum: Object.keys(SystemConfigsTypeMap)
|
||||
},
|
||||
value: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
createTime: {
|
||||
type: Date,
|
||||
default: () => new Date()
|
||||
}
|
||||
})
|
||||
|
||||
try {
|
||||
systemConfigSchema.index({ createTime: -1 }, { expireAfterSeconds: 90 * 24 * 60 * 60 });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
export const MongoSystemConfigs: Model<SystemConfigsType>=
|
||||
models[collectionName] || model(collectionName, systemConfigSchema);
|
||||
MongoSystemConfigs.syncIndexes();
|
@@ -151,6 +151,7 @@ export async function parseHeaderCert({
|
||||
authType: AuthUserTypeEnum.root
|
||||
};
|
||||
}
|
||||
// apikey: abandon
|
||||
if (authApiKey && apikey) {
|
||||
// apikey
|
||||
const parseResult = await authOpenApiKey({ apikey });
|
||||
@@ -164,20 +165,8 @@ export async function parseHeaderCert({
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
uid: '',
|
||||
teamId: '',
|
||||
tmbId: '',
|
||||
appId: '',
|
||||
openApiKey: '',
|
||||
authType: AuthUserTypeEnum.token
|
||||
};
|
||||
})();
|
||||
|
||||
// not rootUser and no uid, reject request
|
||||
if (!rootkey && !uid && !teamId && !tmbId) {
|
||||
return Promise.reject(ERROR_ENUM.unAuthorization);
|
||||
}
|
||||
})();
|
||||
|
||||
return {
|
||||
userId: String(uid),
|
||||
|
@@ -296,7 +296,7 @@ const CodeLight = ({
|
||||
}) => {
|
||||
const { copyData } = useCopyData();
|
||||
|
||||
if (!inline && match) {
|
||||
if (!inline) {
|
||||
return (
|
||||
<Box my={3} borderRadius={'md'} overflow={'overlay'} backgroundColor={'#222'}>
|
||||
<Flex
|
||||
|
@@ -308,8 +308,9 @@
|
||||
}
|
||||
.markdown code,
|
||||
.markdown tt {
|
||||
border: 1px solid #eaeaea;
|
||||
border-radius: 3px 3px 3px 3px;
|
||||
border: 1px solid #dee0e2;
|
||||
background-color: #f4f6f8;
|
||||
border-radius: 3px;
|
||||
margin: 0 2px;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
@@ -1,8 +1,10 @@
|
||||
export const Prompt_AgentQA = {
|
||||
description: `我会给你一段文本,学习它们,并整理学习成果,要求为:
|
||||
1. 提出问题并给出每个问题的答案。
|
||||
2. 每个答案都要详细完整,给出相关原文描述,答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 markdown 元素。
|
||||
3. 最多提出 30 个问题。
|
||||
description: `<context></context> 标记中是一段文本,学习它们,并整理学习成果。
|
||||
|
||||
学习要求:
|
||||
- 提出问题并给出每个问题的答案。
|
||||
- 答案需详细完整,给出相关原文描述。答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 markdown 元素。
|
||||
- 最多提出 30 个问题。
|
||||
`,
|
||||
fixedText: `最后,你需要按下面的格式返回多个问题和答案:
|
||||
Q1: 问题。
|
||||
@@ -11,7 +13,10 @@ Q2:
|
||||
A2:
|
||||
……
|
||||
|
||||
我的文本:"""{{text}}"""`
|
||||
<context>
|
||||
{{text}}
|
||||
<context/>
|
||||
`
|
||||
};
|
||||
|
||||
export const Prompt_ExtractJson = `你可以从 "对话记录" 中提取指定信息,并返回一个 JSON 对象,JSON 对象要求:
|
||||
|
Reference in New Issue
Block a user