花骨朵轻创
花骨朵轻创
Published on 2025-03-02 / 41 Visits
0
0

Dify专有知识库聊天机器人工作流

app:
  description: ''
  icon: 🤖
  icon_background: '#FFEAD5'
  mode: advanced-chat
  name: 专有知识库聊天机器人
kind: app
version: 0.1.1
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload:
      image:
        enabled: false
        number_limits: 3
        transfer_methods:
        - local_file
        - remote_url
    opening_statement: ''
    retriever_resource:
      enabled: true
    sensitive_word_avoidance:
      enabled: false
    speech_to_text:
      enabled: false
    suggested_questions: []
    suggested_questions_after_answer:
      enabled: false
    text_to_speech:
      enabled: false
      language: ''
      voice: ''
  graph:
    edges:
    - data:
        isInIteration: false
        sourceType: knowledge-retrieval
        targetType: llm
      id: 1723978743400-source-llm-target
      source: '1723978743400'
      sourceHandle: source
      target: llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: llm
        targetType: tool
      id: llm-source-1723980305119-target
      source: llm
      sourceHandle: source
      target: '1723980305119'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: tool
        targetType: if-else
      id: 1723980305119-source-1723980468758-target
      source: '1723980305119'
      sourceHandle: source
      target: '1723980468758'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: tool
        targetType: llm
      id: 1723980971735-source-1723981033863-target
      source: '1723980971735'
      sourceHandle: source
      target: '1723981033863'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: tool
      id: 1723980468758-true-1723980971735-target
      source: '1723980468758'
      sourceHandle: 'true'
      target: '1723980971735'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: knowledge-retrieval
      id: 1723980468758-false-1723993297742-target
      source: '1723980468758'
      sourceHandle: 'false'
      target: '1723993297742'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: knowledge-retrieval
        targetType: llm
      id: 1723993297742-source-1723980596103-target
      source: '1723993297742'
      sourceHandle: source
      target: '1723980596103'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: llm
        targetType: parameter-extractor
      id: 1723980596103-source-1723993699657-target
      source: '1723980596103'
      sourceHandle: source
      target: '1723993699657'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: parameter-extractor
        targetType: if-else
      id: 1723993699657-source-1723993886969-target
      source: '1723993699657'
      sourceHandle: source
      target: '1723993886969'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: http-request
      id: 1723993886969-false-1723993952438-target
      source: '1723993886969'
      sourceHandle: 'false'
      target: '1723993952438'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: http-request
        targetType: answer
      id: 1723993952438-source-1723993994437-target
      source: '1723993952438'
      sourceHandle: source
      target: '1723993994437'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: llm
        targetType: answer
      id: 1723981033863-source-1723981179751-target
      source: '1723981033863'
      sourceHandle: source
      target: '1723981179751'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: answer
      id: 1723993886969-true-answer-target
      source: '1723993886969'
      sourceHandle: 'true'
      target: answer
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: start
        targetType: if-else
      id: 1723978678791-source-1724029232255-target
      source: '1723978678791'
      sourceHandle: source
      target: '1724029232255'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: llm
      id: 1724029232255-true-1724029329781-target
      source: '1724029232255'
      sourceHandle: 'true'
      target: '1724029329781'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: knowledge-retrieval
      id: 1724029232255-false-1723978743400-target
      source: '1724029232255'
      sourceHandle: 'false'
      target: '1723978743400'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: llm
        targetType: tool
      id: 1724029329781-source-1724029473445-target
      source: '1724029329781'
      sourceHandle: source
      target: '1724029473445'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: tool
        targetType: answer
      id: 1724029473445-source-1724029491317-target
      source: '1724029473445'
      sourceHandle: source
      target: '1724029491317'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: answer
      id: 1724029232255-06a6e8d4-b186-406e-8b27-c15be0e57d1a-1724080857769-target
      source: '1724029232255'
      sourceHandle: 06a6e8d4-b186-406e-8b27-c15be0e57d1a
      target: '1724080857769'
      targetHandle: target
      type: custom
      zIndex: 0
    nodes:
    - data:
        desc: 用户输入
        selected: false
        title: 开始
        type: start
        variables: []
      height: 82
      id: '1723978678791'
      position:
        x: 30
        y: 560
      positionAbsolute:
        x: 30
        y: 560
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        context:
          enabled: true
          variable_selector:
          - '1723978743400'
          - result
        desc: ''
        memory:
          role_prefix:
            assistant: ''
            user: ''
          window:
            enabled: false
            size: 10
        model:
          completion_params:
            frequency_penalty: 0.3
            presence_penalty: 0.2
            temperature: 0.5
            top_p: 0.85
          mode: chat
          name: gpt-4o
          provider: openai
        prompt_template:
        - edition_type: basic
          id: ad312fd6-e00a-4ab7-adc1-afc09fe221e8
          role: system
          text: "基于上下文,以及用户提问,判断是否上下文与用户提问相关。回答采用Json数据格式。直接输出Json,不要使用Markdown语法。\n\
            如果上下文相关,则回答:\n{\n   “related\":true\n}\n否则,回答:\n{\n   “related\":false\n\
            }\n上下文:\n{{#context#}}\n用户提问:\n{{#sys.query#}}"
        selected: false
        title: LLM
        type: llm
        variables: []
        vision:
          configs:
            detail: high
          enabled: true
      height: 98
      id: llm
      position:
        x: 961.8982985896257
        y: 560
      positionAbsolute:
        x: 961.8982985896257
        y: 560
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        answer: '{{#1723993699657.content#}}'
        desc: ''
        selected: false
        title: 直接回复
        type: answer
        variables: []
      height: 107
      id: answer
      position:
        x: 3070
        y: 718
      positionAbsolute:
        x: 3070
        y: 718
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        dataset_ids:
        - bce9e8d2-fa10-440c-8f83-d06486b1f811
        desc: ''
        multiple_retrieval_config:
          reranking_enable: true
          reranking_mode: weighted_score
          reranking_model:
            model: ''
            provider: ''
          score_threshold: null
          top_k: 4
          weights:
            keyword_setting:
              keyword_weight: 0
            vector_setting:
              embedding_model_name: nomic-embed-text:v1.5
              embedding_provider_name: ollama
              vector_weight: 1
        query_variable_selector:
        - '1723978678791'
        - sys.query
        retrieval_mode: multiple
        selected: false
        single_retrieval_config:
          model:
            completion_params: {}
            mode: chat
            name: glm-4
            provider: zhipuai
        title: 知识检索
        type: knowledge-retrieval
      height: 92
      id: '1723978743400'
      position:
        x: 645.4618619711097
        y: 560
      positionAbsolute:
        x: 645.4618619711097
        y: 560
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        provider_id: json_process
        provider_name: json_process
        provider_type: builtin
        selected: false
        title: JSON 解析
        tool_configurations:
          ensure_ascii: 0
        tool_label: JSON 解析
        tool_name: parse
        tool_parameters:
          content:
            type: mixed
            value: '{{#llm.text#}}'
          json_filter:
            type: mixed
            value: '"related"'
        type: tool
      height: 90
      id: '1723980305119'
      position:
        x: 1255.949149294813
        y: 560
      positionAbsolute:
        x: 1255.949149294813
        y: 560
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        cases:
        - case_id: 'true'
          conditions:
          - comparison_operator: contains
            id: 94136473-2ee0-418d-b51b-d5965bb8510b
            value: 'False'
            varType: string
            variable_selector:
            - '1723980305119'
            - text
          id: 'true'
          logical_operator: and
        desc: 判断true和false
        selected: false
        title: 条件分支
        type: if-else
      height: 154
      id: '1723980468758'
      position:
        x: 1550
        y: 560
      positionAbsolute:
        x: 1550
        y: 560
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        context:
          enabled: true
          variable_selector:
          - '1723993297742'
          - result
        desc: ''
        model:
          completion_params:
            temperature: 0.7
          mode: chat
          name: gpt-4o
          provider: openai
        prompt_template:
        - id: d744cfc4-86ed-4331-85a0-befc371cb4ae
          role: system
          text: '##角色

            你是一个乐于助人的知识库问答助手,根据{{#context#}}回答用户的问题。


            ##限制

            1.根据用户的具体提问回答问题,不要一下子把常见问题都输出给用户。

            2.请使用json格式输出,不要输出任何与json格式无关的内容!


            ##输出要求

            1.如果输出的内容包含图片url,请按以下格式输出:

            {"content":"示例输出内容","imageUrl":"图片地址"}

            2.如果输出的内容不包含图片url,请按一下格式输出:

            {"content":"示例输出内容"}'
        selected: false
        title: LLM 2
        type: llm
        variables: []
        vision:
          configs:
            detail: high
          enabled: true
      height: 98
      id: '1723980596103'
      position:
        x: 2158
        y: 716
      positionAbsolute:
        x: 2158
        y: 716
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        provider_id: duckduckgo
        provider_name: duckduckgo
        provider_type: builtin
        selected: false
        title: DuckDuckGo 搜索
        tool_configurations:
          max_results: 5
          require_summary: 1
        tool_label: DuckDuckGo 搜索
        tool_name: ddgo_search
        tool_parameters:
          query:
            type: mixed
            value: '{{#sys.query#}}'
        type: tool
      height: 116
      id: '1723980971735'
      position:
        x: 1854
        y: 560
      positionAbsolute:
        x: 1854
        y: 560
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        context:
          enabled: true
          variable_selector:
          - '1723980971735'
          - text
        desc: ''
        model:
          completion_params:
            temperature: 0.7
          mode: chat
          name: deepseek-chat
          provider: deepseek
        prompt_template:
        - id: 90ec0ffd-7092-4385-8aad-9c1e3da1b779
          role: system
          text: '基于提供的上下文信息,回答问题。

            上下文信息由<context></context>标签标识。

            <context>

            {{#context#}}

            </context>


            用户的问题:

            <query>

            {{#sys.query#}}

            </query>'
        selected: false
        title: LLM 3
        type: llm
        variables: []
        vision:
          enabled: false
      height: 98
      id: '1723981033863'
      position:
        x: 2158
        y: 560
      positionAbsolute:
        x: 2158
        y: 560
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        answer: '{{#1723981033863.text#}}'
        desc: ''
        selected: false
        title: 直接回复 2
        type: answer
        variables: []
      height: 107
      id: '1723981179751'
      position:
        x: 2462
        y: 560
      positionAbsolute:
        x: 2462
        y: 560
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        dataset_ids:
        - bce9e8d2-fa10-440c-8f83-d06486b1f811
        desc: 第二次检索
        multiple_retrieval_config:
          reranking_enable: true
          reranking_mode: weighted_score
          top_k: 4
          weights:
            keyword_setting:
              keyword_weight: 0
            vector_setting:
              embedding_model_name: nomic-embed-text:v1.5
              embedding_provider_name: ollama
              vector_weight: 1
        query_variable_selector:
        - sys
        - query
        retrieval_mode: single
        selected: false
        single_retrieval_config:
          model:
            completion_params: {}
            mode: chat
            name: glm-4
            provider: zhipuai
        title: 知识检索 2
        type: knowledge-retrieval
      height: 120
      id: '1723993297742'
      position:
        x: 1854
        y: 716
      positionAbsolute:
        x: 1854
        y: 716
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        instruction: ''
        model:
          completion_params:
            temperature: 0.7
          mode: chat
          name: deepseek-coder
          provider: deepseek
        parameters:
        - description: 内容文本
          name: content
          required: false
          type: string
        - description: 图片url
          name: imageUrl
          required: false
          type: string
        query:
        - '1723980596103'
        - text
        reasoning_mode: prompt
        selected: false
        title: 参数提取器
        type: parameter-extractor
        variables: []
      height: 98
      id: '1723993699657'
      position:
        x: 2462
        y: 716
      positionAbsolute:
        x: 2462
        y: 716
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        cases:
        - case_id: 'true'
          conditions:
          - comparison_operator: empty
            id: 94a2f651-3ca3-4125-8e79-745da581d106
            value: ''
            varType: string
            variable_selector:
            - '1723993699657'
            - imageUrl
          id: 'true'
          logical_operator: and
        desc: ''
        selected: false
        title: 条件分支 2
        type: if-else
      height: 126
      id: '1723993886969'
      position:
        x: 2762.2690690144445
        y: 716
      positionAbsolute:
        x: 2762.2690690144445
        y: 716
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        authorization:
          config: null
          type: no-auth
        body:
          data: ''
          type: none
        desc: ''
        headers: ''
        method: get
        params: ''
        selected: false
        timeout:
          max_connect_timeout: 0
          max_read_timeout: 0
          max_write_timeout: 0
        title: HTTP 请求
        type: http-request
        url: '{{#1723993699657.imageUrl#}}'
        variables: []
      height: 93
      id: '1723993952438'
      position:
        x: 3070
        y: 865
      positionAbsolute:
        x: 3070
        y: 865
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        answer: '内容:{{#1723993699657.content#}}图片地址:

          {{#1723993699657.imageUrl#}}'
        desc: ''
        selected: false
        title: 图文回复
        type: answer
        variables: []
      height: 142
      id: '1723993994437'
      position:
        x: 3400.1165168988837
        y: 865
      positionAbsolute:
        x: 3400.1165168988837
        y: 865
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        cases:
        - case_id: 'true'
          conditions:
          - comparison_operator: contains
            id: f1a56fea-5e9b-43cc-a767-3392ab5205c5
            value: 画图
            varType: string
            variable_selector:
            - sys
            - query
          id: 'true'
          logical_operator: and
        - case_id: 06a6e8d4-b186-406e-8b27-c15be0e57d1a
          conditions:
          - comparison_operator: contains
            id: a0bd109f-ea0f-4a25-b4e5-bc4b50c34281
            value: 你好
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: cf33b983-8ea6-49ef-a8e6-3ab332936576
            value: 谁
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 89561f3a-eb32-4fde-b57c-1854d03b7513
            value: '提问 '
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 80772c0b-ca6d-4f72-9f9c-677c595d0e88
            value: 帮我
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 3b604e52-8218-45db-8ef2-afb59e046cce
            value: 开发
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: a20975fc-537e-4f86-8d6d-1877a0137494
            value: '功能 '
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 959df55a-296a-4f60-8d6e-60e044cc7719
            value: 提问
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 583bb8cc-79d7-4586-8458-d717952c0106
            value: '帮助 '
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 7e1e8ca8-65ce-4b19-b478-0ba5289f169a
            value: '方法 '
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: b60a85fc-3cb5-4fcf-864b-a2bd0c052209
            value: 知识库
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 2f1b130d-48e9-4775-9a8c-4f41752ec49d
            value: ' 系统版本'
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 5a1927d9-7d50-40a8-844a-1376d460c924
            value: ' 开发'
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 65a5ae86-3d7b-4847-acc5-623499321760
            value: 你是
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 22d16273-2725-47bf-a7a1-346b7fda54ee
            value: 模型
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 4da56525-87d9-4844-a406-50aec1e73545
            value: 数据库
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 422f3124-7af9-46bc-bcae-bfd33db8d80f
            value: 训练集
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: e43e3a26-c6d3-481d-8986-03c6870edf45
            value: 截止
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: d8474f54-9f96-4261-938a-f62f0b95c543
            value: 中文
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 96be59ca-5754-4432-9938-2f73b88cc8cc
            value: 翻译
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 321cc9cd-626d-4254-87a1-3eadda8c3211
            value: 英文
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: 880d739b-6b8b-4c6e-adc8-5a1a072fdb2c
            value: 问答
            varType: string
            variable_selector:
            - sys
            - query
          - comparison_operator: contains
            id: b3150018-cfae-43cb-9fa5-94a5b42b79f4
            value: 版本
            varType: string
            variable_selector:
            - sys
            - query
          id: 06a6e8d4-b186-406e-8b27-c15be0e57d1a
          logical_operator: or
        desc: ''
        selected: false
        title: 条件分支 3
        type: if-else
      height: 720
      id: '1724029232255'
      position:
        x: 334
        y: 560
      positionAbsolute:
        x: 334
        y: 560
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        context:
          enabled: true
          variable_selector:
          - sys
          - query
        desc: ''
        model:
          completion_params:
            temperature: 0.7
          mode: chat
          name: llama3.1:latest
          provider: ollama
        prompt_template:
        - id: 938fd5d5-a871-4d4e-81e0-c7e434537d23
          role: system
          text: "你是一个多语言翻译成英文的专业翻译助手。你可以把任何文字都翻译成英文\n<examples>\n    <example>\n \
            \       <input>你好,世界!</input>\n        <output>Hello,world!</output>\n\
            \    </example>\n    <example>\n        <input>一个可爱的考拉</input>\n     \
            \   <output>A cute koala</output>\n    </example>\n    <example>\n   \
            \     <input>漂亮的女孩</input>\n        <output>pretty girl</output>\n   \
            \  </example>\n</examples>\n只需要回复翻译后的结果,不做任何解释说明\n请翻译:\n{{#sys.query#}}"
        selected: false
        title: LLM 4
        type: llm
        variables: []
        vision:
          enabled: false
      height: 98
      id: '1724029329781'
      position:
        x: 638
        y: 759
      positionAbsolute:
        x: 638
        y: 759
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        provider_id: stablediffusion
        provider_name: stablediffusion
        provider_type: builtin
        selected: false
        title: Stable Diffusion WebUI
        tool_configurations:
          height: 512
          lora: ''
          model: majicmix realistic 麦橘写实_v7
          negative_prompt: bad art, ugly, deformed, watermark, duplicated, discontinuous
            lines
          steps: 10
          width: 512
        tool_label: Stable Diffusion WebUI
        tool_name: stable_diffusion
        tool_parameters:
          prompt:
            type: mixed
            value: '{{#1724029329781.text#}}'
        type: tool
      height: 220
      id: '1724029473445'
      position:
        x: 942
        y: 759
      positionAbsolute:
        x: 942
        y: 759
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        answer: '{{#1724029473445.files#}}'
        desc: ''
        selected: true
        title: 直接回复 4
        type: answer
        variables: []
      height: 107
      id: '1724029491317'
      position:
        x: 1246
        y: 759
      positionAbsolute:
        x: 1246
        y: 759
      selected: true
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        answer: 我是花骨朵轻创家智能机器人客服!我能为你提供,联网搜索,在线绘图,知识库问答,当前知识库是项目采购知识相关。请提供项目采购相关问题。也可以问我,苏州市天气怎么样
        desc: ''
        selected: false
        title: 直接回复 5
        type: answer
        variables: []
      height: 168
      id: '1724080857769'
      position:
        x: 638
        y: 948.8549951412275
      positionAbsolute:
        x: 638
        y: 948.8549951412275
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    viewport:
      x: -173.39053584250337
      y: -352.71153684122544
      zoom: 0.8563876749071129

复制代码保存为.yml格式的文档。在dify中导入DSL文件


Comment