app:
  description: 技術相談・要件をもとに、過去事例と技術情報KBを参照して提案方針を生成するAI技術相談アシスタント。Context / Harness / Graph Engineering の実装例。
  icon: 🤖
  icon_background: '#FFEAD5'
  icon_type: emoji
  mode: workflow
  name: AI技術相談アシスタント
  use_icon_as_answer_icon: false

# ============================================================
# 事前準備
# ============================================================
# 1. Dify の「ナレッジ」で以下 2 つの KB を作成してください。
#    - 過去事例KB  : 類似案件・提案書・議事録などを登録
#    - 技術情報KB  : 製品カタログ・技術仕様書・FAQ などを登録
# 2. 下記 YOUR_PAST_CASES_KNOWLEDGE_ID / YOUR_TECH_INFO_KNOWLEDGE_ID を
#    各 KB の ID（Dify 管理画面 > ナレッジ > 詳細 URL 末尾の文字列）に置き換えてください。
# 3. langgenius/cohere プラグイン（Rerank 用）と
#    langgenius/openai プラグイン（LLM 用）を Dify に追加してください。
# ============================================================

dependencies:
- current_identifier: null
  type: marketplace
  value:
    marketplace_plugin_unique_identifier: langgenius/cohere:0.0.17@e83d4ff43d1decc03885b90216eb683818dd3806f29195759c85c77b9c64df75
    version: null
- current_identifier: null
  type: marketplace
  value:
    marketplace_plugin_unique_identifier: langgenius/openai:1.0.4@3b49ff900a77c9b2cfba21e3cd1180fbfd7edf5ec008bc20564541c7a3914295
    version: null
kind: app
version: 0.7.0
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload:
      allowed_file_extensions: []
      allowed_file_types:
      - document
      allowed_file_upload_methods:
      - local_file
      - remote_url
      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: 50
        image_file_batch_limit: 10
        image_file_size_limit: 10
        knowledge_file_size_limit: 15
        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
        - remote_url
      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:
    # ----------------------------------------------------------
    # [Graph Engineering] ノード間の接続（DAG）
    # start から 3 方向に並列ファンアウト → proposal_llm に合流
    # → verify と sales が並列 → sales で合流 → end
    # ----------------------------------------------------------
    edges:
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: start
        targetType: llm
      id: start-to-requirements
      source: start
      sourceHandle: source
      target: requirements_llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: start
        targetType: knowledge-retrieval
      id: start-to-past-cases
      source: start
      sourceHandle: source
      target: past_cases
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: start
        targetType: knowledge-retrieval
      id: start-to-tech-info
      source: start
      sourceHandle: source
      target: tech_info
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: knowledge-retrieval
        targetType: template-transform
      id: past-cases-to-text
      source: past_cases
      sourceHandle: source
      target: past_cases_text
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: knowledge-retrieval
        targetType: template-transform
      id: tech-info-to-text
      source: tech_info
      sourceHandle: source
      target: tech_info_text
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: llm
      id: requirements-to-proposal
      source: requirements_llm
      sourceHandle: source
      target: proposal_llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: template-transform
        targetType: llm
      id: past-cases-text-to-proposal
      source: past_cases_text
      sourceHandle: source
      target: proposal_llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: template-transform
        targetType: llm
      id: tech-info-text-to-proposal
      source: tech_info_text
      sourceHandle: source
      target: proposal_llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: llm
      id: proposal-to-verify
      source: proposal_llm
      sourceHandle: source
      target: verify_llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: template-transform
        targetType: llm
      id: past-cases-text-to-verify
      source: past_cases_text
      sourceHandle: source
      target: verify_llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: template-transform
        targetType: llm
      id: tech-info-text-to-verify
      source: tech_info_text
      sourceHandle: source
      target: verify_llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: llm
      id: proposal-to-output
      source: proposal_llm
      sourceHandle: source
      target: output_llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: llm
      id: verify-to-output
      source: verify_llm
      sourceHandle: source
      target: output_llm
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        isInLoop: false
        sourceType: llm
        targetType: end
      id: output-to-end
      source: output_llm
      sourceHandle: source
      target: end
      targetHandle: target
      type: custom
      zIndex: 0
    nodes:
    # ----------------------------------------------------------
    # 入力
    # ----------------------------------------------------------
    - data:
        selected: false
        title: 技術相談・要件入力
        type: start
        variables:
        - default: ''
          hint: 顧客・社内からの技術相談、要件定義書、商談メモなどを入力してください
          label: 技術相談内容 / 要件
          options: []
          placeholder: 例：全社のファイルサーバーをクラウドに移行したい。セキュリティ・コスト・運用の観点で最適な構成を検討している...
          required: true
          type: paragraph
          variable: consultation_text
      height: 108
      id: start
      position:
        x: 80
        y: 450
      positionAbsolute:
        x: 80
        y: 450
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 242
      zIndex: 0

    # ----------------------------------------------------------
    # [Prompt Engineering] 要件の構造化
    # system prompt で出力フォーマットを厳密に指定する層
    # ----------------------------------------------------------
    - data:
        context:
          enabled: false
          variable_selector: []
        memory:
          query_prompt_template: ''
          role_prefix:
            assistant: ''
            user: ''
          window:
            enabled: false
            size: 10
        model:
          completion_params: {}
          mode: chat
          name: gpt-4o-mini
          provider: langgenius/openai/openai
        prompt_template:
        - id: req-system
          role: system
          text: |
            あなたはIT技術相談を支援するアシスタントです。
            入力された技術相談・要件を分析し、後続の知識検索と提案作成に利用できるよう構造化してください。

            以下の項目を整理してください。
            1. 相談・依頼の目的
            2. 現状
            3. 課題・問題
            4. 機能要件
            5. 非機能要件（性能・可用性・セキュリティ等）
            6. システム・インフラ要件
            7. 運用要件
            8. 規模（ユーザー数・拠点数・データ量等）
            9. スケジュール・制約
            10. 明確になっていない事項

            推測で事実を追加せず、不明なものは「不明」としてください。
        - id: req-user
          role: user
          text: |
            以下の技術相談内容・要件を分析してください。

            {{#start.consultation_text#}}
        selected: false
        title: '① [Prompt] 要件整理'
        type: llm
        vision:
          enabled: false
      height: 87
      id: requirements_llm
      position:
        x: 400
        y: 150
      positionAbsolute:
        x: 400
        y: 150
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 241
      zIndex: 0

    # ----------------------------------------------------------
    # [Context Engineering] 過去事例KB の Hybrid Search + Rerank
    # 相談内容を query として KB から関連チャンクを取得する層
    # ※ dataset_ids の値を実際の KB ID に置き換えてください
    # ----------------------------------------------------------
    - data:
        dataset_ids:
        - YOUR_PAST_CASES_KNOWLEDGE_ID
        multiple_retrieval_config:
          reranking_enable: true
          reranking_mode: reranking_model
          reranking_model:
            model: rerank-multilingual-v3.0
            provider: langgenius/cohere/cohere
          score_threshold: 0.5
          top_k: 6
        query_attachment_selector: []
        query_variable_selector:
        - start
        - consultation_text
        retrieval_mode: multiple
        selected: false
        title: '② [Context] 過去事例KB'
        type: knowledge-retrieval
      height: 89
      id: past_cases
      position:
        x: 400
        y: 450
      positionAbsolute:
        x: 400
        y: 450
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 241
      zIndex: 0

    # ----------------------------------------------------------
    # [Context Engineering] 技術情報KB の Hybrid Search + Rerank
    # 製品仕様・技術資料から関連情報を取得する層
    # ※ dataset_ids の値を実際の KB ID に置き換えてください
    # ----------------------------------------------------------
    - data:
        dataset_ids:
        - YOUR_TECH_INFO_KNOWLEDGE_ID
        multiple_retrieval_config:
          reranking_enable: true
          reranking_mode: reranking_model
          reranking_model:
            model: rerank-multilingual-v3.0
            provider: langgenius/cohere/cohere
          score_threshold: 0.5
          top_k: 6
        query_attachment_selector: []
        query_variable_selector:
        - start
        - consultation_text
        retrieval_mode: multiple
        selected: false
        title: '③ [Context] 技術情報KB'
        type: knowledge-retrieval
      height: 89
      id: tech_info
      position:
        x: 400
        y: 750
      positionAbsolute:
        x: 400
        y: 750
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 241
      zIndex: 0

    # ----------------------------------------------------------
    # [Context Engineering] KB チャンクをテキストに整形
    # LLM へ渡す前に chunks オブジェクトを読みやすいテキストに変換
    # ----------------------------------------------------------
    - data:
        selected: false
        template: |
          {% if chunks|length == 0 %}
          （該当する事例が見つかりませんでした）
          {% else %}
          {% for item in chunks %}■ {{ item.title }}
          {{ item.content }}

          {% endfor %}
          {% endif %}
        title: '②-2 [Context] 事例テキスト整形'
        type: template-transform
        variables:
        - value_selector:
          - past_cases
          - result
          variable: chunks
      height: 51
      id: past_cases_text
      position:
        x: 700
        y: 450
      positionAbsolute:
        x: 700
        y: 450
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 241
      zIndex: 0
    - data:
        selected: false
        template: |
          {% if chunks|length == 0 %}
          （該当する技術情報が見つかりませんでした）
          {% else %}
          {% for item in chunks %}■ {{ item.title }}
          {{ item.content }}

          {% endfor %}
          {% endif %}
        title: '③-2 [Context] 技術情報テキスト整形'
        type: template-transform
        variables:
        - value_selector:
          - tech_info
          - result
          variable: chunks
      height: 51
      id: tech_info_text
      position:
        x: 700
        y: 750
      positionAbsolute:
        x: 700
        y: 750
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 241
      zIndex: 0

    # ----------------------------------------------------------
    # [Graph Engineering] 提案方針の生成
    # 3 つの上流（要件整理・事例・技術情報）を受け取り合流するノード
    # ----------------------------------------------------------
    - data:
        context:
          enabled: false
          variable_selector: []
        memory:
          query_prompt_template: ''
          role_prefix:
            assistant: ''
            user: ''
          window:
            enabled: false
            size: 10
        model:
          completion_params: {}
          mode: chat
          name: gpt-4o-mini
          provider: langgenius/openai/openai
        prompt_template:
        - id: proposal-system
          role: system
          text: |
            あなたはIT技術相談・提案を支援するシニアアシスタントです。
            顧客要件、過去事例、技術情報をもとに、実現可能性を意識した提案方針を作成してください。

            重要ルール：
            - 過去事例・技術情報KBにない事実は断定しない。
            - 技術の適合性に確信がない場合は「要確認」とする。
            - 顧客課題と提案内容の対応関係を明確にする。
            - 不足情報は追加確認事項として整理する。
            - 具体的な価格・費用・金額・見積り数値は一切記載しない。
            - 「顧客からの元の相談・質問」に対する直接回答を出力の最初に
              「0. 質問への直接回答」として 2〜3 行で簡潔にまとめる。
            - 技術・製品候補には出典を明記する。
              「技術情報KBより」または「一般的な業界知識より（KB記載なし）」のどちらかを必ず付記する。
            - KB に存在しない具体的な型番・製品名・数値には「（要確認：KB記載なし）」タグを付ける。
              ただし一般的な見込み・意見の表現（「〜が期待される」等）にはタグを付けない。
            - 同じ語句へのタグは文書全体で最初の 1 箇所のみ。タグの乱用は禁止。

            出力項目：
            0. 質問への直接回答
            1. 顧客課題
            2. 提案コンセプト
            3. 推奨アーキテクチャ
            4. 推奨技術・製品候補（出典明記）
            5. 提案理由
            6. 導入ステップ
            7. 運用イメージ
            8. 想定リスク
            9. 追加確認事項
        - id: proposal-user
          role: user
          text: |
            【顧客からの元の相談・質問】
            {{#start.consultation_text#}}

            【要件（構造化）】
            {{#requirements_llm.text#}}

            【過去事例KBの検索結果】
            {{#past_cases_text.output#}}

            【技術情報KBの検索結果】
            {{#tech_info_text.output#}}

            上記をもとに、今回の提案方針を作成してください。
        selected: false
        title: '④ [Graph] 提案方針生成'
        type: llm
        vision:
          enabled: false
      height: 87
      id: proposal_llm
      position:
        x: 1020
        y: 450
      positionAbsolute:
        x: 1020
        y: 450
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 241
      zIndex: 0

    # ----------------------------------------------------------
    # [Harness Engineering] QA 検証ノード
    # 提案内容を KB と照合し、出典誤り・数値断定・タグ漏れを検出する安全機構
    # ----------------------------------------------------------
    - data:
        context:
          enabled: false
          variable_selector: []
        memory:
          query_prompt_template: ''
          role_prefix:
            assistant: ''
            user: ''
          window:
            enabled: false
            size: 10
        model:
          completion_params: {}
          mode: chat
          name: gpt-4o-mini
          provider: langgenius/openai/openai
        prompt_template:
        - id: verify-system
          role: system
          text: |
            あなたは提案書の品質チェック（QA）担当です。
            ④で生成された提案方針の下書きを、実際の検索結果と照合してチェックしてください。

            チェック観点：
            1. 出典表記（「技術情報KBより」/「一般的な業界知識より」）が、
               実際の検索結果の内容と一致しているか。
               KB に存在しない技術・製品を「KBより」と誤表記していないか。
            2. 検索結果に記載のない具体的な数値・価格・費用・納期・SLA・性能値を
               断定的な事実として書いていないか（金額例は特に厳しくチェック）。
            3. KB 本文に存在しない具体的な型番・製品名が
               「（要確認：KB記載なし）」タグなしに使われていないか。
               既にタグが付いている箇所は「対応済み」として扱い、指摘しない。
            4. タグの乱用（一般的な見込み・意見表現にまでタグが付いている等）が
               起きていないか。
            5. 出力項目（0〜9）が過不足なく含まれているか。
            6. 相談内容に対して実際に答えになっているか。

            問題がなければ「重大な問題なし」と明記してください。
            問題がある場合は、箇条書きで具体的に（該当箇所・語句・理由）指摘してください。
            400 字程度を目安に簡潔にまとめてください。
            この出力は社内 QA メモとして使われ、顧客には見せません。
        - id: verify-user
          role: user
          text: |
            【提案方針の下書き（④の出力）】
            {{#proposal_llm.text#}}

            【過去事例KBの検索結果】
            {{#past_cases_text.output#}}

            【技術情報KBの検索結果】
            {{#tech_info_text.output#}}

            上記を照合し、QAチェック結果をまとめてください。
        selected: false
        title: '④-2 [Harness] QA検証'
        type: llm
        vision:
          enabled: false
      height: 87
      id: verify_llm
      position:
        x: 1214
        y: 837
      positionAbsolute:
        x: 1214
        y: 837
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 241
      zIndex: 0

    # ----------------------------------------------------------
    # [Graph Engineering] 最終整理・出力ノード
    # 提案方針（④）と QA 結果（④-2）を受け取り、配布可能な形式に統合する
    # ----------------------------------------------------------
    - data:
        context:
          enabled: false
          variable_selector: []
        memory:
          query_prompt_template: ''
          role_prefix:
            assistant: ''
            user: ''
          window:
            enabled: false
            size: 10
        model:
          completion_params: {}
          mode: chat
          name: gpt-4o-mini
          provider: langgenius/openai/openai
        prompt_template:
        - id: output-system
          role: system
          text: |
            あなたはIT技術相談支援AIの出力整理担当です。
            以下の提案方針を、担当者が次回打合せや社内検討にそのまま利用できる形式に整理してください。

            重要：
            - ④-2 の QA チェック結果で「KB記載なしのタグ漏れ」「根拠のない数値」として
              具体的に指摘された語句・数値は、本文（1〜9 章）で見つけ次第
              「（要確認：KB記載なし）」を付けるか、断定表現を「要確認」に弱めること。
            - 「タグの乱用」が指摘された場合は、対象外箇所から不要な「要確認」タグを削除し
              自然な文章に戻すこと。
            - 根拠のない製品名・数値・価格・納期は追加しないこと。

            # AI技術相談 提案レポート

            ## 0. 質問への直接回答
            ## 1. 案件概要
            ## 2. 顧客課題
            ## 3. 提案コンセプト
            ## 4. 推奨ソリューション
            ## 5. 提案のポイント
            ## 6. 類似事例から得られる示唆
            ## 7. 追加確認事項
            ## 8. 想定リスク
            ## 9. 次回アクション
            ## 10. 社内QAメモ（配布前確認・顧客には見せないこと）

            「10. 社内QAメモ」には④-2 の QA チェック結果をそのまま要約して記載してください。
        - id: output-user
          role: user
          text: |
            【顧客からの元の相談・質問】
            {{#start.consultation_text#}}

            【提案方針（④の出力）】
            {{#proposal_llm.text#}}

            【QAチェック結果（④-2 の出力）】
            {{#verify_llm.text#}}

            上記を整理してください。
        selected: false
        title: '⑤ [Graph] 最終整理・出力'
        type: llm
        vision:
          enabled: false
      height: 87
      id: output_llm
      position:
        x: 1620
        y: 450
      positionAbsolute:
        x: 1620
        y: 450
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 241
      zIndex: 0

    # ----------------------------------------------------------
    # 出力
    # ----------------------------------------------------------
    - data:
        outputs:
        - value_selector:
          - output_llm
          - text
          value_type: string
          variable: result
        selected: false
        title: 提案レポート（出力）
        type: end
      height: 87
      id: end
      position:
        x: 1920
        y: 450
      positionAbsolute:
        x: 1920
        y: 450
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 241
      zIndex: 0
    viewport:
      x: -232
      y: -32
      zoom: 0.55
  rag_pipeline_variables: []
