From c05e47ebc0017caba71f1787a10523a96070a53f Mon Sep 17 00:00:00 2001 From: -LAN- Date: Fri, 13 Jun 2025 09:42:02 +0800 Subject: [PATCH 1/5] refactor(sqlalchemy_workflow_execution_repository): Use the max funtion for getting next_sequence_number. (#20966) --- .../sqlalchemy_workflow_execution_repository.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/core/repositories/sqlalchemy_workflow_execution_repository.py b/api/core/repositories/sqlalchemy_workflow_execution_repository.py index 19086cffff..e5ead9dc56 100644 --- a/api/core/repositories/sqlalchemy_workflow_execution_repository.py +++ b/api/core/repositories/sqlalchemy_workflow_execution_repository.py @@ -6,7 +6,7 @@ import json import logging from typing import Optional, Union -from sqlalchemy import select +from sqlalchemy import func, select from sqlalchemy.engine import Engine from sqlalchemy.orm import sessionmaker @@ -151,11 +151,11 @@ class SQLAlchemyWorkflowExecutionRepository(WorkflowExecutionRepository): existing = session.scalar(select(WorkflowRun).where(WorkflowRun.id == domain_model.id_)) if not existing: # For new records, get the next sequence number - stmt = select(WorkflowRun.sequence_number).where( + stmt = select(func.max(WorkflowRun.sequence_number)).where( WorkflowRun.app_id == self._app_id, WorkflowRun.tenant_id == self._tenant_id, ) - max_sequence = session.scalar(stmt.order_by(WorkflowRun.sequence_number.desc())) + max_sequence = session.scalar(stmt) db_model.sequence_number = (max_sequence or 0) + 1 else: # For updates, keep the existing sequence number From 4d2f904d726731b2e9405fe73538125c8d9266c6 Mon Sep 17 00:00:00 2001 From: twwu Date: Fri, 13 Jun 2025 10:14:45 +0800 Subject: [PATCH 2/5] feat: enhance WorkflowPreview and TemplateCard components with additional styling and className prop --- .../list/template-card/details/index.tsx | 5 ++++- .../create-from-pipeline/list/template-card/index.tsx | 2 +- web/app/components/workflow/workflow-preview/index.tsx | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/web/app/components/datasets/create-from-pipeline/list/template-card/details/index.tsx b/web/app/components/datasets/create-from-pipeline/list/template-card/details/index.tsx index 8e1de45073..ae1eceba2d 100644 --- a/web/app/components/datasets/create-from-pipeline/list/template-card/details/index.tsx +++ b/web/app/components/datasets/create-from-pipeline/list/template-card/details/index.tsx @@ -50,7 +50,10 @@ const Details = ({ return (
- +
- {isFetching && } + {isFetching && ( +
+ +
+ )} {!isFetching && fileData && ( -
{fileData.content}
+
+ {fileData.content} +
)}
) diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/notion-page-preview.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/online-document-preview.tsx similarity index 69% rename from web/app/components/datasets/documents/create-from-pipeline/preview/notion-page-preview.tsx rename to web/app/components/datasets/documents/create-from-pipeline/preview/online-document-preview.tsx index 711057a295..147267974c 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/preview/notion-page-preview.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/preview/online-document-preview.tsx @@ -8,17 +8,18 @@ import { formatNumberAbbreviated } from '@/utils/format' import Loading from './loading' import { Notion } from '@/app/components/base/icons/src/public/common' -type NotionPagePreviewProps = { +type OnlineDocumentPreviewProps = { currentPage: NotionPage hidePreview: () => void } -const NotionPagePreview = ({ +const OnlineDocumentPreview = ({ currentPage, hidePreview, -}: NotionPagePreviewProps) => { +}: OnlineDocumentPreviewProps) => { const { t } = useTranslation() + // todo: replace with a generic hook for previewing online documents const { data: notionPageData, isFetching } = usePreviewNotionPage({ workspaceID: currentPage.workspace_id, pageID: currentPage.page_id, @@ -26,8 +27,8 @@ const NotionPagePreview = ({ }) return ( -
-
+
+
{t('datasetPipeline.addDocuments.stepOne.preview')}
{currentPage?.page_name}
@@ -52,14 +53,18 @@ const NotionPagePreview = ({
-
- {isFetching && } - {!isFetching && notionPageData && ( -
{notionPageData.content}
- )} -
+ {isFetching && ( +
+ +
+ )} + {!isFetching && notionPageData && ( +
+ {notionPageData.content} +
+ )}
) } -export default NotionPagePreview +export default OnlineDocumentPreview diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/web-preview.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/web-preview.tsx index 0b9ee6a5a0..fa04f15fcb 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/preview/web-preview.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/preview/web-preview.tsx @@ -17,8 +17,8 @@ const WebsitePreview = ({ const { t } = useTranslation() return ( -
-
+
+
{t('datasetPipeline.addDocuments.stepOne.preview')}
{payload.title}
@@ -38,8 +38,8 @@ const WebsitePreview = ({
-
-
{payload.markdown}
+
+ {payload.markdown}
) diff --git a/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx b/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx index 6c3e1e23e0..7d919ef1de 100644 --- a/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx +++ b/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx @@ -78,7 +78,7 @@ const PipelineSettings = ({ return (
diff --git a/web/app/components/datasets/preview/container.tsx b/web/app/components/datasets/preview/container.tsx index f6c1f7dc38..fbce75f2c2 100644 --- a/web/app/components/datasets/preview/container.tsx +++ b/web/app/components/datasets/preview/container.tsx @@ -1,20 +1,20 @@ import type { ComponentProps, FC, ReactNode } from 'react' -import { forwardRef } from 'react' import classNames from '@/utils/classnames' export type PreviewContainerProps = ComponentProps<'div'> & { header: ReactNode mainClassName?: string + ref?: React.Ref } -export const PreviewContainer: FC = forwardRef((props, ref) => { - const { children, className, header, mainClassName, ...rest } = props +const PreviewContainer: FC = (props) => { + const { children, className, header, mainClassName, ref, ...rest } = props return
@@ -25,5 +25,8 @@ export const PreviewContainer: FC = forwardRef((props, re
-}) +} + PreviewContainer.displayName = 'PreviewContainer' + +export default PreviewContainer From c891eb28fc0f3aa2dbeee7012698dbd0b0b006b6 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 13 Jun 2025 11:11:58 +0800 Subject: [PATCH 4/5] fix: in prompt editor show vars error --- .../workflow-variable-block/component.tsx | 18 +++++++++++------- web/config/index.ts | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx b/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx index 731841f423..e03cdbca21 100644 --- a/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx +++ b/web/app/components/base/prompt-editor/plugins/workflow-variable-block/component.tsx @@ -27,12 +27,13 @@ import { Variable02 } from '@/app/components/base/icons/src/vender/solid/develop import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others' import { VarBlockIcon } from '@/app/components/workflow/block-icon' import { Line3 } from '@/app/components/base/icons/src/public/common' -import { isConversationVar, isENV, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' +import { isConversationVar, isENV, isRagVariableVar, isSystemVar } from '@/app/components/workflow/nodes/_base/components/variable/utils' import Tooltip from '@/app/components/base/tooltip' import { isExceptionVariable } from '@/app/components/workflow/utils' import VarFullPathPanel from '@/app/components/workflow/nodes/_base/components/variable/var-full-path-panel' import { Type } from '@/app/components/workflow/nodes/llm/types' import type { ValueSelector } from '@/app/components/workflow/types' +import { InputField } from '@/app/components/base/icons/src/vender/pipeline' type WorkflowVariableBlockComponentProps = { nodeKey: string @@ -54,7 +55,8 @@ const WorkflowVariableBlockComponent = ({ const [editor] = useLexicalComposerContext() const [ref, isSelected] = useSelectOrDelete(nodeKey, DELETE_WORKFLOW_VARIABLE_BLOCK_COMMAND) const variablesLength = variables.length - const isShowAPart = variablesLength > 2 + const isRagVar = isRagVariableVar(variables) + const isShowAPart = variablesLength > 2 && !isRagVar const varName = ( () => { const isSystem = isSystemVar(variables) @@ -113,7 +115,7 @@ const WorkflowVariableBlockComponent = ({ className={cn( 'group/wrap relative mx-0.5 flex h-[18px] select-none items-center rounded-[5px] border pl-0.5 pr-[3px] hover:border-state-accent-solid hover:bg-state-accent-hover', isSelected ? ' border-state-accent-solid bg-state-accent-hover' : ' border-components-panel-border-subtle bg-components-badge-white-to-dark', - !node && !isEnv && !isChatVar && '!border-state-destructive-solid !bg-state-destructive-hover', + !node && !isEnv && !isChatVar && !isRagVar && '!border-state-destructive-solid !bg-state-destructive-hover', )} onClick={(e) => { e.stopPropagation() @@ -121,7 +123,7 @@ const WorkflowVariableBlockComponent = ({ }} ref={ref} > - {!isEnv && !isChatVar && ( + {!isEnv && !isChatVar && !isRagVar && (
{ node?.type && ( @@ -146,17 +148,19 @@ const WorkflowVariableBlockComponent = ({ )}
- {!isEnv && !isChatVar && } + {!isEnv && !isChatVar && !isRagVar && } {isEnv && } {isChatVar && } + {isRagVar && }
{varName}
{ - !node && !isEnv && !isChatVar && ( + !node && !isEnv && !isChatVar && !isRagVar && ( ) } @@ -164,7 +168,7 @@ const WorkflowVariableBlockComponent = ({
) - if (!node && !isEnv && !isChatVar) { + if (!node && !isEnv && !isChatVar && !isRagVar) { return ( {Item} diff --git a/web/config/index.ts b/web/config/index.ts index 1c616dd061..f1fffc8646 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -275,7 +275,7 @@ Thought: {{agent_scratchpad}} `, } -export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_]\w{0,29}){1,10}#)\}\}/gi +export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_]?\w{0,29}){1,10}(\.[a-zA-Z0-9_-]{1,50})?#)\}\}/gi export const resetReg = () => VAR_REGEX.lastIndex = 0 From 80f656f79a337acb9eff593e45f118626612c0ca Mon Sep 17 00:00:00 2001 From: twwu Date: Fri, 13 Jun 2025 11:38:26 +0800 Subject: [PATCH 5/5] fix: adjust layout and visibility conditions in CreateFormPipeline and ChunkPreview components --- .../datasets/documents/create-from-pipeline/index.tsx | 6 +++--- .../create-from-pipeline/preview/chunk-preview.tsx | 6 +++--- .../documents/detail/settings/pipeline-settings/index.tsx | 2 +- web/app/components/datasets/preview/container.tsx | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/web/app/components/datasets/documents/create-from-pipeline/index.tsx b/web/app/components/datasets/documents/create-from-pipeline/index.tsx index 41b83a5169..7ac1d7b092 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/index.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/index.tsx @@ -223,7 +223,7 @@ const CreateFormPipeline = () => { return (
{ {/* Preview */} { currentStep === 1 && ( -
+
{currentFile && } {currentDocuments && } {currentWebsite && } @@ -318,7 +318,7 @@ const CreateFormPipeline = () => { } { currentStep === 2 && ( -
+
file.file)} diff --git a/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx b/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx index 2459b4d18d..a17024efa7 100644 --- a/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx +++ b/web/app/components/datasets/documents/create-from-pipeline/preview/chunk-preview.tsx @@ -122,7 +122,7 @@ const ChunkPreview = ({ className='relative flex h-full w-full shrink-0' mainClassName='space-y-6' > - {currentDocForm === ChunkingMode.qa && estimateData?.qa_preview && ( + {!isPending && currentDocForm === ChunkingMode.qa && estimateData?.qa_preview && ( estimateData?.qa_preview.map((item, index) => ( )) )} - {currentDocForm === ChunkingMode.text && estimateData?.preview && ( + {!isPending && currentDocForm === ChunkingMode.text && estimateData?.preview && ( estimateData?.preview.map((item, index) => ( )) )} - {currentDocForm === ChunkingMode.parentChild && estimateData?.preview && ( + {!isPending && currentDocForm === ChunkingMode.parentChild && estimateData?.preview && ( estimateData?.preview?.map((item, index) => { const indexForLabel = index + 1 // const childChunks = parentChildConfig.chunkForContext === 'full-doc' diff --git a/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx b/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx index 7d919ef1de..a206211830 100644 --- a/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx +++ b/web/app/components/datasets/documents/detail/settings/pipeline-settings/index.tsx @@ -93,7 +93,7 @@ const PipelineSettings = ({
{/* Preview */} -
+
= (props) => { {...rest} ref={ref} className={classNames( - 'flex flex-col w-full h-full overflow-y-auto rounded-tl-xl border-t-[0.5px] border-l-[0.5px] border-components-panel-border bg-background-default-lighter shadow-md shadow-shadow-shadow-5', + 'flex flex-col w-full h-full rounded-tl-xl border-t-[0.5px] border-l-[0.5px] border-components-panel-border bg-background-default-lighter shadow-md shadow-shadow-shadow-5', )} >
{header}
-
+
{children}