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: parameter-extractor
      id: start-to-extractor1
      source: start
      target: extractor1
    - data:
        sourceType: parameter-extractor
        targetType: code
      id: extractor1-to-code1
      source: extractor1
      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: parameter-extractor
        model:
          provider: openai
          name: gpt-5-mini
          mode: chat
        query:
        - start
        - query
        parameters:
        - name: principal
          type: number
          description: 融資額（円）
          required: true
        - name: annual_rate
          type: number
          description: 年利率（％）
          required: true
        - name: years
          type: number
          description: 返済年数（年）
          required: true
        reasoning_mode: prompt
        instruction: ユーザーの入力テキストから融資額（円）、年利率（％）、返済年数（年）を抽出してください。数値が与えられていない場合は0を返してください。
      height: 90
      id: extractor1
      position:
        x: 380
        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    # 入力を安全に取得\n    try:\n        p = float(inputs.get(\"\
          principal\", 0))\n    except Exception:\n        p = 0.0\n    try:\n   \
          \     annual = float(inputs.get(\"annual_rate\", 0))\n    except Exception:\n\
          \        annual = 0.0\n    try:\n        years = float(inputs.get(\"years\"\
          , 0))\n    except Exception:\n        years = 0.0\n    # 初期値\n    monthly\
          \ = 0.0\n    total = 0.0\n    if years > 0:\n        r = annual / 100.0\
          \ / 12.0\n        n = int(round(years * 12))\n        if r == 0.0:\n   \
          \         if n > 0:\n                monthly = p / float(n)\n          \
          \  else:\n                monthly = 0.0\n        else:\n            # 標準的な元利均等返済の計算式\n\
          \            denom = (1 + r) ** n - 1\n            if denom == 0.0:\n  \
          \              monthly = 0.0\n            else:\n                monthly\
          \ = p * r * (1 + r) ** n / denom\n        total = monthly * n\n    # 結果を文字列化して返す（小数点以下2桁に丸める）\n\
          \    monthly_str = str(round(monthly, 2))\n    total_str = str(round(total,\
          \ 2))\n    return dict(monthly_payment=monthly_str, total_payment=total_str)\n"
        variables:
        - value_selector:
          - extractor1
          - principal
          variable: principal
        - value_selector:
          - extractor1
          - annual_rate
          variable: annual_rate
        - value_selector:
          - extractor1
          - years
          variable: years
        outputs:
          monthly_payment:
            type: string
            children: null
          total_payment:
            type: string
            children: null
      height: 90
      id: code1
      position:
        x: 680
        y: 282
      type: custom
      width: 244
    - data:
        title: 結果生成
        type: llm
        model:
          provider: openai
          name: gpt-5-mini
          mode: chat
          completion_params:
            temperature: 0.6
        prompt_template:
        - role: system
          text: 'あなたは銀行の返済シミュレータです。計算結果を日本語で分かりやすく説明してください。出力形式は以下のようにしてください。月々の返済額:
            XXXX円 総返済額: YYYY円 計算根拠: （簡潔に）'
        - role: user
          text: 'ユーザー入力: {{#start.query#}}


            計算結果（元データ参照）:

            月々の返済額: {{#code1.monthly_payment#}}円

            総返済額: {{#code1.total_payment#}}円


            上記を受けて、短い説明と計算根拠を日本語で出力してください。'
        vision:
          enabled: false
        memory: null
        context:
          enabled: false
      height: 90
      id: llm1
      position:
        x: 980
        y: 282
      type: custom
      width: 244
    - data:
        title: 終了
        type: end
        outputs:
        - value_selector:
          - llm1
          - text
          variable: result
      height: 90
      id: end
      position:
        x: 1280
        y: 282
      type: custom
      width: 244
  hash: null
