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 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/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..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 @@ -78,7 +78,7 @@ const PipelineSettings = ({ return (
@@ -93,7 +93,7 @@ const PipelineSettings = ({
{/* Preview */} -
+
& { 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
{header}
-
+
{children}
-}) +} + PreviewContainer.displayName = 'PreviewContainer' + +export default PreviewContainer diff --git a/web/app/components/workflow/workflow-preview/index.tsx b/web/app/components/workflow/workflow-preview/index.tsx index fad7a033af..2aeb09cd1e 100644 --- a/web/app/components/workflow/workflow-preview/index.tsx +++ b/web/app/components/workflow/workflow-preview/index.tsx @@ -60,11 +60,13 @@ type WorkflowPreviewProps = { nodes: Node[] edges: Edge[] viewport: Viewport + className?: string } const WorkflowPreview = ({ nodes, edges, viewport, + className, }: WorkflowPreviewProps) => { const [nodesData, setNodesData] = useState(initialNodes(nodes, edges)) const [edgesData, setEdgesData] = useState(initialEdges(edges, nodes)) @@ -83,6 +85,7 @@ const WorkflowPreview = ({ id='workflow-container' className={cn( 'relative h-full w-full', + className, )} > <> @@ -125,7 +128,7 @@ const WorkflowPreview = ({ 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