Skip to content

Commit

Permalink
v4.6.4 (#585)
Browse files Browse the repository at this point in the history
* perf: md format

* add systemConfig schema (#2)

* fix: markdown

* fix: root

* fix: root

---------

Co-authored-by: heheer <[email protected]>
  • Loading branch information
c121914yu and newfish-cmyk authored Dec 8, 2023
1 parent b58249f commit 84cf6b5
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/global/common/string/textSplitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
13 changes: 13 additions & 0 deletions packages/global/common/system/config/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export enum SystemConfigsTypeEnum {
fastgpt = 'fastgpt',
fastgptPro = 'fastgptPro'
}

export const SystemConfigsTypeMap = {
[SystemConfigsTypeEnum.fastgpt]: {
label: 'fastgpt'
},
[SystemConfigsTypeEnum.fastgptPro]: {
label: 'fastgptPro'
}
};
8 changes: 8 additions & 0 deletions packages/global/common/system/config/type.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { SystemConfigsTypeEnum } from "./constants";

export type SystemConfigsType = {
_id: string;
type: `${SystemConfigsTypeEnum}`;
value: Record<string, any>;
createTime: Date;
};
32 changes: 32 additions & 0 deletions packages/service/common/system/config/schema.ts
Original file line number Diff line number Diff line change
@@ -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();
15 changes: 2 additions & 13 deletions packages/service/support/permission/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export async function parseHeaderCert({
authType: AuthUserTypeEnum.root
};
}
// apikey: abandon
if (authApiKey && apikey) {
// apikey
const parseResult = await authOpenApiKey({ apikey });
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/components/Markdown/CodeLight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions projects/app/src/components/Markdown/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 10 additions & 5 deletions projects/app/src/global/core/prompt/agent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export const Prompt_AgentQA = {
description: `我会给你一段文本,学习它们,并整理学习成果,要求为:
1. 提出问题并给出每个问题的答案。
2. 每个答案都要详细完整,给出相关原文描述,答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 markdown 元素。
3. 最多提出 30 个问题。
description: `<context></context> 标记中是一段文本,学习它们,并整理学习成果。
学习要求:
- 提出问题并给出每个问题的答案。
- 答案需详细完整,给出相关原文描述。答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 markdown 元素。
- 最多提出 30 个问题。
`,
fixedText: `最后,你需要按下面的格式返回多个问题和答案:
Q1: 问题。
Expand All @@ -11,7 +13,10 @@ Q2:
A2:
……
我的文本:"""{{text}}"""`
<context>
{{text}}
<context/>
`
};

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

0 comments on commit 84cf6b5

Please sign in to comment.