Skip to content

Commit f6552d0

Browse files
authored
v4.4.5-2 (#355)
1 parent 38d4db5 commit f6552d0

File tree

48 files changed

+535
-398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+535
-398
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: '升级到 V4.4.5'
3+
description: 'FastGPT 从旧版本升级到 V4.4.5 操作指南'
4+
icon: 'upgrade'
5+
draft: false
6+
toc: true
7+
weight: 992
8+
---
9+
10+
## 执行初始化 API
11+
12+
发起 1 个 HTTP 请求(记得携带 `headers.rootkey`,这个值是环境变量里的)
13+
14+
1. https://xxxxx/api/admin/initv445
15+
16+
```bash
17+
curl --location --request POST 'https://{{host}}/api/admin/initv445' \
18+
--header 'rootkey: {{rootkey}}' \
19+
--header 'Content-Type: application/json'
20+
```
21+
22+
初始化了 variable 模块,将其合并到用户引导模块中。
23+

projects/app/src/service/lib/openai.ts renamed to packages/core/aiApi/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { UserModelSchema } from '@/types/mongoSchema';
1+
import { UserModelSchema } from '../user/type';
22
import { Configuration, OpenAIApi } from 'openai';
33

44
export const openaiBaseUrl = process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1';

packages/core/aiApi/constant.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ChatCompletionRequestMessageRoleEnum } from 'openai';

packages/core/aiApi/type.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type { CreateChatCompletionRequest, ChatCompletionRequestMessage } from 'openai';

packages/core/init.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import tunnel from 'tunnel';
2+
3+
export function initHttpAgent() {
4+
// proxy obj
5+
if (process.env.AXIOS_PROXY_HOST && process.env.AXIOS_PROXY_PORT) {
6+
global.httpsAgent = tunnel.httpsOverHttp({
7+
proxy: {
8+
host: process.env.AXIOS_PROXY_HOST,
9+
port: +process.env.AXIOS_PROXY_PORT
10+
}
11+
});
12+
}
13+
}

packages/core/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
22
"name": "@fastgpt/core",
3-
"version": "1.0.0"
3+
"version": "1.0.0",
4+
"dependencies": {
5+
"openai": "^3.3.0",
6+
"tunnel": "^0.0.6"
7+
},
8+
"devDependencies": {
9+
"@types/tunnel": "^0.0.4"
10+
}
411
}

packages/core/types/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { Agent } from 'http';
2+
3+
declare global {
4+
var httpsAgent: Agent;
5+
}

packages/core/user/type.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export type UserModelSchema = {
2+
_id: string;
3+
username: string;
4+
password: string;
5+
avatar: string;
6+
balance: number;
7+
promotionRate: number;
8+
inviterId?: string;
9+
openaiKey: string;
10+
createTime: number;
11+
timezone: string;
12+
openaiAccount?: {
13+
key: string;
14+
baseUrl: string;
15+
};
16+
limit: {
17+
exportKbTime?: Date;
18+
};
19+
};

pnpm-lock.yaml

Lines changed: 15 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/app/package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"@chakra-ui/system": "^2.5.8",
1515
"@emotion/react": "^11.10.6",
1616
"@emotion/styled": "^11.10.6",
17+
"@fastgpt/common": "workspace:*",
18+
"@fastgpt/core": "workspace:*",
19+
"@fastgpt/support": "workspace:*",
1720
"@mozilla/readability": "^0.4.4",
1821
"@tanstack/react-query": "^4.24.10",
1922
"@types/nprogress": "^0.2.0",
@@ -45,7 +48,6 @@
4548
"next-i18next": "^14.0.3",
4649
"nextjs-cors": "^2.1.2",
4750
"nprogress": "^0.2.0",
48-
"openai": "^3.3.0",
4951
"papaparse": "^5.4.1",
5052
"pg": "^8.10.0",
5153
"pg-query-stream": "^4.5.3",
@@ -64,13 +66,9 @@
6466
"request-ip": "^3.3.0",
6567
"sass": "^1.58.3",
6668
"timezones-list": "^3.0.2",
67-
"tunnel": "^0.0.6",
6869
"winston": "^3.10.0",
6970
"winston-mongodb": "^5.1.1",
70-
"zustand": "^4.3.5",
71-
"@fastgpt/support": "workspace:*",
72-
"@fastgpt/common": "workspace:*",
73-
"@fastgpt/core": "workspace:*"
71+
"zustand": "^4.3.5"
7472
},
7573
"devDependencies": {
7674
"@svgr/webpack": "^6.5.1",
@@ -89,7 +87,6 @@
8987
"@types/react-dom": "18.0.11",
9088
"@types/react-syntax-highlighter": "^15.5.6",
9189
"@types/request-ip": "^0.0.37",
92-
"@types/tunnel": "^0.0.3",
9390
"eslint": "8.34.0",
9491
"eslint-config-next": "13.1.6",
9592
"typescript": "4.9.5"

projects/app/public/locales/en/common.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,10 @@
237237
"outlink": {
238238
"Copy Iframe": "Copy Iframe",
239239
"Copy Link": "Copy",
240+
"Create API Key": "Create Key",
240241
"Create Link": "Create Link",
241242
"Delete Link": "Delete",
243+
"Edit API Key": "Edit Key",
242244
"Edit Ifrme Link": "Edit Iframe Link",
243245
"Edit Link": "Edit",
244246
"Edit Share Window": "Edit Share Window",

projects/app/public/locales/zh/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,17 @@
230230
"Tools": "工具"
231231
},
232232
"openapi": {
233-
"app key tips": "这些 Key 已有当前应用标识,可以直接外部接入使用。",
233+
"app key tips": "这些 key 已有当前应用标识,具体使用可参考文档",
234234
"key alias": "key 的别名,仅用于展示",
235235
"key tips": "你可以使用 API 秘钥访问一些特定的接口"
236236
},
237237
"outlink": {
238238
"Copy Iframe": "复制嵌入",
239239
"Copy Link": "复制",
240+
"Create API Key": "创建新 Key",
240241
"Create Link": "创建链接",
241242
"Delete Link": "删除链接",
243+
"Edit API Key": "编辑 Key 信息",
242244
"Edit Ifrme Link": "更新嵌入链接",
243245
"Edit Link": "编辑",
244246
"Edit Share Window": "更新分享窗口",

projects/app/src/components/ChatBox/utils.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ import { FlowModuleTypeEnum } from '@/constants/flow';
33
import { getChatModel } from '@/service/utils/data';
44
import { AppModuleItemType, VariableItemType } from '@/types/app';
55

6-
export const getSpecialModule = (modules: AppModuleItemType[]) => {
6+
export const getGuideModules = (modules: AppModuleItemType[]) => {
7+
const guideModules = modules.find((item) => item.flowType === FlowModuleTypeEnum.userGuide);
8+
79
const welcomeText: string =
8-
modules
9-
.find((item) => item.flowType === FlowModuleTypeEnum.userGuide)
10-
?.inputs?.find((item) => item.key === SystemInputEnum.welcomeText)?.value || '';
10+
guideModules?.inputs?.find((item) => item.key === SystemInputEnum.welcomeText)?.value || '';
1111

1212
const variableModules: VariableItemType[] =
13-
modules
14-
.find((item) => item.flowType === FlowModuleTypeEnum.variable)
15-
?.inputs.find((item) => item.key === SystemInputEnum.variables)?.value || [];
13+
guideModules?.inputs.find((item) => item.key === SystemInputEnum.variables)?.value || [];
1614

1715
return {
1816
welcomeText,

projects/app/src/components/Loading/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import React from 'react';
22
import { Spinner, Flex, Box } from '@chakra-ui/react';
33

4-
const Loading = ({ fixed = true, text = '' }: { fixed?: boolean; text?: string }) => {
4+
const Loading = ({
5+
fixed = true,
6+
text = '',
7+
bg = 'rgba(255,255,255,0.5)'
8+
}: {
9+
fixed?: boolean;
10+
text?: string;
11+
bg?: string;
12+
}) => {
513
return (
614
<Flex
715
position={fixed ? 'fixed' : 'absolute'}
816
zIndex={1000}
9-
backgroundColor={'rgba(255,255,255,0.5)'}
17+
bg={bg}
1018
top={0}
1119
left={0}
1220
right={0}

projects/app/src/components/support/apikey/Table.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const ApiKeyTable = ({ tips, appId }: { tips: string; appId?: string }) => {
106106
onClick={() => copyData(baseUrl, '已复制 API 地址')}
107107
>
108108
<Box border={theme.borders.md} px={2} borderRadius={'md'} fontSize={'sm'}>
109-
API地址
109+
API根地址
110110
</Box>
111111
<Box ml={2} color={'myGray.900'} fontSize={['sm', 'md']}>
112112
{baseUrl}
@@ -292,7 +292,7 @@ function EditKeyModal({
292292
});
293293

294294
return (
295-
<MyModal isOpen={true} title={isEdit ? t('outlink.Edit Link') : t('outlink.Create Link')}>
295+
<MyModal isOpen={true} title={isEdit ? t('outlink.Edit API Key') : t('outlink.Create API Key')}>
296296
<ModalBody>
297297
<Flex alignItems={'center'}>
298298
<Box flex={'0 0 90px'}>{t('Name')}:</Box>

projects/app/src/constants/flow/ModuleTemplate.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ export const ChatModelLimitTip =
2424
export const userGuideTip = '可以添加特殊的对话前后引导模块,更好的让用户进行对话';
2525
export const welcomeTextTip =
2626
'每次对话开始前,发送一个初始内容。支持标准 Markdown 语法,可使用的额外标记:\n[快捷按键]: 用户点击后可以直接发送该问题';
27+
export const variableTip =
28+
'可以在对话开始前,要求用户填写一些内容作为本轮对话的特定变量。该模块位于开场引导之后。\n变量可以通过 {{变量key}} 的形式注入到其他模块 string 类型的输入中,例如:提示词、限定词等';
2729

2830
export const VariableModule: FlowModuleTemplateType = {
2931
flowType: FlowModuleTypeEnum.variable,
3032
logo: '/imgs/module/variable.png',
3133
name: '全局变量',
32-
intro: '可以在对话开始前,要求用户填写一些内容作为本轮对话的变量。该模块位于开场引导之后。',
34+
intro: variableTip,
3335
description:
3436
'全局变量可以通过 {{变量key}} 的形式注入到其他模块 string 类型的输入中,例如:提示词、限定词等',
3537
inputs: [
@@ -52,6 +54,12 @@ export const UserGuideModule: FlowModuleTemplateType = {
5254
key: SystemInputEnum.welcomeText,
5355
type: FlowInputItemTypeEnum.input,
5456
label: '开场白'
57+
},
58+
{
59+
key: SystemInputEnum.variables,
60+
type: FlowInputItemTypeEnum.systemInput,
61+
label: '对话框变量',
62+
value: []
5563
}
5664
],
5765
outputs: []
@@ -476,7 +484,7 @@ export const ModuleTemplates = [
476484
},
477485
{
478486
label: '引导模块',
479-
list: [UserGuideModule, VariableModule]
487+
list: [UserGuideModule]
480488
},
481489
{
482490
label: '内容生成',
@@ -491,7 +499,19 @@ export const ModuleTemplates = [
491499
list: [ClassifyQuestionModule, ContextExtractModule, HttpModule]
492500
}
493501
];
494-
export const ModuleTemplatesFlat = ModuleTemplates.map((templates) => templates.list)?.flat();
502+
export const ModuleTemplatesFlat = [
503+
VariableModule,
504+
UserGuideModule,
505+
UserInputModule,
506+
HistoryModule,
507+
ChatModule,
508+
KBSearchModule,
509+
AnswerModule,
510+
ClassifyQuestionModule,
511+
ContextExtractModule,
512+
HttpModule,
513+
EmptyModule
514+
];
495515

496516
// template
497517
export const appTemplates: (AppItemType & { avatar: string; intro: string })[] = [

0 commit comments

Comments
 (0)