This operation generates SQL statements based on the current query information and associated data tables. This API is suitable for scenarios where your database is stored locally and cannot be accessed by Xiyan. You can associate a virtual data source with Xiyan, call this API to generate the SQL statements, and then parse and execute them locally. For more information, see the best practices document.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
dataanalysisgbi:RunSqlGeneration |
none |
*All Resource
|
None | None |
Request syntax
POST /gbi/runSqlGeneration HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| workspaceId |
string |
Yes |
The ID of the Alibaba Cloud Model Studio workspace used for the current request. |
llm-2v3934xtp49esw64 |
| body |
object |
No |
Request body parameters. |
|
| specificationType |
string |
No |
The version information specified for the current request. If empty, the default workspace version is used. Valid values:
|
STANDARD_MIX |
| query |
string |
Yes |
The query entered by the user. |
请问销量前十的产品有哪些 |
| sessionId |
string |
No |
The message session ID. Multiple request IDs can belong to the same session ID. |
d5eced84-fd25-43ee-a245-adb4e4a8c3be |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
SseEmitter |
||
| data |
object |
Return information. |
|
| errorMessage |
string |
Error message. |
Access was denied, message: No such namespace namespaces/tech-scp-chain7. |
| event |
string |
Event type. Valid values:
|
sql |
| evidence |
string |
Information used for auxiliary model inference. |
今年是2024年 |
| requestId |
string |
The ID of the current request. |
DA2578F7-88A5-5D6E-9305-33E724E97D60 |
| rewrite |
string |
The rewritten user input. |
查询全部关键字数据,并以饼图形式展示 |
| selector |
array |
List of specific table names retrieved. |
|
|
string |
The name of the specific table retrieved. |
table_name1 |
|
| sessionId |
string |
Conversation ID. |
f64c38dd-a235-4bb4-ae6c-79eaedcba699 |
| sql |
string |
The SQL statement generated for the current conversation. |
select p.product_id, p.product_name, sum(o.quantity) as total_sales from products p join orders o on p.product_id = o.product_id where o.order_date between '2022-10-22' and '2024-10-22' group by p.product_id, p.product_name having total_sales > 5 |
| sqlError |
string |
If the task execution fails, this field reports the reason for the failure. |
Can not issue data manipulation statements with executeQuery() |
| chat |
object |
||
| text |
string |
Examples
Success response
JSON format
{
"data": {
"errorMessage": "Access was denied, message: No such namespace namespaces/tech-scp-chain7.",
"event": "sql",
"evidence": "今年是2024年",
"requestId": "DA2578F7-88A5-5D6E-9305-33E724E97D60",
"rewrite": "查询全部关键字数据,并以饼图形式展示",
"selector": [
"table_name1"
],
"sessionId": "f64c38dd-a235-4bb4-ae6c-79eaedcba699",
"sql": "select p.product_id, p.product_name, sum(o.quantity) as total_sales from products p join orders o on p.product_id = o.product_id where o.order_date between '2022-10-22' and '2024-10-22' group by p.product_id, p.product_name having total_sales > 5",
"sqlError": "Can not issue data manipulation statements with executeQuery()",
"chat": {
"text": ""
}
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 401 | Internal.Error | Bad Request: Internal Error. | Internal error, please contact customer service personnel to troubleshoot |
| 401 | NoAuth | Bad Request: Workspace.Illegal.Auth. | The current account does not have the permission to the specified business space. |
| 401 | NoResourceAuth | Bad Request: Resource Auth Error. | If you do not have permission for the requested resource, make sure that the requested resource belongs to the business space in the current parameter. |
| 401 | SystemOperationInProgress | Xiyan GBI is learning your previous modifications. Please try again later. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.