app:
  description: Code 判定不良率→條件分流→不合格自動產 8D、合格產允收單。
  icon: 🔬
  icon_background: '#E0F2FE'
  icon_type: emoji
  mode: workflow
  name: 進料檢驗與 8D 異常處理
  use_icon_as_answer_icon: false
dependencies:
- current_identifier: null
  type: marketplace
  value:
    marketplace_plugin_unique_identifier: langgenius/anthropic:0.3.24@c5e50da8c13c7ac75348df5ac75b9418c79736eb506064669dd7ca06cbd83537
    version: null
kind: app
version: 0.6.0
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload:
      allowed_file_extensions:
      - .JPG
      allowed_file_types:
      - image
      allowed_file_upload_methods:
      - local_file
      enabled: false
      fileUploadConfig:
        attachment_image_file_size_limit: 2
        audio_file_size_limit: 50
        batch_count_limit: 5
        file_size_limit: 15
        file_upload_limit: 20
        image_file_batch_limit: 10
        image_file_size_limit: 10
        single_chunk_attachment_limit: 10
        video_file_size_limit: 100
        workflow_file_upload_limit: 10
      image:
        enabled: false
        number_limits: 3
        transfer_methods:
        - local_file
      number_limits: 3
    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
        isInLoop: false
        sourceType: start
        targetType: tool
      id: 27s-source-27code
      source: 27s
      sourceHandle: source
      target: 27code
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: tool
        targetType: if-else
      id: 27code-source-27if
      source: 27code
      sourceHandle: source
      target: 27if
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: if-else
        targetType: knowledge-retrieval
      id: 27if-true-27kr
      source: 27if
      sourceHandle: 'true'
      target: 27kr
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: knowledge-retrieval
        targetType: llm
      id: 27kr-source-27l8d
      source: 27kr
      sourceHandle: source
      target: 27l8d
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: template-transform
      id: 27l8d-source-27tpl
      source: 27l8d
      sourceHandle: source
      target: 27tpl
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: template-transform
        targetType: variable-aggregator
      id: 27tpl-source-27agg
      source: 27tpl
      sourceHandle: source
      target: 27agg
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: if-else
        targetType: llm
      id: 27if-false-27lacc
      source: 27if
      sourceHandle: 'false'
      target: 27lacc
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: variable-aggregator
      id: 27lacc-source-27agg
      source: 27lacc
      sourceHandle: source
      target: 27agg
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: variable-aggregator
        targetType: llm
      id: 27agg-source-27lsum
      source: 27agg
      sourceHandle: source
      target: 27lsum
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: end
      id: 27lsum-source-27e
      source: 27lsum
      sourceHandle: source
      target: 27e
      targetHandle: target
      type: custom
      zIndex: 0
    nodes:
    - data:
        selected: false
        title: 開始
        type: start
        variables:
        - default: ''
          hint: ''
          label: 品名/批號
          max_length: 80
          options: []
          placeholder: 例：304 不鏽鋼板 批號 A2607
          required: true
          type: text-input
          variable: item
        - default: ''
          hint: ''
          label: 主要不良現象
          max_length: 100
          options: []
          placeholder: 例：尺寸超差、刮傷、材質異常
          required: true
          type: text-input
          variable: symptom
        - default: ''
          hint: ''
          label: 檢驗數
          options: []
          placeholder: '500'
          required: true
          type: number
          variable: inspected
        - default: ''
          hint: ''
          label: 不良數
          options: []
          placeholder: '18'
          required: true
          type: number
          variable: defect
        - default: ''
          hint: ''
          label: 允收不良率門檻(%)
          options: []
          placeholder: '2'
          required: true
          type: number
          variable: threshold
      height: 213
      id: 27s
      position:
        x: 0
        y: 0
      positionAbsolute:
        x: 0
        y: 0
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    - data:
        provider_id: code
        provider_name: code
        provider_type: builtin
        selected: false
        title: Code 判定
        tool_configurations: {}
        tool_label: Code Interpreter
        tool_name: simple_code
        tool_node_version: '2'
        tool_parameters:
          code:
            type: mixed
            value: 'inspected=int("{{#27s.inspected#}}")

              defect=int("{{#27s.defect#}}")

              thr=float("{{#27s.threshold#}}")

              rate=(defect/inspected*100) if inspected else 0

              verdict="FAIL" if rate>thr else "PASS"

              print(f"品名/批號：{{#27s.item#}}")

              print(f"檢驗數：{inspected}　不良數：{defect}")

              print(f"不良率：{rate:.2f}%（允收門檻 {thr}%）")

              print(f"VERDICT: {verdict}")

              '
          language:
            type: constant
            value: python3
        type: tool
      height: 52
      id: 27code
      position:
        x: 342
        y: 116
      positionAbsolute:
        x: 342
        y: 116
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    - data:
        cases:
        - case_id: 'true'
          conditions:
          - comparison_operator: contains
            id: cond1
            value: FAIL
            variable_selector:
            - 27code
            - text
          logical_operator: and
        selected: false
        title: 是否判退
        type: if-else
      height: 124
      id: 27if
      position:
        x: 684
        y: 88.66666666666666
      positionAbsolute:
        x: 684
        y: 88.66666666666666
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    - data:
        dataset_ids:
        - A8CEwcdok6itQHuFhs10z2hY/44zOCu7BjHxp7937kQbjA/6L+oMFYGxLwS7ykBF
        multiple_retrieval_config:
          reranking_enable: false
          reranking_mode: reranking_model
          reranking_model:
            model: ''
            provider: ''
          score_threshold: null
          top_k: 3
          weights: null
        query_variable_selector:
        - 27s
        - symptom
        retrieval_mode: multiple
        selected: false
        title: 對策檢索
        type: knowledge-retrieval
      height: 90
      id: 27kr
      position:
        x: 1046
        y: 38.96666666666667
      positionAbsolute:
        x: 1046
        y: 38.96666666666667
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    - data:
        context:
          enabled: true
          variable_selector:
          - 27kr
          - result
        model:
          completion_params:
            temperature: 0.3
          mode: chat
          name: claude-sonnet-5
          provider: langgenius/anthropic/anthropic
        prompt_template:
        - id: s產生 8D 初稿
          role: system
          text: '你是品保工程師。這批進料判定為『不合格』。請【根據下方對策手冊】產出一份 8D 異常處理初稿，涵蓋 D1~D8，重點放在 D3 圍堵、D4
            根因（用 5 Why 針對『{{#27s.symptom#}}』）、D5 對策、D7 預防再發，並依手冊給供應商 8D 回覆期限與升級原則。繁體中文、Markdown。


            【對策手冊】

            {{#context#}}'
        - id: u產生 8D 初稿
          role: user
          text: 請開始。
        selected: false
        title: 產生 8D 初稿
        type: llm
        vision:
          enabled: false
      height: 88
      id: 27l8d
      position:
        x: 1388
        y: 54.96666666666667
      positionAbsolute:
        x: 1388
        y: 54.96666666666667
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    - data:
        selected: false
        template: '# 進料異常處理報告


          ## 一、檢驗判定

          {{ stats }}


          ## 二、8D 對策初稿

          {{ eightd }}

          '
        title: 組裝異常報告
        type: template-transform
        variables:
        - value_selector:
          - 27code
          - text
          variable: stats
        - value_selector:
          - 27l8d
          - text
          variable: eightd
      height: 52
      id: 27tpl
      position:
        x: 1730
        y: 87.63333333333333
      positionAbsolute:
        x: 1730
        y: 87.63333333333333
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    - data:
        context:
          enabled: false
          variable_selector: []
        model:
          completion_params:
            temperature: 0.3
          mode: chat
          name: claude-sonnet-5
          provider: langgenius/anthropic/anthropic
        prompt_template:
        - id: s產生允收單
          role: system
          text: '你是品保人員。這批進料判定為『合格』。請產出一張簡短的『進料允收通知』：品名批號、檢驗結果摘要、允收結論與後續入庫提醒。繁體中文、Markdown。


            檢驗數據：

            {{#27code.text#}}'
        - id: u產生允收單
          role: user
          text: 請開始。
        selected: false
        title: 產生允收單
        type: llm
        vision:
          enabled: false
      height: 88
      id: 27lacc
      position:
        x: 1730
        y: 222.96666666666667
      positionAbsolute:
        x: 1730
        y: 222.96666666666667
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    - data:
        output_type: string
        selected: false
        title: 彙整結果
        type: variable-aggregator
        variables:
        - - 27tpl
          - output
        - - 27lacc
          - text
      height: 134
      id: 27agg
      position:
        x: 2092
        y: 134.96666666666667
      positionAbsolute:
        x: 2092
        y: 134.96666666666667
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    - data:
        context:
          enabled: false
          variable_selector: []
        model:
          completion_params:
            temperature: 0.4
          mode: chat
          name: claude-sonnet-5
          provider: langgenius/anthropic/anthropic
        prompt_template:
        - id: s主管摘要
          role: system
          text: '你是品保主管。用 2-3 句話為下面這份進料處理結果做出結論與指示（是否放行、要不要通知採購/供應商、後續追蹤重點）。繁體中文。


            {{#27agg.output#}}'
        - id: u主管摘要
          role: user
          text: 請開始。
        selected: false
        title: 主管摘要
        type: llm
        vision:
          enabled: false
      height: 88
      id: 27lsum
      position:
        x: 2434
        y: 180.3
      positionAbsolute:
        x: 2434
        y: 180.3
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    - data:
        outputs:
        - value_selector:
          - 27agg
          - output
          value_type: string
          variable: report
        - value_selector:
          - 27lsum
          - text
          value_type: string
          variable: summary
        selected: false
        title: 輸出
        type: end
      height: 114
      id: 27e
      position:
        x: 2776
        y: 181.96666666666667
      positionAbsolute:
        x: 2776
        y: 181.96666666666667
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
    viewport:
      x: -644.190372914031
      y: 364.1971604715144
      zoom: 0.3590577745647328
  rag_pipeline_variables: []
