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: 180
      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    import re\n    import math\n    text\
          \ = str(inputs.get(\"query\", \"\"))\n    # ヘルパ: 指定するキーワードから数値と単位を抽出\n \
          \   def find_value(keys):\n        for key in keys:\n            pattern\
          \ = key + r'\\s*[:=]?\\s*(-?\\d+\\.?\\d*)\\s*(mm|cm|m|N|kN|kg)?'\n     \
          \       m = re.search(pattern, text, flags=re.IGNORECASE)\n            if\
          \ m:\n                try:\n                    val = float(m.group(1))\n\
          \                except:\n                    continue\n               \
          \ unit = m.group(2) or ''\n                return val, unit\n        return\
          \ None, None\n    width, wunit = find_value(['width','b','幅','W'])\n   \
          \ thickness, tunit = find_value(['thickness','t','厚さ'])\n    length, lunit\
          \ = find_value(['length','L','長さ'])\n    load, lounit = find_value(['load','P','荷重','力'])\n\
          \    # 単位変換\n    def to_n(value, unit):\n        if not unit:\n        \
          \    return value\n        u = unit.lower()\n        if u == 'mm':\n   \
          \         return value / 1000.0\n        if u == 'cm':\n            return\
          \ value / 100.0\n        if u == 'm':\n            return value\n      \
          \  if u == 'kg':\n            return value * 9.81\n        if u == 'kn':\n\
          \            return value * 1000.0\n        if u == 'n':\n            return\
          \ value\n        return value\n    # デフォルト値（入力不足時の保険）\n    if width is None:\n\
          \        width = 0.1\n        wunit = 'm'\n    if thickness is None:\n \
          \       thickness = 0.01\n        tunit = 'm'\n    if load is None:\n  \
          \      load = 1000.0\n        lounit = 'N'\n    # SI変換（幅・厚さは長さ単位→m、荷重はN）\n\
          \    width_m = to_n(width, wunit)\n    thickness_m = to_n(thickness, tunit)\n\
          \    load_n = to_n(load, lounit)\n    area = width_m * thickness_m\n   \
          \ stress = None\n    if area > 0:\n        stress = load_n / area\n    #\
          \ 材料強度の仮定（例: S235）\n    yield_strength = 235e6\n    safety_factor = None\n\
          \    if stress is not None and stress > 0:\n        safety_factor = yield_strength\
          \ / stress\n    # レポート作成\n    lines = []\n    lines.append(\"入力（解析に使用した値）:\"\
          )\n    lines.append(\"  幅 (m): \" + str(round(width_m, 6)))\n    lines.append(\"\
          \  厚さ (m): \" + str(round(thickness_m, 6)))\n    if length is not None:\n\
          \        lines.append(\"  長さ (入力あり): \" + str(length) + ((\" \" + (lunit\
          \ or \"\")) if lunit else \"\"))\n    lines.append(\"  荷重 (N): \" + str(round(load_n,\
          \ 2)))\n    lines.append(\"\")\n    lines.append(\"計算結果:\")\n    if stress\
          \ is None:\n        lines.append(\"  断面積が無効なため応力を算出できません。幅/厚さの入力を確認してください。\"\
          )\n    else:\n        lines.append(\"  単純軸応力 (Pa): \" + str(round(stress,\
          \ 2)))\n        lines.append(\"  単純軸応力 (MPa): \" + str(round(stress / 1e6,\
          \ 3)))\n        lines.append(\"  仮定した材料の降伏強さ (MPa): \" + str(round(yield_strength\
          \ / 1e6, 1)))\n        if safety_factor is not None:\n            lines.append(\"\
          \  安全係数: \" + str(round(safety_factor, 2)))\n    lines.append(\"\")\n  \
          \  lines.append(\"懸念事項:\")\n    if safety_factor is None:\n        lines.append(\"\
          \  - 入力不足で安全係数を算出できません。寸法（幅・厚さ）と荷重を明記してください。\")\n    else:\n        if safety_factor\
          \ < 1.0:\n            lines.append(\"  - 破壊の可能性あり（安全係数 < 1.0）。設計変更が必要です。\"\
          )\n        elif safety_factor < 1.5:\n            lines.append(\"  - 安全余裕が非常に小さい（安全係数\
          \ < 1.5）。厚さ増しや高強度材料を検討してください。\")\n        elif safety_factor < 2.0:\n  \
          \          lines.append(\"  - 中程度の安全余裕（1.5〜2.0）。荷重の増加や製造公差に注意してください。\")\n\
          \        else:\n            lines.append(\"  - 十分な安全余裕あり。ただし疲労、集中荷重、締結部周りの応力集中は別途検討が必要です。\"\
          )\n    lines.append(\"\")\n    lines.append(\"注記:\")\n    lines.append(\"\
          \  - 本計算は単純な軸応力計算です。曲げ、せん断、接合部、局所座屈、疲労、荷重の時変動などは考慮していません。\")\n    result\
          \ = \"\\n\".join(lines)\n    return dict(output=result)\n"
        variables:
        - value_selector:
          - start
          - query
          variable: query
        outputs:
          output:
            type: string
            children: null
      height: 200
      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.25
        prompt_template:
        - role: system
          text: あなたは構造設計の専門家です。以下の計算結果をわかりやすく解説し、信頼性評価、主要な懸念点、改善提案（優先度の高い順）を日本語で箇条書き形式で示してください。必要なら追加でユーザーに確認すべき情報を列挙してください。
        - role: user
          text: 'ユーザー入力:


            {{#start.query#}}


            計算要約:


            {{#code1.output#}}


            上記を踏まえて、設計上の注意点と具体的な改善案（例: 厚さを何mm増やす、材料を変更する等）を提示してください。'
        vision:
          enabled: false
        memory: null
        context:
          enabled: false
      height: 240
      id: llm1
      position:
        x: 680
        y: 282
      type: custom
      width: 244
    - data:
        title: 終了
        type: end
        outputs:
        - value_selector:
          - llm1
          - text
          variable: result
      id: end
      position:
        x: 980
        y: 282
      type: custom
      height: 90
      width: 244
  hash: null
