Skip to content

Commit 84cf6b5

Browse files
v4.6.4 (#585)
* perf: md format * add systemConfig schema (#2) * fix: markdown * fix: root * fix: root --------- Co-authored-by: heheer <[email protected]>
1 parent b58249f commit 84cf6b5

File tree

8 files changed

+70
-21
lines changed

8 files changed

+70
-21
lines changed

packages/global/common/string/textSplitter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export const splitText2Chunks = (props: {
151151
const maxLen = splitTexts.length > 1 ? stepReges[step].maxLen : chunkLen;
152152
const minChunkLen = chunkLen * 0.7;
153153
const miniChunkLen = 30;
154+
// console.log(splitTexts, stepReges[step].reg);
154155

155156
const chunks: string[] = [];
156157
for (let i = 0; i < splitTexts.length; i++) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export enum SystemConfigsTypeEnum {
2+
fastgpt = 'fastgpt',
3+
fastgptPro = 'fastgptPro'
4+
}
5+
6+
export const SystemConfigsTypeMap = {
7+
[SystemConfigsTypeEnum.fastgpt]: {
8+
label: 'fastgpt'
9+
},
10+
[SystemConfigsTypeEnum.fastgptPro]: {
11+
label: 'fastgptPro'
12+
}
13+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { SystemConfigsTypeEnum } from "./constants";
2+
3+
export type SystemConfigsType = {
4+
_id: string;
5+
type: `${SystemConfigsTypeEnum}`;
6+
value: Record<string, any>;
7+
createTime: Date;
8+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { SystemConfigsType } from '@fastgpt/global/common/system/config/type';
2+
import { connectionMongo, type Model } from '../../../common/mongo';
3+
import { SystemConfigsTypeMap } from '@fastgpt/global/common/system/config/constants';
4+
5+
const { Schema, model, models } = connectionMongo;
6+
7+
const collectionName = 'systemConfigs';
8+
const systemConfigSchema = new Schema({
9+
type: {
10+
type: String,
11+
required: true,
12+
enum: Object.keys(SystemConfigsTypeMap)
13+
},
14+
value: {
15+
type: Object,
16+
required: true
17+
},
18+
createTime: {
19+
type: Date,
20+
default: () => new Date()
21+
}
22+
})
23+
24+
try {
25+
systemConfigSchema.index({ createTime: -1 }, { expireAfterSeconds: 90 * 24 * 60 * 60 });
26+
} catch (error) {
27+
console.log(error);
28+
}
29+
30+
export const MongoSystemConfigs: Model<SystemConfigsType>=
31+
models[collectionName] || model(collectionName, systemConfigSchema);
32+
MongoSystemConfigs.syncIndexes();

packages/service/support/permission/controller.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export async function parseHeaderCert({
151151
authType: AuthUserTypeEnum.root
152152
};
153153
}
154+
// apikey: abandon
154155
if (authApiKey && apikey) {
155156
// apikey
156157
const parseResult = await authOpenApiKey({ apikey });
@@ -164,20 +165,8 @@ export async function parseHeaderCert({
164165
};
165166
}
166167

167-
return {
168-
uid: '',
169-
teamId: '',
170-
tmbId: '',
171-
appId: '',
172-
openApiKey: '',
173-
authType: AuthUserTypeEnum.token
174-
};
175-
})();
176-
177-
// not rootUser and no uid, reject request
178-
if (!rootkey && !uid && !teamId && !tmbId) {
179168
return Promise.reject(ERROR_ENUM.unAuthorization);
180-
}
169+
})();
181170

182171
return {
183172
userId: String(uid),

projects/app/src/components/Markdown/CodeLight.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ const CodeLight = ({
296296
}) => {
297297
const { copyData } = useCopyData();
298298

299-
if (!inline && match) {
299+
if (!inline) {
300300
return (
301301
<Box my={3} borderRadius={'md'} overflow={'overlay'} backgroundColor={'#222'}>
302302
<Flex

projects/app/src/components/Markdown/index.module.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,9 @@
308308
}
309309
.markdown code,
310310
.markdown tt {
311-
border: 1px solid #eaeaea;
312-
border-radius: 3px 3px 3px 3px;
311+
border: 1px solid #dee0e2;
312+
background-color: #f4f6f8;
313+
border-radius: 3px;
313314
margin: 0 2px;
314315
padding: 0 5px;
315316
}

projects/app/src/global/core/prompt/agent.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
export const Prompt_AgentQA = {
2-
description: `我会给你一段文本,学习它们,并整理学习成果,要求为:
3-
1. 提出问题并给出每个问题的答案。
4-
2. 每个答案都要详细完整,给出相关原文描述,答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 markdown 元素。
5-
3. 最多提出 30 个问题。
2+
description: `<context></context> 标记中是一段文本,学习它们,并整理学习成果。
3+
4+
学习要求:
5+
- 提出问题并给出每个问题的答案。
6+
- 答案需详细完整,给出相关原文描述。答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 markdown 元素。
7+
- 最多提出 30 个问题。
68
`,
79
fixedText: `最后,你需要按下面的格式返回多个问题和答案:
810
Q1: 问题。
@@ -11,7 +13,10 @@ Q2:
1113
A2:
1214
……
1315
14-
我的文本:"""{{text}}"""`
16+
<context>
17+
{{text}}
18+
<context/>
19+
`
1520
};
1621

1722
export const Prompt_ExtractJson = `你可以从 "对话记录" 中提取指定信息,并返回一个 JSON 对象,JSON 对象要求:

0 commit comments

Comments
 (0)