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: end
      id: code1-to-end
      source: code1
      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
          completion_params:
            temperature: 0.2
        query:
        - start
        - query
        parameters:
        - name: category
          type: string
          description: 返品理由カテゴリ（指定の選択肢のいずれかを正確に返す）
          required: true
        - name: confidence
          type: number
          description: カテゴリ判定の確信度（0〜1）
          required: false
        reasoning_mode: prompt
        instruction: '以下の返品理由テキストから、最も適切なカテゴリを1つだけ選んでください。

          カテゴリは厳密に次のいずれかの日本語表記で返してください（表記を正確に一致させること）:

          1) サイズ違い

          2) 商品不良/破損

          3) 不満・期待外れ

          4) 注文間違い/重複

          5) 配送遅延

          6) その他

          出力形式:

          - category: 上記いずれかの文字列（必須）

          - confidence: 0〜1の推定確信度（任意）

          例: {"category": "サイズ違い", "confidence": 0.85}

          '
      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    category = str(inputs.get(\"\
          category\", \"\")).strip()\n    confidence = inputs.get(\"confidence\",\
          \ None)\n    try:\n        confidence_val = float(confidence) if confidence\
          \ is not None else None\n    except Exception:\n        confidence_val =\
          \ None\n    # カテゴリ -> 集計用ラベルのマッピング（辞書リテラルは使わずlist of tuplesで作成）\n    label_map\
          \ = dict([\n        (\"サイズ違い\", \"size_mismatch\"),\n        (\"商品不良/破損\"\
          , \"damaged\"),\n        (\"不満・期待外れ\", \"dissatisfied\"),\n        (\"注文間違い/重複\"\
          , \"order_error\"),\n        (\"配送遅延\", \"delivery_delay\"),\n        (\"\
          その他\", \"other\")\n    ])\n    label = label_map.get(category, \"other\"\
          )\n    # 出力テキスト整形（f-stringは禁止のためformatを使用）\n    conf_text = str(confidence_val)\
          \ if confidence_val is not None else \"N/A\"\n    result_text = \"カテゴリ:\
          \ \" + category + \" | ラベル: \" + label + \" | 確信度: \" + conf_text\n    #\
          \ 戻り値は必ずdictで返す\n    return dict(output=result_text, label=label, confidence=confidence_val)\n"
        variables:
        - value_selector:
          - extractor1
          - category
          variable: category
        - value_selector:
          - extractor1
          - confidence
          variable: confidence
        outputs:
          output:
            type: string
            children: null
          label:
            type: string
            children: null
          confidence:
            type: number
            children: null
      height: 90
      id: code1
      position:
        x: 680
        y: 282
      type: custom
      width: 244
    - data:
        title: 終了
        type: end
        outputs:
        - value_selector:
          - code1
          - output
          variable: result
      height: 90
      id: end
      position:
        x: 980
        y: 282
      type: custom
      width: 244
  hash: null
