mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 03:36:36 +08:00
Merge branch 'feat/rag-pipeline' into deploy/rag-dev
This commit is contained in:
commit
d2ae695b3b
@ -13,6 +13,7 @@ const BuiltInPipelineList = () => {
|
|||||||
{list.map((pipeline, index) => (
|
{list.map((pipeline, index) => (
|
||||||
<TemplateCard
|
<TemplateCard
|
||||||
key={index}
|
key={index}
|
||||||
|
type='built-in'
|
||||||
pipeline={pipeline}
|
pipeline={pipeline}
|
||||||
showMoreOperations={false}
|
showMoreOperations={false}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -13,6 +13,7 @@ const CustomizedList = () => {
|
|||||||
{list.map((pipeline, index) => (
|
{list.map((pipeline, index) => (
|
||||||
<TemplateCard
|
<TemplateCard
|
||||||
key={index}
|
key={index}
|
||||||
|
type='customized'
|
||||||
pipeline={pipeline}
|
pipeline={pipeline}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -11,17 +11,19 @@ import WorkflowPreview from '@/app/components/workflow/workflow-preview'
|
|||||||
|
|
||||||
type DetailsProps = {
|
type DetailsProps = {
|
||||||
id: string
|
id: string
|
||||||
|
type: 'customized' | 'built-in'
|
||||||
onApplyTemplate: () => void
|
onApplyTemplate: () => void
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const Details = ({
|
const Details = ({
|
||||||
id,
|
id,
|
||||||
|
type,
|
||||||
onApplyTemplate,
|
onApplyTemplate,
|
||||||
onClose,
|
onClose,
|
||||||
}: DetailsProps) => {
|
}: DetailsProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { data: pipelineTemplateInfo } = usePipelineTemplateById(id, true)
|
const { data: pipelineTemplateInfo } = usePipelineTemplateById(id, type, true)
|
||||||
const appIcon = React.useMemo(() => {
|
const appIcon = React.useMemo(() => {
|
||||||
if (!pipelineTemplateInfo)
|
if (!pipelineTemplateInfo)
|
||||||
return { type: 'emoji', icon: '📙', background: '#FFF4ED' }
|
return { type: 'emoji', icon: '📙', background: '#FFF4ED' }
|
||||||
@ -41,7 +43,7 @@ const Details = ({
|
|||||||
<div className='flex h-full'>
|
<div className='flex h-full'>
|
||||||
<div className='flex grow items-center justify-center p-3 pr-0'>
|
<div className='flex grow items-center justify-center p-3 pr-0'>
|
||||||
<WorkflowPreview
|
<WorkflowPreview
|
||||||
{...pipelineTemplateInfo.graph}
|
{...pipelineTemplateInfo.export_data.workflow.graph}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='relative flex w-[360px] shrink-0 flex-col'>
|
<div className='relative flex w-[360px] shrink-0 flex-col'>
|
||||||
|
|||||||
@ -23,11 +23,13 @@ import CreateModal from './create-modal'
|
|||||||
type TemplateCardProps = {
|
type TemplateCardProps = {
|
||||||
pipeline: PipelineTemplate
|
pipeline: PipelineTemplate
|
||||||
showMoreOperations?: boolean
|
showMoreOperations?: boolean
|
||||||
|
type: 'customized' | 'built-in'
|
||||||
}
|
}
|
||||||
|
|
||||||
const TemplateCard = ({
|
const TemplateCard = ({
|
||||||
pipeline,
|
pipeline,
|
||||||
showMoreOperations = true,
|
showMoreOperations = true,
|
||||||
|
type,
|
||||||
}: TemplateCardProps) => {
|
}: TemplateCardProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { push } = useRouter()
|
const { push } = useRouter()
|
||||||
@ -36,7 +38,7 @@ const TemplateCard = ({
|
|||||||
const [showDetailModal, setShowDetailModal] = useState(false)
|
const [showDetailModal, setShowDetailModal] = useState(false)
|
||||||
const [showCreateModal, setShowCreateModal] = useState(false)
|
const [showCreateModal, setShowCreateModal] = useState(false)
|
||||||
|
|
||||||
const { refetch: getPipelineTemplateInfo } = usePipelineTemplateById(pipeline.id, false)
|
const { refetch: getPipelineTemplateInfo } = usePipelineTemplateById(pipeline.id, type, false)
|
||||||
const { mutateAsync: createEmptyDataset } = useCreatePipelineDataset()
|
const { mutateAsync: createEmptyDataset } = useCreatePipelineDataset()
|
||||||
const { handleCheckPluginDependencies } = usePluginDependencies()
|
const { handleCheckPluginDependencies } = usePluginDependencies()
|
||||||
|
|
||||||
@ -179,6 +181,7 @@ const TemplateCard = ({
|
|||||||
>
|
>
|
||||||
<Details
|
<Details
|
||||||
id={pipeline.id}
|
id={pipeline.id}
|
||||||
|
type={type}
|
||||||
onClose={closeDetailsModal}
|
onClose={closeDetailsModal}
|
||||||
onApplyTemplate={openCreateModal}
|
onApplyTemplate={openCreateModal}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -30,17 +30,23 @@ export type PipelineTemplateListResponse = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type PipelineTemplateByIdResponse = {
|
export type PipelineTemplateByIdResponse = {
|
||||||
|
id: string
|
||||||
name: string
|
name: string
|
||||||
icon: IconInfo
|
icon: IconInfo
|
||||||
description: string
|
description: string
|
||||||
author: string // todo: TBD
|
author: string // todo: TBD
|
||||||
structure: string // todo: TBD
|
structure: string // todo: TBD
|
||||||
graph: {
|
export_data: {
|
||||||
nodes: Node[]
|
workflow: {
|
||||||
edges: Edge[]
|
graph: {
|
||||||
viewport: Viewport
|
nodes: Node[]
|
||||||
|
edges: Edge[]
|
||||||
|
viewport: Viewport
|
||||||
|
}
|
||||||
|
environment_variables?: EnvironmentVariable[]
|
||||||
|
rag_pipeline_variables?: RAGPipelineVariables
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export_data: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CreateFormData = {
|
export type CreateFormData = {
|
||||||
|
|||||||
@ -42,11 +42,11 @@ export const usePipelineTemplateList = (params: PipelineTemplateListParams) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const usePipelineTemplateById = (templateId: string, enabled: boolean) => {
|
export const usePipelineTemplateById = (templateId: string, type: string, enabled: boolean) => {
|
||||||
return useQuery<PipelineTemplateByIdResponse>({
|
return useQuery<PipelineTemplateByIdResponse>({
|
||||||
queryKey: [NAME_SPACE, 'template', templateId],
|
queryKey: [NAME_SPACE, 'template', templateId],
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
return get<PipelineTemplateByIdResponse>(`/rag/pipeline/templates/${templateId}`)
|
return get<PipelineTemplateByIdResponse>(`/rag/pipeline/templates/${templateId}?type=${type}`)
|
||||||
},
|
},
|
||||||
enabled,
|
enabled,
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user