> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ai.relyt.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Create job

> 分析或探索您的数据。您可以通过此接口根据您的数据进行提问，立即获取洞察。

在 Relyt AI 中，**任务（Job）** 即 Relyt AI 根据您的请求（例如提示词或其他工作流）而生成并执行的问答过程。



## OpenAPI

````yaml post /v2/team/jobs
openapi: 3.0.1
info:
  title: Team Open API Version 2 中文版本
  description: ''
  version: 1.0.0
servers:
  - url: https://app.ai.relyt.cn/app/api
    description: 体验环境
security:
  - apikey-header-x-pd-api-key: []
tags:
  - name: Session
  - name: Dataset
  - name: Data source
  - name: File
  - name: Job
paths:
  /v2/team/jobs:
    post:
      tags:
        - Job
      summary: Create job
      description: |-
        分析或探索您的数据。您可以通过此接口根据您的数据进行提问，立即获取洞察。

        在 Relyt AI 中，**任务（Job）** 即 Relyt AI 根据您的请求（例如提示词或其他工作流）而生成并执行的问答过程。
      parameters:
        - name: x-pd-external-trace-id
          in: header
          description: >-
            您本地系统中设置的 Trace ID，至多支持 128 个字符。当请求发生错误时，可以将此 ID 提供给 Relyt AI
            团队，协助进行故障排查。
          required: false
          example: ''
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                session_id:
                  type: string
                  description: >-
                    会话 ID。


                    如需查看项目中存在的会话，请调用 [GET
                    /v2team/sessions](/api-reference/list-sessions) 接口。
                stream:
                  type: boolean
                  description: >-
                    是否使用流式返回。如果设置为 `true`，Relyt AI
                    将实时向客户端发送回答更新，持续传输实时可用的数据。如果设置为
                    `false`，则在整个回答完成后，一次性返回完整的响应。


                    如不指定，则使用默认值 `false`。


                    关于如何理解流式返回的内容，请参考
                    [流式返回中的内容说明](/api-reference/streaming#content-description)。
                  default: false
                question:
                  type: string
                  description: 您的问题（即提示词）。
                dataset_id:
                  type: string
                  description: >-
                    任务关联的数据集 ID。 


                    如需查询您有访问权限的数据集列表，请调用 [GET
                    /v2/team/datasets](/api-reference/list-datasets) 接口。
                datasource_ids:
                  type: array
                  items:
                    type: string
                  description: 指定在任务中使用的数据源的 ID。最多可以指定 1,000 个数据源。
                output_language:
                  type: string
                  description: |-
                    Relyt AI 的回复语言。例如，当设置为 `ZH-CN` 时，则 Relyt AI 以简体中文回复。可选值包括：

                    - `AUTO`：根据提示词自动识别
                    - `EN`：英语
                    - `ES`：西班牙语
                    - `AR`：阿拉伯语
                    - `PT`：葡萄牙语
                    - `ID`：印尼语
                    - `JA`：日语
                    - `RU`：俄语
                    - `HI`：印地语
                    - `FR`：法语
                    - `DE`：德语
                    - `VI`：越南语
                    - `TR`：土耳其语
                    - `PL`：波兰语
                    - `IT`：意大利语
                    - `KO`：韩语
                    - `ZH-CN`：简体中文
                    - `ZH-TW`：繁体中文
                  enum:
                    - AUTO
                    - EN
                    - ES
                    - AR
                    - PT
                    - ID
                    - JA
                    - RU
                    - HI
                    - FR
                    - DE
                    - VI
                    - TR
                    - PL
                    - IT
                    - KO
                    - ZH-CN
                    - ZH-TW
                  default: AUTO
                job_mode:
                  type: string
                  description: |-
                    任务类型。可选值包括：

                    - `AUTO`：Relyt AI 根据你的提问进行意图判断，决定该任务为数据分析任务或信息检索任务。
                    - `DATA_ANALYTICS`：Relyt AI 会根据你的输入进行数据分析。

                    如不指定，则使用会话的 `job_mode` 设置。
                  enum:
                    - AUTO
                    - DATA_ANALYTICS
                  default: AUTO
                user_id:
                  type: string
                  description: 用户 ID，即您在组织中的唯一身份标识。
              required:
                - question
                - session_id
                - user_id
            examples:
              '1':
                value:
                  session_id: cxxdgegeegeg3433fff
                  user_id: tmm-dafasdfasdfasdf
                  stream: true
                  question: Hello World
                  dataset_id: cm1gjmg8e0057r3x22v1fdu8m
                  datasource_ids:
                    - cm1gjmmoo0001h0x24uk1xgu9
                  output_language: AUTO
                  job_mode: AUTO
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    description: >-
                      状态码。**0** 表示操作成功。其它值则表示操作失败。如需进行错误排查，请参阅
                      [错误码](/introduction/error-codes)。
                  data:
                    type: object
                    properties:
                      job_id:
                        type: string
                        description: 任务 ID，即会话中该任务的唯一标识。
                      blocks:
                        type: array
                        items:
                          $ref: '#/components/schemas/BlockDTO'
                          description: 构成整个答案的内容块列表。
                        description: 构成完整答案的答案块列表。
                    required:
                      - job_id
                      - blocks
                    description: 任务对象。
                required:
                  - data
                  - code
              examples:
                '1':
                  summary: Stream=false
                  value:
                    code: 0
                    data:
                      job_id: job-cm3ikdeuj02zk01l1yeuirt77
                      blocks:
                        - type: CODE
                          content: |-
                            ```python

                            import pandas as pd

                            def invoke(input_0: pd.DataFrame) -> pd.DataFrame:
                                '''
                                input_0: pd.DataFrame  makeovermonday-a-century-of-global-deaths-from-disasters_decadal-deaths-disasters-type.csv
                                '''
                                # Group by 'Year' and sum the deaths for each type of disaster
                                aggregated_data = input_0.groupby('Year').sum().reset_index()
                                
                                # Select only the columns related to deaths
                                death_columns = [
                                    'Deaths - Drought (decadal)', 'Deaths - Flood (decadal)', 
                                    'Deaths - Earthquake (decadal)', 'Deaths - Extreme weather (decadal)', 
                                    'Deaths - Extreme temperature (decadal)', 'Deaths - Volcanic activity (decadal)', 
                                    'Deaths - Wildfire (decadal)', 'Deaths - Glacial lake outburst flood (decadal)', 
                                    'Deaths - Dry mass movement (decadal)', 'Deaths - Wet mass movement (decadal)', 
                                    'Deaths - Fog (decadal)'
                                ]
                                
                                # Create a new DataFrame with the aggregated results
                                output = aggregated_data[['Year'] + death_columns]
                                
                                # Rename columns to be more descriptive
                                output.columns = ['Decade'] + [col.replace('Deaths - ', '').replace(' (decadal)', '') for col in death_columns]
                                
                                return output

                            ```
                          group_id: 33063572-6e88-4912-8e2d-4166bcc8caee
                          group_name: >-
                            Analyze the dataset to observe the trend of deaths
                            caused by different types of natural disasters over
                            the past century. This involves aggregating the data
                            by decade and calculating the total number of deaths
                            for each type of disaster to identify any changes in
                            trends.
                          stage: Analyze
                        - type: TABLE
                          content:
                            url: >-
                              https://static.powerdrill.ai/tmp_datasource_cache/code_result/cm37bchx106e301l1v9yf67yc/e24b6a5f-fdb8-48ca-ae35-dc91ac8e8ef7.csv
                            name: trend_data.csv
                            expires_at: '2024-11-21T09:56:34.290544Z'
                          group_id: 33063572-6e88-4912-8e2d-4166bcc8caee
                          group_name: >-
                            Analyze the dataset to observe the trend of deaths
                            caused by different types of natural disasters over
                            the past century. This involves aggregating the data
                            by decade and calculating the total number of deaths
                            for each type of disaster to identify any changes in
                            trends.
                          stage: Analyze
                        - type: IMAGE
                          content:
                            url: >-
                              https://static.powerdrill.ai/tmp_datasource_cache/code_result/cm37bchx106e301l1v9yf67yc/81b75a33-a223-4954-9680-9f397872c8ad.png
                            name: >-
                              Trend of Deaths from Natural Disasters Over the
                              Century
                            expires_at: '2024-11-21T09:56:34.290544Z'
                          group_id: 7501680b-5879-441b-bd96-f58b1029ae17
                          group_name: >-
                            Visualize the trend data to show how the number of
                            deaths from different types of natural disasters has
                            changed over the past century. Use line charts to
                            represent the trends for each disaster type, which
                            will help in understanding the impact of measures
                            and technological advancements on reducing deaths.
                          stage: Analyze
                        - type: MESSAGE
                          content: >+


                            `Analyzing Conclusions` 


                            ### Analysis of Trends in the Number of Deaths from
                            Natural Disasters 


                            #### Data Analysis

                          group_id: b842aca7-6fd5-4190-85fa-97085e473877
                          group_name: Conclusions
                          stage: Respond
                        - type: TABLE
                          content:
                            url: >-
                              https://static.powerdrill.ai/tmp_datasource_cache/code_result/cm37bchx106e301l1v9yf67yc/e24b6a5f-fdb8-48ca-ae35-dc91ac8e8ef7.csv
                            name: trend_data.csv
                            expires_at: '2024-11-21T09:56:34.290544Z'
                          group_id: b842aca7-6fd5-4190-85fa-97085e473877
                          group_name: Conclusions
                          stage: Respond
                        - type: MESSAGE
                          content: >+


                            - **Droughts and Floods**: In the early 20th
                            century, droughts and floods caused extremely high
                            death tolls, particularly during the 1920s and
                            1930s.

                            - **Earthquakes and Extreme Weather**: Earthquakes
                            and extreme weather also led to significant death
                            tolls throughout the century, especially in the
                            1970s and 1990s.

                            - **Extreme Temperatures and Volcanic Activity**:
                            These disasters had relatively lower death tolls,
                            but in certain decades, such as the 2000s, deaths
                            caused by extreme temperatures increased.


                            #### Trend Visualization

                          group_id: b842aca7-6fd5-4190-85fa-97085e473877
                          group_name: Conclusions
                          stage: Respond
                        - type: IMAGE
                          content:
                            url: >-
                              https://static.powerdrill.ai/tmp_datasource_cache/code_result/cm37bchx106e301l1v9yf67yc/81b75a33-a223-4954-9680-9f397872c8ad.png
                            name: >-
                              Trend of Deaths from Natural Disasters Over the
                              Century
                            expires_at: '2024-11-21T09:56:34.290544Z'
                          group_id: b842aca7-6fd5-4190-85fa-97085e473877
                          group_name: Conclusions
                          stage: Respond
                        - type: MESSAGE
                          content: >-


                            - **Overall Trend**: The chart shows that although
                            certain decades experienced spikes in death tolls
                            caused by natural disasters, the overall trend is
                            declining.

                            - **Impact of Technology and Measures**: Over time,
                            advancements in technology and the implementation of
                            disaster prevention measures are likely key factors
                            in reducing death tolls.


                            #### Conclusions and Insights

                            - **Technological Advancements**: Modern
                            technological progress, such as improved early
                            warning systems and better construction techniques,
                            may have reduced the fatalities caused by
                            earthquakes and extreme weather.

                            - **Disaster Prevention Measures**: The enhancement
                            of disaster prevention measures and emergency
                            response capabilities on a global scale has likely
                            contributed to the decreased fatality rates of
                            natural disasters.
                          group_id: b842aca7-6fd5-4190-85fa-97085e473877
                          group_name: Conclusions
                          stage: Respond
                        - type: SOURCES
                          content:
                            - source: >-
                                makeovermonday-a-century-of-global-deaths-from-disasters_decadal-deaths-disasters-type.csv
                              datasource_id: clxin6l9200oo01l1457bolx3
                              dataset_id: clxin6l8400ok01l1ff2m0s25
                              file_type: csv
                          group_id: ''
                          group_name: ''
                          stage: Respond
                        - type: QUESTIONS
                          content:
                            - >-
                              Analyze the trends in death tolls from different
                              types of natural disasters over the past century
                              and explore which disaster types have shown the
                              most significant reduction in fatalities.
                            - >-
                              Study the technological advancements and measures
                              in responding to natural disasters across
                              different regions globally, and analyze how these
                              differences have influenced changes in death tolls
                              in each region.
                            - >-
                              Explore how future technological advancements and
                              policy measures could further reduce fatalities
                              caused by natural disasters, and assess their
                              feasibility and potential impacts.
                          group_id: '-1'
                          stage: Respond
          headers:
            x-pd-trace-id:
              example: ''
              required: true
              description: Relyt AI 返回的 Trace ID。当请求发生错误时，可以将此 ID 提供给 Relyt AI 团队，协助进行故障排查。
              schema:
                type: string
        '400':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              examples:
                '2':
                  summary: '400'
                  value:
                    code: 210021
                    msg: Job quota exceeded
          headers: {}
        '403':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              examples:
                '3':
                  summary: '403'
                  value:
                    code: 1003
                    msg: insufficient.authentication
          headers: {}
        '500':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              examples:
                '4':
                  summary: '500'
                  value:
                    code: 210020
                    msg: >-
                      Something went wrong during job execution. Please try
                      again.
          headers: {}
      deprecated: false
      security:
        - apikey-header-x-pd-api-key: []
components:
  schemas:
    BlockDTO:
      type: object
      properties:
        type:
          type: string
          description: |-
            答案块（Block）的内容类型。可能值为：

            - `MESSAGE`：表示内容是文本。
            - `CODE`：表示内容是代码片段。
            - `TABLE`：表示内容是表格。
            - `IMAGE`：表示内容是图片。
            - `SOURCE`：表示内容是答案块的参考来源。
            - `QUESTIONS`：即 Relyt AI 生成的建议问题，帮助引导您后续的数据探索和分析。
          enum:
            - MESSAGE
            - CODE
            - TABLE
            - SOURCES
            - QUESTIONS
        content:
          type: string
          description: |-
            答案块的内容，随 `type` 值而异：

            - 当 `type` 为 `MESSAGE` 时，内容为一段文本。
            - 当 `type` 为 `CODE` 时，内容为 Markdown 格式表示的代码片段。
            - 当 `type` 为 `TABLE` 时，内容为表格，包含如下构成参数：
                - `name`：`.csv` 文件的名称。
                - `url`：文件的 S3 Key 或 URL。
                - `expires_at`：`url` 的过期时间。如需保存表格方便后续使用，请确保在 URL 过期之前完成下载。
            - 当 `type` 为 `IMAGE` 时，内容为一张图片，包含如下构成参数：
                - `name`：图片的名称。
                - `url`：图片的 S3 Key 或 URL。
                - `expires_at`：`url` 的过期时间。如需保存图片方便后续使用，请确保在 URL 过期之前完成下载。
            - 当 `type` 为 `SOURCE` 时，内容为答案块的参考来源，包含如下构成参数：
                - `source`：数据源的文件名。
                - `datasource_id`：数据源 ID。
                - `dataset_id`：数据集 ID。
                - `file_type`：数据源的文件扩展名。
            - 当 `type` 为 `QUESTIONS` 时，内容为 Relyt AI 生成的建议问题，帮助您引导后续的数据探索与分析。
        group_id:
          type: string
          description: 答案块所在的分组 ID。
        group_name:
          type: string
          description: 答案块所在的分组名称。
        stage:
          type: string
          enum:
            - Analyze
            - Respond
          description: |-
            Relyt AI 生成答案的过程分为两个阶段：`Analyze` 和 `Respond`。  

            - `Analyze` 阶段的答案块并非最终答案的构成部分，为分析过程中的输出，旨在帮助您理解答案的生成方式。
            - `Respond` 阶段的答案块是 Relyt AI 基于您的问题生成的最终答复。
      required:
        - type
        - content
        - group_id
        - group_name
        - stage
  securitySchemes:
    apikey-header-x-pd-api-key:
      type: apiKey
      in: header
      name: x-pd-api-key

````