app:
  description: 銀行（メガバンク）取引履歴要約：口座の過去取引から主要な収支傾向と疑わしい取引を抽出します。
  icon: 🏦
  icon_background: '#FFEAD5'
  mode: workflow
  name: 取引履歴要約ワークフロー
  use_icon_as_answer_icon: false
kind: app
version: 0.6.0
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload:
      image:
        enabled: false
    opening_statement: ''
    suggested_questions: []
    suggested_questions_after_answer:
      enabled: false
    text_to_speech:
      enabled: false
  graph:
    edges:
    - data:
        sourceType: start
        targetType: code
      id: start-to-code1
      source: start
      target: code1
    - data:
        sourceType: code
        targetType: llm
      id: code1-to-llm1
      source: code1
      target: llm1
    - data:
        sourceType: llm
        targetType: end
      id: llm1-to-end
      source: llm1
      target: end
    nodes:
    - data:
        title: 開始
        type: start
        variables:
        - label: query
          max_length: 2048
          options: []
          required: true
          type: paragraph
          variable: query
      height: 90
      id: start
      position:
        x: 80
        y: 282
      type: custom
      width: 244
    - data:
        title: 取引パース
        type: code
        code_language: python3
        code: "def _safe_str(v):\n    \"\"\"Convert any value to string safely.\"\"\
          \"\n    if v is None:\n        return \"\"\n    if isinstance(v, list):\n\
          \        return \"\\n\".join(str(i) for i in v)\n    return str(v)\n\ndef\
          \ _safe_list(v):\n    \"\"\"Ensure value is a list.\"\"\"\n    if v is None:\n\
          \        return []\n    if isinstance(v, str):\n        return [v]\n   \
          \ if isinstance(v, list):\n        return v\n    return [v]\n\ndef main(**kwargs)\
          \ -> dict:\n    inputs = kwargs\n    text = inputs.get(\"text\", \"\")\n\
          \    lines = [l.strip() for l in text.splitlines() if l.strip()]\n    transactions\
          \ = []\n    start_index = 0\n    if lines:\n        first = lines[0].lower()\n\
          \        if \"date\" in first or \"amount\" in first or \"金額\" in first:\n\
          \            start_index = 1\n    for line in lines[start_index:]:\n   \
          \     parts = [p.strip() for p in line.split(\",\")]\n        if len(parts)\
          \ < 3:\n            parts = [p.strip() for p in line.split(\"\\t\")]\n \
          \       if len(parts) < 3:\n            continue\n        date = parts[0]\n\
          \        desc = parts[1]\n        amount_str = parts[2].replace(\",\", \"\
          \").replace(\"¥\", \"\").replace(\"JPY\", \"\").strip()\n        try:\n\
          \            amount = float(amount_str)\n        except Exception:\n   \
          \         cleaned = \"\".join(ch for ch in amount_str if (ch.isdigit() or\
          \ ch in \".-\"))\n            try:\n                amount = float(cleaned)\
          \ if cleaned else 0.0\n            except Exception:\n                amount\
          \ = 0.0\n        bal = None\n        if len(parts) >= 4:\n            bal_str\
          \ = parts[3].replace(\",\", \"\").strip()\n            try:\n          \
          \      bal = float(bal_str)\n            except Exception:\n           \
          \     bal = None\n        transactions.append(dict(date=date, description=desc,\
          \ amount=amount, balance=bal))\n    return dict(transactions=transactions)\n"
        variables:
        - value_selector:
          - start
          - query
          variable: text
        outputs:
          transactions:
            type: array[object]
            children: null
      height: 90
      id: code1
      position:
        x: 380
        y: 282
      type: custom
      width: 244
    - data:
        title: 分析（傾向と疑わしい取引抽出）
        type: llm
        model:
          provider: openai
          name: gpt-5-mini
          mode: chat
          completion_params:
            temperature: 0.2
        prompt_template:
        - role: system
          text: あなたは銀行取引の専門家アナリストです。与えられた取引リストから主要な収支傾向を抽出し、疑わしい取引（高額な異常送金、同一先への短期反復送金、不審な説明文のキーワードなど）を検出・分類してください。出力は必ずJSON形式のみで行い、次のキーを含めてください：overall_trend,
            monthly_breakdown, suspicious_transactions, recommendations。monthly_breakdownは各月の入金合計と出金合計を含む配列とし、suspicious_transactionsは各要素が{date,
            description, amount, reason, priority}の形式を持つこと。日本語で回答してください。
        - role: user
          text: 'ユーザー入力: {{#start.query#}}


            解析済み取引データ: {{#code1.transactions#}}'
        vision:
          enabled: false
        memory: null
        context:
          enabled: false
      height: 90
      id: llm1
      position:
        x: 680
        y: 282
      type: custom
      width: 244
    - data:
        title: 終了
        type: end
        outputs:
        - value_selector:
          - llm1
          - text
          variable: result
      height: 90
      id: end
      position:
        x: 980
        y: 282
      type: custom
      width: 244
  hash: null
