Know all about our streaming capability
{
"id": "<group_id>",
"model": "",
"choices": [
{
"delta": {
"content": "<content>"
},
"index": 0
}
],
"created": 1731664172,
"group_id": "<group_id>",
"group_name": "<group_name>",
"stage": "<block_stage>"
}
id
and group_id
: The ID of the group to which the response block belongs.
A group in the streaming response is a collection of response blocks. For example, in a general job, each step in the Analyze
stage is a group, and the entire Respond
stage is a group.
content
: The content of the response block, which varies with the block type. For more details, see Content description.
created
: The timestamp indicating when the content was created.
group_id
: The ID of the group to which the response block belongs.
group_name
: The name of the group, such as Conclusions
.
stage
: The stage to which the response block belongs. Two stages are available: Analyze
and Respond
.
:keep-alive
in a response, simply ignore it—it serves only as a heartbeat signal to maintain the connection.content
in each response block varies with the block content type:
MESSAGE
:
The content is a piece of text.
CODE
:
The content is a code snippet in Markdown format.
TABLE
:
The content represents a table, consisting of:
name
: The .csv
file name.
url
: The S3 key or URL to the file.
expires_at
: The expiration time for url
. To save the table for future use, make sure to download it before it expires.
IMAGE
:
The content represents an image, consisting of:
name
: The image name.
url
: The S3 key or URL to the image.
expires_at
: The expiration time for url
. To save the image for future use, make sure to download it before it expires.
SOURCES
:
The content represents the source of the response block, including:
id
: The ID of the source.
content
: The chunk content.
page_no
: The location of the chunk in the source file.
source
: The file name of the data source.
datasource_id
: The ID of the data source.
dataset_id
: The ID of the dataset.
file_type
: The name extension of the data source file.
QUESTIONS
:
The content represents follow-up questions suggested by Powerdrill.
POST /v2/jobs
endpoint, see Create job.import requests
url = "https://ai.data.cloud/api/v2/team/jobs"
payload = {
"session_id": "cxxdgegeegeg3433fff",
"user_id": "tmm-dafasdfasdfasdf",
"stream": True,
"question": "Which travel agency has the highest average booking price?",
"dataset_id": "cm1gjmg8e0057r3x22v1fdu8m",
"datasource_ids": ["cm1gjmmoo0001h0x24uk1xgu9"],
"output_language": "AUTO",
"job_mode": "AUTO"
}
headers = {
"x-pd-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Streaming response
event:JOB_ID
data:job-cm738w2ly00bb01l10mr4i2mx
id:96ddde95-4885-4e71-9d0d-bcc1245c2e7f
event:TASK
data:{"id":"96ddde95-4885-4e71-9d0d-bcc1245c2e7f","model":"","choices":[{"delta":{"content":{"name":"Analyze","id":"96ddde95-4885-4e71-9d0d-bcc1245c2e7f","status":"running","parent_id":null,"stage":"Analyze","properties":{}}},"index":0,"finish_reason":null}],"created":1739445418,"group_id":"96ddde95-4885-4e71-9d0d-bcc1245c2e7f","group_name":"Analyze","stage":"Analyze"}
id:96ddde95-4885-4e71-9d0d-bcc1245c2e7f
event:TASK
data:{"id":"96ddde95-4885-4e71-9d0d-bcc1245c2e7f","model":"","choices":[{"delta":{"content":{"name":"Analyze","id":"96ddde95-4885-4e71-9d0d-bcc1245c2e7f","status":"running","parent_id":null,"stage":"Analyze","properties":{"files":""}}},"index":0,"finish_reason":null}],"created":1739445418,"group_id":"96ddde95-4885-4e71-9d0d-bcc1245c2e7f","group_name":"Analyze","stage":"Analyze"}
id:96ddde95-4885-4e71-9d0d-bcc1245c2e7f
event:TASK
data:{"id":"96ddde95-4885-4e71-9d0d-bcc1245c2e7f","model":"","choices":[{"delta":{"content":{"name":"Analyze","id":"96ddde95-4885-4e71-9d0d-bcc1245c2e7f","status":"done","parent_id":null,"stage":"Analyze","properties":{"files":""}}},"index":0,"finish_reason":null}],"created":1739445418,"group_id":"96ddde95-4885-4e71-9d0d-bcc1245c2e7f","group_name":"Analyze","stage":"Analyze"}
id:50c14384-2ae3-4351-93a3-3f43db55ef9e
event:TASK
data:{"id":"50c14384-2ae3-4351-93a3-3f43db55ef9e","model":"","choices":[{"delta":{"content":{"name":"Understand data","id":"50c14384-2ae3-4351-93a3-3f43db55ef9e","status":"running","parent_id":null,"stage":"Analyze","properties":{}}},"index":0,"finish_reason":null}],"created":1739445424,"group_id":"50c14384-2ae3-4351-93a3-3f43db55ef9e","group_name":"Understand data","stage":"Analyze"}
id:3cd93b66-bf6f-4532-9ca4-e08119364c03
event:TASK
data:{"id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","model":"","choices":[{"delta":{"content":{"name":"Calculate the average booking price for each travel agency. First, group by the travel agency, then calculate the average value of the price column for each agency.","id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","status":"running","parent_id":null,"stage":"Analyze","properties":{"files":"junlan.csv"}}},"index":0,"finish_reason":null}],"created":1739445424,"group_id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","group_name":"Calculate the average booking price for each travel agency. First, group by the travel agency, then calculate the average of the price column for each agency.","stage":"Analyze"}
id:3cd93b66-bf6f-4532-9ca4-e08119364c03
event:TASK
data:{"id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","model":"","choices":[{"delta":{"content":{"name":"Calculate the average booking price for each travel agency. First, group by the travel agency, then calculate the average of the price column for each agency.","id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","status":"running","parent_id":null,"stage":"Analyze","properties":{"files":"junlan.csv"}}},"index":0,"finish_reason":null}],"created":1739445424,"group_id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","group_name":"Calculate the average booking price for each travel agency. First, group by the travel agency, then calculate the average of the price column for each agency.","stage":"Analyze"}
id:-1
event:TASK
data:{"id":"-1","model":"","choices":[{"delta":{"content":{"name":"Search references","id":"4e6af71f-4e82-4e92-815f-5c1da6e94361","status":"running","parent_id":null,"stage":"Analyze","properties":{}}},"index":0,"finish_reason":null}],"created":1739445424,"group_id":"-1","group_name":"","stage":"Analyze"}
id:3cd93b66-bf6f-4532-9ca4-e08119364c03
event:CODE
data:{"id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","model":"","choices":[{"delta":{"role":null,"content":"```python\n\nimport pandas as pd\n\ndef invoke(input_0: pd.DataFrame) -> pd.DataFrame:\n '''\n input_0: pd.DataFrame junlan_table_0.csv\n '''\n # Group by travel agency and calculate the mean price\n result = input_0.groupby('travel_agency')['price'].mean().reset_index()\n # Rename columns for clarity\n result.columns = ['Travel Agency', 'Average Booking Price']\n return result\n\n# Assuming input_0 is the DataFrame provided\noutput = invoke(input_0)\n\n```"},"index":0,"finish_reason":null}],"created":1739445428,"group_id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","group_name":"Calculate the average booking price for each travel agency. First, group by travel agency, and then compute the average of the price column for each agency.","stage":"Analyze"}
id:-1
event:TASK
data:{"id":"-1","model":"","choices":[{"delta":{"content":{"name":"Search references","id":"4e6af71f-4e82-4e92-815f-5c1da6e94361","status":"done","parent_id":null,"stage":"Analyze","properties":{}}},"index":0,"finish_reason":null}],"created":1739445429,"group_id":"-1","group_name":"","stage":"Analyze"}
id:50c14384-2ae3-4351-93a3-3f43db55ef9e
event:TASK
data:{"id":"50c14384-2ae3-4351-93a3-3f43db55ef9e","model":"","choices":[{"delta":{"content":{"name":"Understand data","id":"50c14384-2ae3-4351-93a3-3f43db55ef9e","status":"done","parent_id":null,"stage":"Analyze","properties":{}}},"index":0,"finish_reason":null}],"created":1739445429,"group_id":"50c14384-2ae3-4351-93a3-3f43db55ef9e","group_name":"Understand data","stage":"Analyze"}
id:3cd93b66-bf6f-4532-9ca4-e08119364c03
event:TABLE
data:{"id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","model":"","choices":[{"delta":{"content":{"name":"average_price_per_agency.csv","url":"https://static.powerdrill.ai/tmp_datasource_cache/code_result/tmm-cm5ao3yoe00zm01l1u1e7p3pj/d65e5112-9615-4fcd-831b-fb9b7bf5da70.csv","expires_at":"2025-02-13T11:27:13.025667Z"}},"index":0,"finish_reason":null}],"created":1739445432,"group_id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","group_name":"Calculate the average booking price for each travel agency. First, group by travel agency, and then compute the average of the price column for each agency.","stage":"Analyze"}
id:3cd93b66-bf6f-4532-9ca4-e08119364c03
event:TASK
data:{"id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","model":"","choices":[{"delta":{"content":{"name":"Calculate the average booking price for each travel agency. First, group by travel agency, and then compute the average of the price column for each agency.","id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","status":"done","parent_id":null,"stage":"Analyze","properties":{"files":"junlan.csv"}}},"index":0,"finish_reason":null}],"created":1739445432,"group_id":"3cd93b66-bf6f-4532-9ca4-e08119364c03","group_name":"Calculate the average booking price for each travel agency. First, group by travel agency, and then compute the average of the price column for each agency.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:TASK
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"content":{"name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","id":"af56c606-f813-4d4b-9d3e-76aff11fad85","status":"running","parent_id":null,"stage":"Analyze","properties":{"files":""}}},"index":0,"finish_reason":null}],"created":1739445433,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:TASK
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"content":{"name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","id":"af56c606-f813-4d4b-9d3e-76aff11fad85","status":"running","parent_id":null,"stage":"Analyze","properties":{"files":""}}},"index":0,"finish_reason":null}],"created":1739445433,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:TASK
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"content":{"name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","id":"af56c606-f813-4d4b-9d3e-76aff11fad85","status":"running","parent_id":null,"stage":"Analyze","properties":{"files":"average_price_per_agency.csv"}}},"index":0,"finish_reason":null}],"created":1739445433,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:TASK
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"content":{"name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","id":"af56c606-f813-4d4b-9d3e-76aff11fad85","status":"error","parent_id":null,"stage":"Analyze","properties":{"files":""}}},"index":0,"finish_reason":null}],"created":1739445433,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:TASK
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"content":{"name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","id":"af56c606-f813-4d4b-9d3e-76aff11fad85","status":"running","parent_id":null,"stage":"Analyze","properties":{"files":""}}},"index":0,"finish_reason":null}],"created":1739445433,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:TASK
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"content":{"name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","id":"af56c606-f813-4d4b-9d3e-76aff11fad85","status":"running","parent_id":null,"stage":"Analyze","properties":{"files":"average_price_per_agency.csv"}}},"index":0,"finish_reason":null}],"created":1739445433,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:CODE
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"role":null,"content":"```python\n\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport io\n\ndef invoke(average_price_per_agency: pd.DataFrame) -> io.BytesIO:\n # Sort the data by 'Average Booking Price' in descending order\n sorted_data = average_price_per_agency.sort_values(by='Average Booking Price', ascending=False)\n \n # Create a bar plot\n plt.figure(figsize=(10, 6))\n plt.bar(sorted_data['Travel Agency'], sorted_data['Average Booking Price'])\n \n # Rotate x-axis labels for better readability\n plt.xticks(rotation=45, ha='right')\n \n # Add labels and title\n plt.xlabel('Travel Agency')\n plt.ylabel('Average Booking Price')\n plt.title('Average Booking Price per Travel Agency')\n \n # Adjust layout\n plt.tight_layout()\n \n # Save the plot to a BytesIO object\n output = io.BytesIO()\n plt.savefig(output, format='png')\n plt.close()\n \n # Seek to the beginning of the BytesIO object\n output.seek(0)\n \n return output\n\n```"},"index":0,"finish_reason":null}],"created":1739445433,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:IMAGE
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"content":{"url":"https://static.powerdrill.ai/tmp_datasource_cache/code_result/tmm-cm5ao3yoe00zm01l1u1e7p3pj/ed2b799b-070a-4119-a3fa-04b8915583ce.png","name":"visualization.png","expires_at":"2025-02-13T11:27:15.594379Z"}},"index":0,"finish_reason":null}],"created":1739445435,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:TASK
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"content":{"name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","id":"af56c606-f813-4d4b-9d3e-76aff11fad85","status":"done","parent_id":null,"stage":"Analyze","properties":{"files":""}}},"index":0,"finish_reason":null}],"created":1739445435,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:af56c606-f813-4d4b-9d3e-76aff11fad85
event:TASK
data:{"id":"af56c606-f813-4d4b-9d3e-76aff11fad85","model":"","choices":[{"delta":{"content":{"name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","id":"af56c606-f813-4d4b-9d3e-76aff11fad85","status":"done","parent_id":null,"stage":"Analyze","properties":{"files":""}}},"index":0,"finish_reason":null}],"created":1739445435,"group_id":"af56c606-f813-4d4b-9d3e-76aff11fad85","group_name":"Visualize the average booking price for each travel agency using a bar chart to easily compare which travel agency has the highest average price.","stage":"Analyze"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:TASK
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"content":{"name":"Conclusions","id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","status":"running","parent_id":null,"stage":"Respond","properties":{}}},"index":0,"finish_reason":null}],"created":1739445435,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"结论","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"\n\n`Analyzing Conclusions` \n\n"},"index":0,"finish_reason":null}],"created":1739445435,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"### Travel Agency with the Highest Average Booking Price\n\n"},"index":0,"finish_reason":null}],"created":1739445440,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"#### Analysis\n"},"index":0,"finish_reason":null}],"created":1739445440,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":""},"index":0,"finish_reason":null}],"created":1739445440,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"\n"},"index":0,"finish_reason":null}],"created":1739445440,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:TABLE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"content":{"name":"average_price_per_agency.csv","url":"https://static.powerdrill.ai/tmp_datasource_cache/code_result/tmm-cm5ao3yoe00zm01l1u1e7p3pj/d65e5112-9615-4fcd-831b-fb9b7bf5da70.csv","expires_at":"2025-02-13T11:27:20.36399Z"}},"index":0,"finish_reason":null}],"created":1739445440,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"\n\n"},"index":0,"finish_reason":null}],"created":1739445440,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"- **Highest Average Booking Price**: Triprobotics Inc. has the highest average booking price of 279.04.\n\n"},"index":0,"finish_reason":null}],"created":1739445440,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"#### Visualization\n"},"index":0,"finish_reason":null}],"created":1739445441,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":""},"index":0,"finish_reason":null}],"created":1739445441,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"结论","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"\n"},"index":0,"finish_reason":null}],"created":1739445441,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:IMAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"content":{"url":"https://static.powerdrill.ai/tmp_datasource_cache/code_result/tmm-cm5ao3yoe00zm01l1u1e7p3pj/ed2b799b-070a-4119-a3fa-04b8915583ce.png","name":"visualization.png","expires_at":"2025-02-13T11:27:21.19331Z"}},"index":0,"finish_reason":null}],"created":1739445441,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"\n\n"},"index":0,"finish_reason":null}],"created":1739445441,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"- **Visual Confirmation**: The bar chart confirms that Triprobotics Inc. has the highest average booking price compared to other travel agencies.\n\n"},"index":0,"finish_reason":null}],"created":1739445441,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"#### Conclusion and Insights\n"},"index":0,"finish_reason":null}],"created":1739445441,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:MESSAGE
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"role":null,"content":"- **Key Insight**: Triprobotics Inc. stands out with the highest average booking price among the listed travel agencies."},"index":0,"finish_reason":null}],"created":1739445442,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:QUESTIONS
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"content":["Analyze the distribution of booking prices across different travel agencies and identify any significant outliers or patterns.","Investigate the relationship between the trip type (oneway or roundtrip) and the average booking price for each travel agency.","Examine how the average booking price varies with different departure and arrival airports for the top three travel agencies with the highest average prices."]},"index":0,"finish_reason":null}],"created":1739445442,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:TRIGGER
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"content":{"name":"conclusion_slice","arguments":{"answer":"$answer"}}},"index":0,"finish_reason":null}],"created":1739445442,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:d7c2bdcc-e330-410c-ae01-b14fd4a6ca58
event:TASK
data:{"id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","model":"","choices":[{"delta":{"content":{"name":"Conclusions","id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","status":"done","parent_id":null,"stage":"Respond","properties":{}}},"index":0,"finish_reason":null}],"created":1739445442,"group_id":"d7c2bdcc-e330-410c-ae01-b14fd4a6ca58","group_name":"Conclusions","stage":"Respond"}
id:-1
event:SOURCES
data:{"id":"-1","model":"","choices":[{"delta":{"content":[{"id":"1","source":"junlan.csv","page_no":null,"content":null,"datasource_id":"ds-cm5c11ati000301fcotg37qi4","dataset_id":"dset-cm5c11ao90bct01l1s07wxfjt","file_type":"csv","external_id":"11121434"}]},"index":0,"finish_reason":null}],"created":1739445442,"group_id":"-1","group_name":"","stage":"Analyze"}
event:END_MARK
data:[DONE]
stream
is set to False
.
import requests
url = "https://ai.data.cloud/api/v2/team/jobs"
payload = {
"session_id": "cxxdgegeegeg3433fff",
"user_id": "tmm-dafasdfasdfasdf",
"stream": False,
"question": "Which travel agency has the highest average booking price?",
"dataset_id": "cm1gjmg8e0057r3x22v1fdu8m",
"datasource_ids": ["cm1gjmmoo0001h0x24uk1xgu9"],
"output_language": "EN",
"job_mode": "AUTO"
}
headers = {
"x-pd-api-key": "$PROJECT_API_KEY",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
Non-streaming response
{
{
"code": 0,
"msg": null,
"data": {
"job_id": "job-cm738e1ba004601l1rm95unn8",
"blocks": [
{
"type": "CODE",
"content": "```python\n\nimport pandas as pd\n\ndef invoke(input_0: pd.DataFrame) -> pd.DataFrame:\n # Group by travel agency and calculate the mean price\n result = input_0.groupby('travel_agency')['price'].mean().reset_index()\n # Rename columns for clarity\n result.columns = ['Travel Agency', 'Average Booking Price']\n return result\n\n# Assuming input_0 is the DataFrame provided\noutput = invoke(input_0)\n\n```",
"group_id": "e07b6a6a-7cf4-4fec-a068-c339cb1f3fc5",
"group_name": "Calculate the average booking price for each travel agency. First, group by travel agency, and then calculate the average value of the price column for each agency.。",
"stage": "Analyze"
},
{
"type": "TABLE",
"content": {
"url": "https://static.powerdrill.ai/tmp_datasource_cache/code_result/tmm-cm5ao3yoe00zm01l1u1e7p3pj/f47e6d58-b0f1-405d-a367-d4055aab1188.csv",
"name": "average_price_per_agency.csv",
"expires_at": "2025-02-13T11:13:21.903308Z"
},
"group_id": "e07b6a6a-7cf4-4fec-a068-c339cb1f3fc5",
"group_name": "Calculate the average booking price for each travel agency. First, group by travel agency, then calculate the average value of the price column for each agency.",
"stage": "Analyze"
},
{
"type": "CODE",
"content": "```python\n\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport io\n\ndef invoke(average_price_per_agency: pd.DataFrame) -> io.BytesIO:\n # Sort the data by 'Average Booking Price' in descending order\n sorted_data = average_price_per_agency.sort_values(by='Average Booking Price', ascending=False)\n \n # Create a bar plot\n plt.figure(figsize=(10, 6))\n plt.bar(sorted_data['Travel Agency'], sorted_data['Average Booking Price'])\n \n # Rotate x-axis labels for better readability\n plt.xticks(rotation=45, ha='right')\n \n # Add labels and title\n plt.xlabel('Travel Agency')\n plt.ylabel('Average Booking Price')\n plt.title('Average Booking Price per Travel Agency')\n \n # Adjust layout\n plt.tight_layout()\n \n # Save the plot to a BytesIO object\n output = io.BytesIO()\n plt.savefig(output, format='png')\n plt.close()\n \n # Seek to the beginning of the BytesIO object\n output.seek(0)\n \n return output\n\n```",
"group_id": "8580f207-1b66-4231-9266-69c845f2d2cd",
"group_name": "Visualize the average booking price for each travel agency using a bar chart, so you can easily compare which agency has the highest average price.",
"stage": "Analyze"
},
{
"type": "IMAGE",
"content": {
"url": "https://static.powerdrill.ai/tmp_datasource_cache/code_result/tmm-cm5ao3yoe00zm01l1u1e7p3pj/b185c0f3-a021-4ceb-b317-b391c0e7df28.png",
"name": "visualization.png",
"expires_at": "2025-02-13T11:13:21.903308Z"
},
"group_id": "8580f207-1b66-4231-9266-69c845f2d2cd",
"group_name": "Use a bar chart to visualize the average booking price for each travel agency, so you can easily compare which agency has the highest average price.",
"stage": "Analyze"
},
{
"type": "MESSAGE",
"content": "\n\n`Analyzing Conclusions` \n\n### Travel Agency with the Highest Average Booking Price\n\n#### Analysis\n\n",
"group_id": "60ad92c9-6151-41a3-b3aa-ab695cdaa5f5",
"group_name": "Conclusions",
"stage": "Respond"
},
{
"type": "TABLE",
"content": {
"url": "https://static.powerdrill.ai/tmp_datasource_cache/code_result/tmm-cm5ao3yoe00zm01l1u1e7p3pj/f47e6d58-b0f1-405d-a367-d4055aab1188.csv",
"name": "average_price_per_agency.csv",
"expires_at": "2025-02-13T11:13:21.903308Z"
},
"group_id": "60ad92c9-6151-41a3-b3aa-ab695cdaa5f5",
"group_name": "Conclusions",
"stage": "Respond"
},
{
"type": "MESSAGE",
"content": "\n\n- **Highest Average Booking Price**: Triprobotics Inc. has the highest average booking price at **279.04**.\n\n#### Visualization\n\n",
"group_id": "60ad92c9-6151-41a3-b3aa-ab695cdaa5f5",
"group_name": "Conclusions",
"stage": "Respond"
},
{
"type": "IMAGE",
"content": {
"url": "https://static.powerdrill.ai/tmp_datasource_cache/code_result/tmm-cm5ao3yoe00zm01l1u1e7p3pj/b185c0f3-a021-4ceb-b317-b391c0e7df28.png",
"name": "visualization.png",
"expires_at": "2025-02-13T11:13:21.903308Z"
},
"group_id": "60ad92c9-6151-41a3-b3aa-ab695cdaa5f5",
"group_name": "Conclusions",
"stage": "Respond"
},
{
"type": "MESSAGE",
"content": "\n\n- **Visual Confirmation**: The bar chart confirms that Triprobotics Inc. leads with the highest average booking price compared to other agencies.\n\n#### Conclusion and Insights\n- **Key Insight**: Triprobotics Inc. stands out with the highest average booking price among the listed travel agencies.",
"group_id": "60ad92c9-6151-41a3-b3aa-ab695cdaa5f5",
"group_name": "Conclusions",
"stage": "Respond"
},
{
"type": "SOURCES",
"content": [
{
"source": "junlan.csv",
"datasource_id": "ds-cm5c11ati000301fcotg37qi4",
"dataset_id": "dset-cm5c11ao90bct01l1s07wxfjt",
"file_type": "csv",
"external_id": "11121434"
}
],
"group_id": "",
"group_name": "",
"stage": "Respond"
},
{
"type": "QUESTIONS",
"content": [
"Analyze the distribution of booking prices across different travel agencies and identify any significant outliers or patterns.",
"Investigate the relationship between the trip type (oneway or roundtrip) and the average booking price for each travel agency.",
"Examine how the average booking price varies with different departure and arrival airports for the top three travel agencies with the highest average prices."
],
"group_id": "-1",
"group_name": null,
"stage": "Respond"
}
]
}
}