Skip to content

Commit

Permalink
v4.6.2 (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored Nov 28, 2023
1 parent e765c3b commit a74e1d7
Show file tree
Hide file tree
Showing 75 changed files with 1,138 additions and 416 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Install dependencies only when needed
FROM node:18.15-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat && npm install -g pnpm
RUN apk add libc6-compat && npm install -g pnpm
WORKDIR /app

ARG name
Expand Down
11 changes: 6 additions & 5 deletions docSite/content/docs/custom-models/chatglm2.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,19 @@ Authorization 为 sk-aaabbbcccdddeeefffggghhhiiijjjkkk。model 为刚刚在 One

## 接入 FastGPT

修改 config.json 配置文件,在 VectorModels 中加入 chatglm2 模型:
修改 config.json 配置文件,在 ChatModels 中加入 chatglm2 模型:

```json
"ChatModels": [
//已有模型
{
"model": "chatglm2",
"name": "chatglm2",
"maxToken": 8000,
"price": 0,
"quoteMaxToken": 4000,
"maxTemperature": 1.2,
"maxContext": 4000,
"maxResponse": 4000,
"quoteMaxToken": 2000,
"maxTemperature": 1,
"vision": false,
"defaultSystemChatPrompt": ""
}
]
Expand Down
4 changes: 3 additions & 1 deletion docSite/content/docs/development/openapi/dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ weight: 563
curl --location --request POST 'https://fastgpt.run/api/support/wallet/bill/createTrainingBill' \
--header 'Authorization: Bearer {{apikey}}' \
--header 'Content-Type: application/json' \
--data-raw ''
--data-raw '{
"name": "可选,自定义订单名称,例如:文档训练-fastgpt.docx"
}'
```

**响应结果**
Expand Down
2 changes: 1 addition & 1 deletion docSite/content/docs/installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ curl -O https://raw.githubusercontent.com/labring/FastGPT/main/projects/app/data

## 三、启动容器

修改`docker-compose.yml`中的`OPENAI_BASE_URL``CHAT_API_KEY`即可,对应为 API 的地址和 key。
修改`docker-compose.yml`中的`OPENAI_BASE_URL``CHAT_API_KEY`即可,对应为 API 的地址(别忘记加/v1)和 key。

```bash
# 在 docker-compose.yml 同级目录下执行
Expand Down
3 changes: 1 addition & 2 deletions packages/global/common/system/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ export type FeConfigsType = {
show_emptyChat?: boolean;
show_register?: boolean;
show_appStore?: boolean;
show_contact?: boolean;
show_git?: boolean;
show_pay?: boolean;
show_openai_account?: boolean;
show_promotion?: boolean;
hide_app_flow?: boolean;
concatMd?: string;
docUrl?: string;
openAPIDocUrl?: string;
systemTitle?: string;
authorText?: string;
googleClientVerKey?: string;
isPlus?: boolean;
oauth?: {
Expand Down
8 changes: 8 additions & 0 deletions packages/global/core/ai/model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export type VectorModelItemType = {
maxToken: number;
};

export type ReRankModelItemType = {
model: string;
name: string;
price: number;
requestUrl?: string;
requestAuth?: string;
};

export type AudioSpeechModelType = {
model: string;
name: string;
Expand Down
5 changes: 4 additions & 1 deletion packages/global/core/ai/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type {
FunctionModelItemType,
VectorModelItemType,
AudioSpeechModelType,
WhisperModelType
WhisperModelType,
ReRankModelItemType
} from './model.d';

export const defaultChatModels: ChatModelItemType[] = [
Expand Down Expand Up @@ -117,6 +118,8 @@ export const defaultVectorModels: VectorModelItemType[] = [
}
];

export const defaultReRankModels: ReRankModelItemType[] = [];

export const defaultAudioSpeechModels: AudioSpeechModelType[] = [
{
model: 'tts-1',
Expand Down
6 changes: 4 additions & 2 deletions packages/global/core/app/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PermissionTypeEnum } from '../../support/permission/constant';
import type { AIChatModuleProps, DatasetModuleProps } from '../module/node/type.d';
import { VariableInputEnum } from '../module/constants';
import { SelectedDatasetType } from '../module/api';
import { DatasetSearchModeEnum } from '../dataset/constant';

export interface AppSchema {
_id: string;
Expand All @@ -18,6 +19,7 @@ export interface AppSchema {
updateTime: number;
modules: ModuleItemType[];
permission: `${PermissionTypeEnum}`;
inited?: boolean;
}

export type AppListItemType = {
Expand Down Expand Up @@ -62,7 +64,7 @@ export type AppSimpleEditFormType = {
datasets: SelectedDatasetType;
similarity: number;
limit: number;
rerank: boolean;
searchMode: `${DatasetSearchModeEnum}`;
searchEmptyText: string;
};
userGuide: {
Expand Down Expand Up @@ -106,7 +108,7 @@ export type AppSimpleEditConfigTemplateType = {
datasets?: boolean;
similarity?: boolean;
limit?: boolean;
rerank?: boolean;
searchMode: `${DatasetSearchModeEnum}`;
searchEmptyText?: boolean;
};
userGuide?: {
Expand Down
10 changes: 5 additions & 5 deletions packages/global/core/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { FlowNodeInputItemType } from '../module/node/type.d';
import { getGuideModule, splitGuideModule } from '../module/utils';
import { defaultChatModels } from '../ai/model';
import { ModuleItemType } from '../module/type.d';
import { DatasetSearchModeEnum } from '../dataset/constant';

export const getDefaultAppForm = (templateId = 'fastgpt-universal'): AppSimpleEditFormType => {
const defaultChatModel = defaultChatModels[0];
Expand All @@ -25,7 +26,7 @@ export const getDefaultAppForm = (templateId = 'fastgpt-universal'): AppSimpleEd
similarity: 0.4,
limit: 5,
searchEmptyText: '',
rerank: false
searchMode: DatasetSearchModeEnum.embedding
},
userGuide: {
welcomeText: '',
Expand Down Expand Up @@ -91,10 +92,9 @@ export const appModules2Form = ({
module.inputs,
ModuleInputKeyEnum.datasetLimit
);
defaultAppForm.dataset.rerank = findInputValueByKey(
module.inputs,
ModuleInputKeyEnum.datasetStartReRank
);
defaultAppForm.dataset.searchMode =
findInputValueByKey(module.inputs, ModuleInputKeyEnum.datasetSearchMode) ||
DatasetSearchModeEnum.embedding;

// empty text
const emptyOutputs =
Expand Down
27 changes: 27 additions & 0 deletions packages/global/core/dataset/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,31 @@ export const TrainingTypeMap = {
// }
};

export enum DatasetSearchModeEnum {
embedding = 'embedding',
embeddingReRank = 'embeddingReRank',
embFullTextReRank = 'embFullTextReRank'
}

export const DatasetSearchModeMap = {
[DatasetSearchModeEnum.embedding]: {
icon: 'core/dataset/modeEmbedding',
title: 'core.dataset.search.mode.embedding',
desc: 'core.dataset.search.mode.embedding desc',
value: DatasetSearchModeEnum.embedding
},
[DatasetSearchModeEnum.embeddingReRank]: {
icon: 'core/dataset/modeEmbeddingRerank',
title: 'core.dataset.search.mode.embeddingReRank',
desc: 'core.dataset.search.mode.embeddingReRank desc',
value: DatasetSearchModeEnum.embeddingReRank
},
[DatasetSearchModeEnum.embFullTextReRank]: {
icon: 'core/dataset/modeEmbFTRerank',
title: 'core.dataset.search.mode.embFullTextReRank',
desc: 'core.dataset.search.mode.embFullTextReRank desc',
value: DatasetSearchModeEnum.embFullTextReRank
}
};

export const FolderAvatarSrc = '/imgs/files/folder.svg';
4 changes: 3 additions & 1 deletion packages/global/core/module/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ export enum ModuleInputKeyEnum {
datasetSelectList = 'datasets',
datasetSimilarity = 'similarity',
datasetLimit = 'limit',
datasetStartReRank = 'rerank',
datasetSearchMode = 'searchMode',
datasetParamsModal = 'datasetParamsModal',

// context extract
contextExtractInput = 'content',
Expand Down Expand Up @@ -98,5 +99,6 @@ export enum ModuleOutputKeyEnum {

export enum VariableInputEnum {
input = 'input',
textarea = 'textarea',
select = 'select'
}
2 changes: 2 additions & 0 deletions packages/global/core/module/node/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export enum FlowNodeInputTypeEnum {
selectChatModel = 'selectChatModel',
// dataset special input
selectDataset = 'selectDataset',
selectDatasetParamsModal = 'selectDatasetParamsModal',

hidden = 'hidden'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
flowType: FlowNodeTypeEnum.classifyQuestion,
avatar: '/imgs/module/cq.png',
name: '问题分类',
intro:
'根据用户的历史记录和当前问题判断该次提问的类型。可以添加多组问题类型,下面是一个模板例子:\n类型1: 打招呼\n类型2: 关于 laf 通用问题\n类型3: 关于 laf 代码问题\n类型4: 其他问题',
intro: `根据用户的历史记录和当前问题判断该次提问的类型。可以添加多组问题类型,下面是一个模板例子:
类型1: 打招呼
类型2: 关于商品“使用”问题
类型3: 关于商品“购买”问题
类型4: 其他问题`,
showStatus: true,
inputs: [
Input_Template_TFSwitch,
Expand Down
26 changes: 17 additions & 9 deletions packages/global/core/module/template/system/datasetSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../../constants';
import { Input_Template_TFSwitch, Input_Template_UserChatInput } from '../input';
import { Output_Template_Finish } from '../output';
import { DatasetSearchModeEnum } from '../../../dataset/constant';

export const DatasetSearchModule: FlowModuleTemplateType = {
id: FlowNodeTypeEnum.datasetSearchNode,
Expand All @@ -36,7 +37,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
},
{
key: ModuleInputKeyEnum.datasetSimilarity,
type: FlowNodeInputTypeEnum.slider,
type: FlowNodeInputTypeEnum.hidden,
label: '最低相关性',
value: 0.4,
valueType: ModuleDataTypeEnum.number,
Expand All @@ -52,7 +53,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
},
{
key: ModuleInputKeyEnum.datasetLimit,
type: FlowNodeInputTypeEnum.slider,
type: FlowNodeInputTypeEnum.hidden,
label: '单次搜索上限',
description: '最多取 n 条记录作为本次问题引用',
value: 5,
Expand All @@ -68,13 +69,20 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
showTargetInPlugin: false
},
{
key: ModuleInputKeyEnum.datasetStartReRank,
type: FlowNodeInputTypeEnum.switch,
label: '结果重排',
description: '将召回的结果进行进一步重排,可增加召回率',
plusField: true,
value: false,
valueType: ModuleDataTypeEnum.boolean,
key: ModuleInputKeyEnum.datasetSearchMode,
type: FlowNodeInputTypeEnum.hidden,
label: 'core.dataset.search.Mode',
valueType: ModuleDataTypeEnum.string,
showTargetInApp: false,
showTargetInPlugin: false,
value: DatasetSearchModeEnum.embedding
},
{
key: ModuleInputKeyEnum.datasetParamsModal,
type: FlowNodeInputTypeEnum.selectDatasetParamsModal,
label: '',
connected: false,
valueType: ModuleDataTypeEnum.any,
showTargetInApp: false,
showTargetInPlugin: false
},
Expand Down
4 changes: 3 additions & 1 deletion packages/global/core/module/template/system/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ export const HistoryModule: FlowModuleTemplateType = {
key: ModuleInputKeyEnum.historyMaxAmount,
type: FlowNodeInputTypeEnum.numberInput,
label: '最长记录数',
description:
'该记录数不代表模型可接收这么多的历史记录,具体可接收多少历史记录,取决于模型的能力,通常建议不要超过20条。',
value: 6,
valueType: ModuleDataTypeEnum.number,
min: 0,
max: 50,
max: 100,
showTargetInApp: false,
showTargetInPlugin: false
},
Expand Down
2 changes: 1 addition & 1 deletion packages/service/core/dataset/data/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const DatasetDataSchema = new Schema({
},
fullTextToken: {
type: String,
required: true
default: ''
},
indexes: {
type: [
Expand Down
8 changes: 4 additions & 4 deletions packages/service/support/permission/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,13 @@ export async function parseHeaderCert({
};
}
// root user
async function parseRootKey(rootKey?: string, userId = '') {
async function parseRootKey(rootKey?: string) {
if (!rootKey || !process.env.ROOT_KEY || rootKey !== process.env.ROOT_KEY) {
return Promise.reject(ERROR_ENUM.unAuthorization);
}
return userId;
}

const { cookie, token, apikey, rootkey, userid, authorization } = (req.headers ||
const { cookie, token, apikey, rootkey, authorization } = (req.headers ||
{}) as ReqHeaderAuthType;

const { uid, teamId, tmbId, appId, openApiKey, authType } = await (async () => {
Expand All @@ -129,9 +128,10 @@ export async function parseHeaderCert({
};
}
if (authRoot && rootkey) {
await parseRootKey(rootkey);
// root user
return {
uid: await parseRootKey(rootkey, userid),
uid: '',
teamId: '',
tmbId: '',
appId: '',
Expand Down
1 change: 1 addition & 0 deletions projects/app/data/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"maxToken": 3000
}
],
"ReRankModels": [],
"AudioSpeechModels": [
{
"model": "tts-1",
Expand Down
Loading

0 comments on commit a74e1d7

Please sign in to comment.