Implementation:Langgenius Dify UsePublishAsCustomizedPipeline
| Knowledge Sources | Dify |
|---|---|
| Domains | RAG, Pipeline, Frontend |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Description
UsePublishAsCustomizedPipeline is a collection of React Query mutation hooks that provide the data-fetching layer for pipeline publishing operations in Dify. These hooks enable the frontend to publish pipelines as customized templates, export pipeline configurations as DSL files, and update existing template metadata.
The suite includes three primary hooks:
- usePublishAsCustomizedPipeline -- A mutation hook that publishes a pipeline configuration as a new customized template. Sends a POST request to
/rag/pipelines/{pipelineId}/customized/publishwith template metadata (name, icon, description). - useExportPipelineDSL -- A mutation hook that exports a pipeline's full configuration as a DSL string. Sends a GET request to
/rag/pipelines/{pipelineId}/exportswith an optionalinclude_secretflag. - useUpdateTemplateInfo -- A mutation hook that updates the metadata of an existing customized template. Sends a PATCH request to
/rag/pipeline/customized/templates/{template_id}.
Usage
These hooks are consumed by pipeline publishing dialogs, template management panels, and export workflows in the Dify frontend. The typical publishing workflow is:
- User finalizes pipeline configuration and testing.
- User triggers
usePublishAsCustomizedPipelineto create a reusable template with name, icon, and description. - Optionally, user uses
useExportPipelineDSLto download the pipeline configuration as a DSL file for backup or sharing. - Later, user may use
useUpdateTemplateInfoto refine the template's display metadata.
Code Reference
Source Location
web/service/use-pipeline.ts, lines 299--334 (publish and export) and lines 72--85 (update template)
Signature
export const usePublishAsCustomizedPipeline = () => {
return useMutation({
mutationKey: [NAME_SPACE, 'publish-as-customized-pipeline'],
mutationFn: ({
pipelineId,
name,
icon_info,
description,
}: {
pipelineId: string
name: string
icon_info: IconInfo
description?: string
}) => {
return post(`/rag/pipelines/${pipelineId}/customized/publish`, {
body: { name, icon_info, description },
})
},
})
}
export const useExportPipelineDSL = () => {
return useMutation({
mutationKey: [NAME_SPACE, 'export-pipeline-dsl'],
mutationFn: ({
pipelineId,
include = false,
}: { pipelineId: string; include?: boolean }) => {
return get<ExportTemplateDSLResponse>(
`/rag/pipelines/${pipelineId}/exports?include_secret=${include}`,
)
},
})
}
export const useUpdateTemplateInfo = (
mutationOptions: MutationOptions<
UpdateTemplateInfoResponse,
Error,
UpdateTemplateInfoRequest
> = {},
) => {
return useMutation({
mutationKey: [NAME_SPACE, 'template-update'],
mutationFn: (request: UpdateTemplateInfoRequest) => {
const { template_id, ...rest } = request
return patch<UpdateTemplateInfoResponse>(
`/rag/pipeline/customized/templates/${template_id}`,
{ body: rest },
)
},
...mutationOptions,
})
}
Import
import {
usePublishAsCustomizedPipeline,
useExportPipelineDSL,
useUpdateTemplateInfo,
} from '@/service/use-pipeline'
I/O Contract
usePublishAsCustomizedPipeline
Inputs (mutation variables):
| Parameter | Type | Required | Description |
|---|---|---|---|
| pipelineId | string |
Yes | The pipeline to publish as a customized template |
| name | string |
Yes | Display name for the published template |
| icon_info | IconInfo |
Yes | Icon metadata for the template (type, background color, icon identifier) |
| description | string |
No | Optional description text for the template |
Outputs:
| Field | Type | Description |
|---|---|---|
| (void) | -- | The mutation does not return a typed response body |
useExportPipelineDSL
Inputs (mutation variables):
| Parameter | Type | Required | Description |
|---|---|---|---|
| pipelineId | string |
Yes | The pipeline to export |
| include | boolean |
No | Whether to include secrets in the export (default: false)
|
Outputs:
| Field | Type | Description |
|---|---|---|
| data | string |
Serialized DSL content representing the full pipeline configuration |
useUpdateTemplateInfo
Inputs (mutation variables):
| Parameter | Type | Required | Description |
|---|---|---|---|
| template_id | string |
Yes | The ID of the customized template to update |
| name | string |
Yes | Updated display name |
| icon_info | IconInfo |
Yes | Updated icon metadata |
| description | string |
Yes | Updated description text |
Outputs:
| Field | Type | Description |
|---|---|---|
| pipeline_id | string |
Associated pipeline identifier |
| name | string |
Updated template name |
| icon | IconInfo |
Updated icon metadata |
| description | string |
Updated description |
| position | number |
Sort order position in the template list |
Usage Examples
// Publish a pipeline as a customized template
const { mutateAsync: publishPipeline } = usePublishAsCustomizedPipeline()
await publishPipeline({
pipelineId: 'pipeline-abc',
name: 'Product Documentation RAG',
icon_info: {
icon_type: 'emoji',
icon: '📄',
background: '#E8F5E9',
},
description: 'Optimized pipeline for processing product documentation with hierarchical chunking.',
})
// Export a pipeline configuration as DSL (without secrets)
const { mutateAsync: exportDSL } = useExportPipelineDSL()
const { data: dslContent } = await exportDSL({
pipelineId: 'pipeline-abc',
include: false,
})
// Download the DSL as a file
const blob = new Blob([dslContent], { type: 'application/yaml' })
downloadFile(blob, 'pipeline-config.yml')
// Export with secrets included (for same-environment transfer)
const { data: dslWithSecrets } = await exportDSL({
pipelineId: 'pipeline-abc',
include: true,
})
// Update an existing template's metadata
const { mutateAsync: updateTemplate } = useUpdateTemplateInfo({
onSuccess: (result) => {
console.log('Template updated:', result.name)
},
})
await updateTemplate({
template_id: 'template-xyz',
name: 'Product Docs RAG v2',
icon_info: {
icon_type: 'emoji',
icon: '📋',
background: '#E3F2FD',
},
description: 'Updated pipeline with improved QA chunking support.',
})