From 2822ff3f974addf21eb96d29f44a91c845ce1ef3 Mon Sep 17 00:00:00 2001 From: balibabu Date: Wed, 20 Nov 2024 16:35:21 +0800 Subject: [PATCH 1/3] Feat: merge the begin operator's url and file into one field #3355 (#3521) ### What problem does this PR solve? Feat: merge the begin operator's url and file into one field #3355 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/pages/flow/constant.tsx | 3 - .../form/generate-form/dynamic-parameters.tsx | 1 - web/src/pages/flow/run-drawer/index.tsx | 157 ++++++------------ 3 files changed, 50 insertions(+), 111 deletions(-) diff --git a/web/src/pages/flow/constant.tsx b/web/src/pages/flow/constant.tsx index 173de2c0e55..132fbd1101b 100644 --- a/web/src/pages/flow/constant.tsx +++ b/web/src/pages/flow/constant.tsx @@ -45,7 +45,6 @@ import { import upperFirst from 'lodash/upperFirst'; import { CloudUpload, - Link2, ListOrdered, OptionIcon, TextCursorInput, @@ -2876,7 +2875,6 @@ export enum BeginQueryType { File = 'file', Integer = 'integer', Boolean = 'boolean', - Url = 'url', } export const BeginQueryTypeIconMap = { @@ -2886,5 +2884,4 @@ export const BeginQueryTypeIconMap = { [BeginQueryType.File]: CloudUpload, [BeginQueryType.Integer]: ListOrdered, [BeginQueryType.Boolean]: ToggleLeft, - [BeginQueryType.Url]: Link2, }; diff --git a/web/src/pages/flow/form/generate-form/dynamic-parameters.tsx b/web/src/pages/flow/form/generate-form/dynamic-parameters.tsx index 96e9ed28f43..427ce04ab0a 100644 --- a/web/src/pages/flow/form/generate-form/dynamic-parameters.tsx +++ b/web/src/pages/flow/form/generate-form/dynamic-parameters.tsx @@ -36,7 +36,6 @@ const DynamicParameters = ({ nodeId }: IProps) => { title: t('key'), dataIndex: 'key', key: 'key', - width: 50, onCell: (record: IGenerateParameter) => ({ record, editable: true, diff --git a/web/src/pages/flow/run-drawer/index.tsx b/web/src/pages/flow/run-drawer/index.tsx index 5dda620fb48..dda626e01a1 100644 --- a/web/src/pages/flow/run-drawer/index.tsx +++ b/web/src/pages/flow/run-drawer/index.tsx @@ -5,11 +5,10 @@ import { useHandleSubmittable } from '@/hooks/login-hooks'; import { IModalProps } from '@/interfaces/common'; import api from '@/utils/api'; import { getAuthorization } from '@/utils/authorization-util'; -import { InboxOutlined } from '@ant-design/icons'; +import { UploadOutlined } from '@ant-design/icons'; import { Button, Drawer, - Flex, Form, FormItemProps, Input, @@ -19,7 +18,6 @@ import { Upload, } from 'antd'; import { pick } from 'lodash'; -import { Link2, Trash2 } from 'lucide-react'; import React, { useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { BeginQueryType } from '../constant'; @@ -33,6 +31,7 @@ import { getDrawerWidth } from '../utils'; import { PopoverForm } from './popover-form'; import { UploadChangeParam, UploadFile } from 'antd/es/upload'; +import { Link } from 'lucide-react'; import styles from './index.less'; const RunDrawer = ({ @@ -60,18 +59,6 @@ const RunDrawer = ({ [setRecord, showPopover], ); - const handleRemoveUrl = useCallback( - (key: number, index: number) => () => { - const list: any[] = form.getFieldValue(key); - - form.setFieldValue( - key, - list.filter((_, idx) => idx !== index), - ); - }, - [form], - ); - const getBeginNodeDataQuery = useGetBeginNodeDataQuery(); const query: BeginQuery[] = getBeginNodeDataQuery(); @@ -126,27 +113,47 @@ const RunDrawer = ({ ), [BeginQueryType.File]: ( - - -

- -

-

{t('fileManager.uploadTitle')}

-

- {t('fileManager.uploadDescription')} -

-
-
+ + +
+ + + + + + 0 ? 'mb-1' : ''} + noStyle + > + + + + +
+
+ +
), [BeginQueryType.Integer]: ( @@ -158,66 +165,11 @@ const RunDrawer = ({ ), - [BeginQueryType.Url]: ( - - 0 ? 'mb-1' : ''} - > - - - - - - - prevValues[idx] !== curValues[idx] - } - > - {({ getFieldValue }) => { - const urlInfo: { url: string; result: string }[] = - getFieldValue(idx) || []; - return urlInfo.length ? ( - - {urlInfo.map((u, index) => ( -
- - {u.url} - -
- ))} -
- ) : null; - }} -
-
- ), }; return BeginQueryTypeMap[q.type as BeginQueryType]; }, - [ - form, - handleRemoveUrl, - handleShowPopover, - onChange, - switchVisible, - t, - visible, - ], + [form, handleShowPopover, onChange, switchVisible, t, visible], ); const { handleRun } = useSaveGraphBeforeOpeningDebugDrawer(showChatModal!); @@ -239,20 +191,11 @@ const RunDrawer = ({ if (Array.isArray(value)) { nextValue = ``; - value.forEach((x, idx) => { - if (x?.originFileObj instanceof File) { - if (idx === 0) { - nextValue += `${x.name}\n\n${x.response?.data}\n\n`; - } else { - nextValue += `${x.response?.data}\n\n`; - } - } else { - if (idx === 0) { - nextValue += `${x.url}\n\n${x.result}\n\n`; - } else { - nextValue += `${x.result}\n\n`; - } - } + value.forEach((x) => { + nextValue += + x?.originFileObj instanceof File + ? `${x.name}\n${x.response?.data}\n----\n` + : `${x.url}\n${x.result}\n----\n`; }); } return { ...item, value: nextValue }; @@ -277,7 +220,7 @@ const RunDrawer = ({ const { basicForm } = forms; const urlInfo = basicForm.getFieldValue(currentRecord) || []; basicForm.setFieldsValue({ - [currentRecord]: [...urlInfo, values], + [currentRecord]: [...urlInfo, { ...values, name: values.url }], }); hidePopover(); } From 64f50992e0fc4dce73e79f8b951a02e31cb2d638 Mon Sep 17 00:00:00 2001 From: Zhichang Yu Date: Wed, 20 Nov 2024 17:09:28 +0800 Subject: [PATCH 2/3] Warning instead of exception on type mismatch (#3523) ### What problem does this PR solve? Warning instead of exception on type mismatch. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/ragflow_server.py | 5 +++-- rag/svr/task_executor.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/ragflow_server.py b/api/ragflow_server.py index db063da2cfc..056f0561017 100644 --- a/api/ragflow_server.py +++ b/api/ragflow_server.py @@ -14,8 +14,9 @@ # limitations under the License. # -from beartype.claw import beartype_packages -beartype_packages(["agent", "api", "deepdoc", "plugins", "rag", "ragflow_sdk"]) # <-- raise exceptions in your code +from beartype import BeartypeConf +from beartype.claw import beartype_all # <-- you didn't sign up for this +beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code import logging from api.utils.log_utils import initRootLogger diff --git a/rag/svr/task_executor.py b/rag/svr/task_executor.py index 8a38389d4c3..3a0a9302be9 100644 --- a/rag/svr/task_executor.py +++ b/rag/svr/task_executor.py @@ -13,8 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from beartype.claw import beartype_packages -beartype_packages(["agent", "api", "deepdoc", "plugins", "rag", "ragflow_sdk"]) # <-- raise exceptions in your code +from beartype import BeartypeConf +from beartype.claw import beartype_all # <-- you didn't sign up for this +beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code import logging import sys From f7fb18f2be4992a0874725a7def0bf46685f8c6c Mon Sep 17 00:00:00 2001 From: Zhichang Yu Date: Wed, 20 Nov 2024 17:43:16 +0800 Subject: [PATCH 3/3] Removed beartype (#3528) ### What problem does this PR solve? The beartype configuration of main(64f50992e0fc4dce73e79f8b951a02e31cb2d638) is: ``` from beartype import BeartypeConf from beartype.claw import beartype_all # <-- you didn't sign up for this beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code ``` ragflow_server failed at a third-party package: ``` (ragflow-py3.10) zhichyu@iris:~/github.com/infiniflow/ragflow$ rm -rf logs/* && bash docker/launch_backend_service.sh Starting task_executor.py for task 0 (Attempt 1) Starting ragflow_server.py (Attempt 1) Traceback (most recent call last): File "/home/zhichyu/github.com/infiniflow/ragflow/api/ragflow_server.py", line 22, in from api.utils.log_utils import initRootLogger File "/home/zhichyu/github.com/infiniflow/ragflow/api/utils/__init__.py", line 25, in import requests File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/requests/__init__.py", line 43, in import urllib3 File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/__init__.py", line 15, in from ._base_connection import _TYPE_BODY File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/_base_connection.py", line 5, in from .util.connection import _TYPE_SOCKET_OPTIONS File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/util/__init__.py", line 4, in from .connection import is_connection_dropped File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/util/connection.py", line 7, in from .timeout import _DEFAULT_TIMEOUT, _TYPE_TIMEOUT File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/util/timeout.py", line 20, in _DEFAULT_TIMEOUT: Final[_TYPE_DEFAULT] = _TYPE_DEFAULT.token NameError: name 'Final' is not defined Traceback (most recent call last): File "/home/zhichyu/github.com/infiniflow/ragflow/rag/svr/task_executor.py", line 22, in from api.utils.log_utils import initRootLogger File "/home/zhichyu/github.com/infiniflow/ragflow/api/utils/__init__.py", line 25, in import requests File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/requests/__init__.py", line 43, in import urllib3 File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/__init__.py", line 15, in from ._base_connection import _TYPE_BODY File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/_base_connection.py", line 5, in from .util.connection import _TYPE_SOCKET_OPTIONS File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/util/__init__.py", line 4, in from .connection import is_connection_dropped File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/util/connection.py", line 7, in from .timeout import _DEFAULT_TIMEOUT, _TYPE_TIMEOUT File "/home/zhichyu/github.com/infiniflow/ragflow/.venv/lib/python3.10/site-packages/urllib3/util/timeout.py", line 20, in _DEFAULT_TIMEOUT: Final[_TYPE_DEFAULT] = _TYPE_DEFAULT.token NameError: name 'Final' is not defined ``` This third-package is out of our control. I have to remove beartype entirely. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/ragflow_server.py | 6 +++--- rag/svr/task_executor.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/ragflow_server.py b/api/ragflow_server.py index 056f0561017..69218d6f0aa 100644 --- a/api/ragflow_server.py +++ b/api/ragflow_server.py @@ -14,9 +14,9 @@ # limitations under the License. # -from beartype import BeartypeConf -from beartype.claw import beartype_all # <-- you didn't sign up for this -beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code +# from beartype import BeartypeConf +# from beartype.claw import beartype_all # <-- you didn't sign up for this +# beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code import logging from api.utils.log_utils import initRootLogger diff --git a/rag/svr/task_executor.py b/rag/svr/task_executor.py index 3a0a9302be9..3a8972a1d8c 100644 --- a/rag/svr/task_executor.py +++ b/rag/svr/task_executor.py @@ -12,10 +12,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# -from beartype import BeartypeConf -from beartype.claw import beartype_all # <-- you didn't sign up for this -beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code + +# from beartype import BeartypeConf +# from beartype.claw import beartype_all # <-- you didn't sign up for this +# beartype_all(conf=BeartypeConf(violation_type=UserWarning)) # <-- emit warnings from all code import logging import sys