Skip to content

Commit

Permalink
feat: chat slider support folder (#1759)
Browse files Browse the repository at this point in the history
* feat: docker-compose version

* feat: chat slider support folder

* lazy behavior

* pref: code sandbox size
  • Loading branch information
c121914yu authored Jun 13, 2024
1 parent 6385794 commit f7f4a8d
Show file tree
Hide file tree
Showing 20 changed files with 336 additions and 152 deletions.
2 changes: 1 addition & 1 deletion docSite/content/zh-cn/docs/development/upgrading/484.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: 'V4.8.4(进行中)'
title: 'V4.8.4'
description: 'FastGPT V4.8.4 更新说明'
icon: 'upgrade'
draft: false
Expand Down
8 changes: 4 additions & 4 deletions files/docker/docker-compose-milvus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ services:
# fastgpt
sandbox:
container_name: sandbox
image: ghcr.io/labring/fastgpt-sandbox:v4.8.3 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.3 # 阿里云
image: ghcr.io/labring/fastgpt-sandbox:v4.8.4 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.4 # 阿里云
networks:
- fastgpt
restart: always
fastgpt:
container_name: fastgpt
image: ghcr.io/labring/fastgpt:v4.8.3 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.3 # 阿里云
image: ghcr.io/labring/fastgpt:v4.8.4 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.4 # 阿里云
ports:
- 3000:3000
networks:
Expand Down
8 changes: 4 additions & 4 deletions files/docker/docker-compose-pgvector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ services:
# fastgpt
sandbox:
container_name: sandbox
image: ghcr.io/labring/fastgpt-sandbox:v4.8.3 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.3 # 阿里云
image: ghcr.io/labring/fastgpt-sandbox:v4.8.4 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.4 # 阿里云
networks:
- fastgpt
restart: always
fastgpt:
container_name: fastgpt
image: ghcr.io/labring/fastgpt:v4.8.3 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.3 # 阿里云
image: ghcr.io/labring/fastgpt:v4.8.4 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.4 # 阿里云
ports:
- 3000:3000
networks:
Expand Down
8 changes: 4 additions & 4 deletions files/docker/docker-compose-zilliz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ services:
wait $$!
sandbox:
container_name: sandbox
image: ghcr.io/labring/fastgpt-sandbox:v4.8.3 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.3 # 阿里云
image: ghcr.io/labring/fastgpt-sandbox:v4.8.4 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.4 # 阿里云
networks:
- fastgpt
restart: always
fastgpt:
container_name: fastgpt
image: ghcr.io/labring/fastgpt:v4.8.3 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.3 # 阿里云
image: ghcr.io/labring/fastgpt:v4.8.4 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.4 # 阿里云
ports:
- 3000:3000
networks:
Expand Down
1 change: 1 addition & 0 deletions packages/web/components/common/Icon/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const iconPaths = {
'common/routePushLight': () => import('./icons/common/routePushLight.svg'),
'common/saveFill': () => import('./icons/common/saveFill.svg'),
'common/searchLight': () => import('./icons/common/searchLight.svg'),
'common/select': () => import('./icons/common/select.svg'),
'common/selectLight': () => import('./icons/common/selectLight.svg'),
'common/settingLight': () => import('./icons/common/settingLight.svg'),
'common/text/t': () => import('./icons/common/text/t.svg'),
Expand Down
4 changes: 4 additions & 0 deletions packages/web/components/common/Icon/icons/common/select.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion packages/web/components/common/MyMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ const MyMenu = ({
}, [offset]);

return (
<Menu offset={computeOffset} isOpen={isOpen} autoSelect={false} direction={'ltr'} isLazy>
<Menu
offset={computeOffset}
isOpen={isOpen}
autoSelect={false}
direction={'ltr'}
isLazy
lazyBehavior={'keepMounted'}
>
<Box
ref={ref}
onMouseEnter={() => {
Expand Down
48 changes: 48 additions & 0 deletions packages/web/components/common/MyPopover/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';
import {
Popover,
PopoverTrigger,
PopoverContent,
useDisclosure,
PlacementWithLogical
} from '@chakra-ui/react';

const MyPopover = ({
Trigger,
placement,
offset,
trigger,
children
}: {
Trigger: React.ReactNode;
placement?: PlacementWithLogical;
offset?: [number, number];
trigger?: 'hover' | 'click';
children: (e: { onClose: () => void }) => React.ReactNode;
}) => {
const firstFieldRef = React.useRef(null);

const { onOpen, onClose, isOpen } = useDisclosure();

return (
<Popover
isOpen={isOpen}
initialFocusRef={firstFieldRef}
onOpen={onOpen}
onClose={onClose}
placement={placement}
offset={offset}
closeOnBlur={false}
trigger={trigger}
openDelay={100}
closeDelay={100}
isLazy
lazyBehavior="keepMounted"
>
<PopoverTrigger>{Trigger}</PopoverTrigger>
<PopoverContent p={4}>{children({ onClose })}</PopoverContent>
</Popover>
);
};

export default MyPopover;
2 changes: 2 additions & 0 deletions projects/app/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"Last use time": "Last use time",
"Load Failed": "Load Failed",
"Loading": "Loading...",
"More": "More",
"More settings": "More settings",
"Move": "Move",
"MultipleRowSelect": {
Expand Down Expand Up @@ -430,6 +431,7 @@
"Quote": "Quote",
"Quote Amount": "Dataset quotes ({{amount}} items)",
"Read Mark Description": "View introduction to marking function",
"Recent use": "Recent use",
"Record": "Voice input",
"Restart": "Restart conversation",
"Select File": "Select file",
Expand Down
2 changes: 2 additions & 0 deletions projects/app/i18n/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"Last use time": "最后使用时间",
"Load Failed": "加载失败",
"Loading": "加载中...",
"More": "更多",
"More settings": "更多设置",
"Move": "移动",
"MultipleRowSelect": {
Expand Down Expand Up @@ -431,6 +432,7 @@
"Quote": "引用",
"Quote Amount": "知识库引用({{amount}}条)",
"Read Mark Description": "查看标注功能介绍",
"Recent use": "最近使用",
"Record": "语音输入",
"Restart": "重开对话",
"Select File": "选择文件",
Expand Down
21 changes: 13 additions & 8 deletions projects/app/public/docs/versionIntro.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
### FastGPT V4.8.2
### FastGPT V4.8.4

1. 新增 - 应用使用新权限系统。
2. 新增 - 应用支持文件夹。
3. 优化 - 文本分割增加连续换行、制表符清除,避免大文本性能问题。
4. 重要修复 - 修复系统插件运行池数据污染问题,由于从内存获取,会导致全局污染。
5. 修复 - Debug 模式下,相同 source 和 target 内容,导致连线显示异常。
6. 修复 - 定时执行初始化错误。
7. 修复 - 应用调用传参异常。
8. 修复 - ctrl + cv 复杂节点时,nodeId错误。
9. 调整组件库全局theme。

------

- 新增 - 知识库重新选择向量模型重建
- 新增 - 对话框支持问题模糊检索提示,可自定义预设问题词库
- 新增 - js代码运行节点
- 新增 - 外部文件源知识库: [点击查看文档](https://doc.fastai.site/docs/course/externalfile/)
- 新增 - 内容提取节点增加完全提取成功输出
- 新增 - HTTP节点增加错误输出,可以自行判断处理
- 优化 - 插件输入的 debug 模式,支持全量参数输入渲染
- [点击查看高级编排介绍文档](https://doc.fastgpt.in/docs/workflow/intro)
- [使用文档](https://doc.fastgpt.in/docs/intro/)
- [点击查看商业版](https://doc.fastgpt.in/docs/commercial/)
1 change: 0 additions & 1 deletion projects/app/src/components/Avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const Avatar = ({ w = '30px', src, ...props }: ImageProps) => {
alt=""
w={w}
h={w}
p={'1px'}
src={src || LOGO_ICON}
{...props}
/>
Expand Down
88 changes: 56 additions & 32 deletions projects/app/src/components/common/folder/SelectOneResource.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Box, Flex } from '@chakra-ui/react';
import React, { useMemo, useState } from 'react';
import { Box, BoxProps, Flex } from '@chakra-ui/react';
import {
GetResourceFolderListProps,
GetResourceListItemResponse,
Expand All @@ -10,24 +10,43 @@ import Loading from '@fastgpt/web/components/common/MyLoading';
import Avatar from '@/components/Avatar';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import { useMemoizedFn } from 'ahooks';
import { FolderImgUrl } from '@fastgpt/global/common/file/image/constants';
import { useTranslation } from 'next-i18next';

type ResourceItemType = GetResourceListItemResponse & {
open: boolean;
children?: ResourceItemType[];
};

const rootId = 'root';

const SelectOneResource = ({
server,
value,
onSelect
onSelect,
maxH = ['80vh', '600px']
}: {
server: (e: GetResourceFolderListProps) => Promise<GetResourceListItemResponse[]>;
value?: ParentIdType;
onSelect: (e?: string) => any;
maxH?: BoxProps['maxH'];
}) => {
const { t } = useTranslation();
const [dataList, setDataList] = useState<ResourceItemType[]>([]);
const [requestingIdList, setRequestingIdList] = useState<ParentIdType[]>([]);

const concatRoot = useMemo(() => {
const root: ResourceItemType = {
id: rootId,
open: true,
avatar: FolderImgUrl,
name: t('common.folder.Root Path'),
isFolder: true,
children: dataList
};
return [root];
}, [dataList, t]);

const { runAsync: requestServer } = useRequest2((e: GetResourceFolderListProps) => {
if (requestingIdList.includes(e.parentId)) return Promise.reject(null);

Expand Down Expand Up @@ -59,7 +78,7 @@ const SelectOneResource = ({
alignItems={'center'}
cursor={'pointer'}
py={1}
pl={`${1.25 * index + 0.5}rem`}
pl={index === 0 ? '0.5rem' : `${1.75 * (index - 1) + 0.5}rem`}
pr={2}
borderRadius={'md'}
_hover={{
Expand All @@ -72,6 +91,7 @@ const SelectOneResource = ({
}
: {
onClick: async () => {
if (item.id === rootId) return;
// folder => open(request children) or close
if (item.isFolder) {
if (!item.children) {
Expand All @@ -90,33 +110,31 @@ const SelectOneResource = ({
}
})}
>
<Flex
alignItems={'center'}
justifyContent={'center'}
visibility={
item.isFolder && (!item.children || item.children.length > 0)
? 'visible'
: 'hidden'
}
w={'1.25rem'}
h={'1.25rem'}
cursor={'pointer'}
borderRadius={'xs'}
_hover={{
bg: 'rgba(31, 35, 41, 0.08)'
}}
>
<MyIcon
name={
requestingIdList.includes(item.id)
? 'common/loading'
: 'common/rightArrowFill'
}
w={'14px'}
color={'myGray.500'}
transform={item.open ? 'rotate(90deg)' : 'none'}
/>
</Flex>
{index !== 0 && (
<Flex
alignItems={'center'}
justifyContent={'center'}
visibility={item.isFolder ? 'visible' : 'hidden'}
w={'1.25rem'}
h={'1.25rem'}
cursor={'pointer'}
borderRadius={'xs'}
_hover={{
bg: 'rgba(31, 35, 41, 0.08)'
}}
>
<MyIcon
name={
requestingIdList.includes(item.id)
? 'common/loading'
: 'common/rightArrowFill'
}
w={'14px'}
color={'myGray.500'}
transform={item.open ? 'rotate(90deg)' : 'none'}
/>
</Flex>
)}
<Avatar ml={index !== 0 ? '0.5rem' : 0} src={item.avatar} w={'1.25rem'} />
<Box fontSize={'sm'} ml={2}>
{item.name}
Expand All @@ -134,7 +152,13 @@ const SelectOneResource = ({
}
);

return loading ? <Loading fixed={false} /> : <Render list={dataList} />;
return loading ? (
<Loading fixed={false} />
) : (
<Box maxH={maxH} overflow={'auto'}>
<Render list={concatRoot} />
</Box>
);
};

export default SelectOneResource;
Loading

0 comments on commit f7f4a8d

Please sign in to comment.