app:
  description: ''
  icon: 🤖
  icon_background: '#FFEAD5'
  mode: workflow
  name: 阿里图片
  use_icon_as_answer_icon: false
kind: app
version: 0.1.5
workflow:
  conversation_variables: []
  environment_variables:
  - description: ''
    id: d44069e2-5859-4e6c-a499-a9bc6c22eef1
    name: model
    selector:
    - env
    - model
    value: wanx2.1-t2i-plus
    value_type: string
  - description: ''
    id: 90f6bcb8-5294-4749-ae39-4830ae0f7769
    name: aliapikey
    selector:
    - env
    - aliapikey
    value: sk-33130a715e2646998b470f75138f59ae
    value_type: string
  features:
    file_upload:
      allowed_file_extensions:
      - .JPG
      - .JPEG
      - .PNG
      - .GIF
      - .WEBP
      - .SVG
      allowed_file_types:
      - image
      allowed_file_upload_methods:
      - local_file
      - remote_url
      enabled: false
      fileUploadConfig:
        audio_file_size_limit: 50
        batch_count_limit: 10
        file_size_limit: 30
        image_file_size_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:
    edges:
    - data:
        isInIteration: false
        sourceType: start
        targetType: http-request
      id: 1740368660342-source-1740368851219-target
      selected: false
      source: '1740368660342'
      sourceHandle: source
      target: '1740368851219'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: http-request
        targetType: code
      id: 1740368851219-source-1740370104244-target
      selected: false
      source: '1740368851219'
      sourceHandle: source
      target: '1740370104244'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: code
        targetType: if-else
      id: 1740370104244-source-1740371748823-target
      selected: false
      source: '1740370104244'
      sourceHandle: source
      target: '1740371748823'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: end
      id: 1740371748823-721a69c6-e3b3-4157-b90c-b9bc3ac4d142-1740374050802-target
      selected: false
      source: '1740371748823'
      sourceHandle: 721a69c6-e3b3-4157-b90c-b9bc3ac4d142
      target: '1740374050802'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: end
      id: 1740371748823-false-1740374082986-target
      selected: false
      source: '1740371748823'
      sourceHandle: 'false'
      target: '1740374082986'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: if-else
        targetType: code
      id: 1740371748823-true-1740376831039-target
      selected: false
      source: '1740371748823'
      sourceHandle: 'true'
      target: '1740376831039'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: code
        targetType: http-request
      id: 1740376831039-source-1740760419258-target
      source: '1740376831039'
      sourceHandle: source
      target: '1740760419258'
      targetHandle: target
      type: custom
      zIndex: 0
    - data:
        isInIteration: false
        sourceType: http-request
        targetType: end
      id: 1740760419258-source-1740627300015-target
      source: '1740760419258'
      sourceHandle: source
      target: '1740627300015'
      targetHandle: target
      type: custom
      zIndex: 0
    nodes:
    - data:
        desc: ''
        selected: false
        title: 定义输入字段
        type: start
        variables:
        - label: text
          max_length: 256
          options: []
          required: true
          type: text-input
          variable: text
      height: 90
      id: '1740368660342'
      position:
        x: 30
        y: 287
      positionAbsolute:
        x: 30
        y: 287
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        authorization:
          config:
            api_key: '{{#env.aliapikey#}}'
            type: bearer
          type: api-key
        body:
          data:
          - type: text
            value: "{\n    \"model\": \"{{#env.model#}}\",\n    \"input\": {\n   \
              \     \"prompt\": \"{{#1740368660342.text#}}\"\n    },\n    \"parameters\"\
              : {\n        \"size\": \"1024*1024\",\n        \"n\":1\n    }\n\n}"
          type: raw-text
        desc: ''
        headers: 'X-DashScope-Async:enable

          Content-Type:application/json'
        method: post
        params: ''
        retry_config:
          max_retries: 3
          retry_enabled: true
          retry_interval: 100
        selected: false
        timeout:
          connect: 10
          max_connect_timeout: 0
          max_read_timeout: 0
          max_write_timeout: 0
          read: 10
          write: 10
        title: post 请求任务队列
        type: http-request
        url: https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis
        variables: []
      height: 152
      id: '1740368851219'
      position:
        x: 334
        y: 287
      positionAbsolute:
        x: 334
        y: 287
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        code: "def main(body: str, status_code: int) -> dict:\n    import json\n\n\
          \    try:\n        response_json = json.loads(body)\n\n        if \"output\"\
          \ in response_json and \"task_id\" in response_json[\"output\"]:\n     \
          \       task_id = response_json[\"output\"][\"task_id\"]\n            return\
          \ {\n                \"result\": task_id,\n                \"status_code\"\
          : str(status_code)\n            }\n        elif \"code\" in response_json\
          \ and \"message\" in response_json:\n            message = response_json[\"\
          message\"]\n            return {\n                \"result\": message,\n\
          \                    \"status_code\": str(status_code)\n               \
          \ \n            }\n        else:\n            return {\n               \
          \ \"result\": \"未知响应格式\",\n                    \"status_code\": str(status_code)\n\
          \                \n            }\n\n    except json.JSONDecodeError:\n \
          \       return {\n            \"result\": \"JSON 解析失败\",\n             \
          \   \"status_code\": str(status_code)\n            \n        }"
        code_language: python3
        desc: 将请求获取的数据格式化输出
        outputs:
          result:
            children: null
            type: string
          status_code:
            children: null
            type: string
        selected: false
        title: 格式化参数
        type: code
        variables:
        - value_selector:
          - '1740368851219'
          - body
          variable: body
        - value_selector:
          - '1740368851219'
          - status_code
          variable: status_code
      height: 82
      id: '1740370104244'
      position:
        x: 638
        y: 287
      positionAbsolute:
        x: 638
        y: 287
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        cases:
        - case_id: 'true'
          conditions:
          - comparison_operator: is
            id: f5e746da-5b54-4fd9-bdc7-1b50af9d072d
            value: '200'
            varType: string
            variable_selector:
            - '1740370104244'
            - status_code
          id: 'true'
          logical_operator: and
        - case_id: 721a69c6-e3b3-4157-b90c-b9bc3ac4d142
          conditions:
          - comparison_operator: is
            id: 735418b1-dc6d-449e-bf56-b89e8d78a344
            value: '401'
            varType: string
            variable_selector:
            - '1740370104244'
            - status_code
          id: 721a69c6-e3b3-4157-b90c-b9bc3ac4d142
          logical_operator: and
        desc: ''
        selected: false
        title: 根据状态码进行判断
        type: if-else
      height: 174
      id: '1740371748823'
      position:
        x: 942
        y: 287
      positionAbsolute:
        x: 942
        y: 287
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        outputs:
        - value_selector:
          - '1740370104244'
          - result
          variable: result
        selected: false
        title: 错误401
        type: end
      height: 90
      id: '1740374050802'
      position:
        x: 1246
        y: 287
      positionAbsolute:
        x: 1246
        y: 287
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        outputs:
        - value_selector:
          - '1740370104244'
          - result
          variable: result
        selected: false
        title: 错误其他
        type: end
      height: 90
      id: '1740374082986'
      position:
        x: 1246
        y: 417
      positionAbsolute:
        x: 1246
        y: 417
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        code: "import requests\nimport json\nimport time\n\ndef main(task_id: str,\
          \ aliapikey: str) -> dict:\n    dashscope_api_key = aliapikey\n    task_id\
          \ = task_id\n    task_status_value = \"PENDING\"  # 初始化 task_status_value\n\
          \    result1_value = \"\"  # 初始化 result1_value\n\n    while task_status_value\
          \ in [\"RUNNING\", \"PENDING\", \"SUSPENDED\"]:\n        dashscope_api_url\
          \ = f\"https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}\"\n       \
          \ headers = {\n            'Authorization': f'Bearer {dashscope_api_key}'\n\
          \        }\n\n        dashscope_response = requests.get(dashscope_api_url,\
          \ headers=headers)\n        dashscope_response.raise_for_status()\n    \
          \    dashscope_api_result = dashscope_response.json()\n        print(\"\
          Raw API Response:\", dashscope_api_result)\n        task_status_value =\
          \ dashscope_api_result['output']['task_status']\n\n        if task_status_value\
          \ == \"FAILED\":\n            result1_value = dashscope_api_result['output']['message']\n\
          \            return {\n                \"task_status\": task_status_value,\n\
          \                \"result1\": str(result1_value)\n            }\n      \
          \  elif task_status_value == \"SUCCEEDED\":\n            url_value = dashscope_api_result['output']['results'][0]['url']\n\
          \            return {\n                \"task_status\": task_status_value,\n\
          \                \"result1\": str(url_value)\n            }\n        elif\
          \ task_status_value in [\"RUNNING\", \"PENDING\", \"SUSPENDED\"]:\n    \
          \        time.sleep(3)\n        elif task_status_value == \"UNKNOWN\":\n\
          \            return {\n                \"task_status\": task_status_value,\n\
          \                \"result1\": \"UNKNOWN\"\n            }\n\n    return {\n\
          \        \"task_status\": task_status_value,\n        \"result1\": str(result1_value)\n\
          \    }"
        code_language: python3
        desc: ps：如果出现timeout，可增加失败重试次数
        outputs:
          result1:
            children: null
            type: string
          task_status:
            children: null
            type: string
        retry_config:
          max_retries: 3
          retry_enabled: true
          retry_interval: 5000
        selected: false
        title: 无限循环请求
        type: code
        variables:
        - value_selector:
          - '1740370104244'
          - result
          variable: task_id
        - value_selector:
          - env
          - aliapikey
          variable: aliapikey
      height: 124
      id: '1740376831039'
      position:
        x: 1246
        y: 547
      positionAbsolute:
        x: 1246
        y: 547
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        desc: ''
        outputs:
        - value_selector:
          - '1740760419258'
          - files
          variable: files
        selected: true
        title: 输出文件变量
        type: end
      height: 90
      id: '1740627300015'
      position:
        x: 1854
        y: 564
      positionAbsolute:
        x: 1854
        y: 564
      selected: true
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    - data:
        authorization:
          config: null
          type: no-auth
        body:
          data:
          - type: text
            value: ''
          type: none
        desc: 这样会下载下来，保存到本地服务器
        headers: ''
        method: get
        params: ''
        retry_config:
          max_retries: 3
          retry_enabled: true
          retry_interval: 100
        selected: false
        timeout:
          max_connect_timeout: 0
          max_read_timeout: 0
          max_write_timeout: 0
        title: get 图片地址
        type: http-request
        url: '{{#1740376831039.result1#}}'
        variables: []
      height: 151
      id: '1740760419258'
      position:
        x: 1550
        y: 564
      positionAbsolute:
        x: 1550
        y: 564
      selected: false
      sourcePosition: right
      targetPosition: left
      type: custom
      width: 244
    viewport:
      x: 0
      y: 0
      zoom: 0.7
