GPT TEXT TO DATA 接口文档
作用:通过自然语言查询数据, 集成GPT能力, 可多轮对话
接口信息:
PATH:/df/rest/table/list
METHOD: GET
获取系统中所有已导入表信息
Header 请求参数
json
Authorization: Bearer M2M5YzY2TE0ZmEwMDNZjY1MDRkMGNkNWIuYTUxYThkZjJkGQ3NGZlZmJlZmIMGM2YTA3MDhlNg=
请求参数
Name | Location | Type | Required | Description |
---|---|---|---|---|
name | query | string | no | 表名查询参数 |
Authorization | header | string | yes | none |
Response Examples
json
{
"data": [
{
"columns": [
{
"colDisplayName": "产品类别",
"colName": "产品类别",
"dataType": "string",
"id": "1872444643045654532"
},
{
"colDisplayName": "区域",
"colName": "区域",
"dataType": "string",
"id": "1872444643045654533"
},
{
"colDisplayName": "快递公司",
"colName": "快递公司",
"dataType": "string",
"id": "1872444643045654534"
},
{
"colDisplayName": "目的城市",
"colName": "目的城市",
"dataType": "string",
"id": "1872444643045654536"
},
{
"colDisplayName": "订单单号",
"colName": "订单单号",
"dataType": "bigint",
"id": "1872444643045654538"
},
{
"colDisplayName": "顾客姓名",
"colName": "顾客姓名",
"dataType": "string",
"id": "1872444643045654542"
}
],
"id": "1872444643041460225",
"tblDisplayName": "test_flow_Datafocus流处理",
"tblName": "test_flow_Datafocus流处理"
}
],
"errCode": 0,
"exception": "",
"msgParams": null,
"promptMsg": null,
"success": true
}
Responses Data Schema
HTTP Status Code 200
Name | Type | Required | Restrictions | Title | description |
---|---|---|---|---|---|
» success | boolean | true | none | 结果 | true:成功 false:失败 |
» exception | string | true | none | 异常信息 | 异常信息 |
» errCode | integer | true | none | 错误码 | 非零为出错 |
» promptMsg | object | false | none | 异常提示 | 异常提示信息 |
» data | [数据表信息] | false | none | 响应数据体 | 响应数据体 |
PATH:/df/rest/datasource/tables
METHOD: POST
获取数据源的所有表信息
Header 请求参数
json
Authorization: Bearer M2M5YzY2TE0ZmEwMDNZjY1MDRkMGNkNWIuYTUxYThkZjJkGQ3NGZlZmJlZmIMGM2YTA3MDhlNg=
Body Parameters
json
{
"db": "test_1",
"description": "",
"host": "192.168.0.93",
"jdbcSuffix": "",
"name": "pg93Test1",
"port": 5432,
"schemaName": "public",
"sourceType": "dataSource",
"type": "postgresql",
"user": "postgres",
"password": "postgres"
}
Params
Name | Location | Type | Required | Description |
---|---|---|---|---|
Authorization | header | string | yes | none |
body | body | any | no | none |
Response Examples
json
{
"data": [
{
"columns": [
{
"colDisplayName": "id",
"colName": "id",
"dataType": "bigint",
"id": "0"
},
{
"colDisplayName": "datasource_id",
"colName": "datasource_id",
"dataType": "bigint",
"id": "0"
},
{
"colDisplayName": "config_key",
"colName": "config_key",
"dataType": "string",
"id": "0"
},
{
"colDisplayName": "config_value",
"colName": "config_value",
"dataType": "string",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "df_web_datasource_properties",
"tblName": "df_web_datasource_properties"
},
{
"columns": [
{
"colDisplayName": "a1",
"colName": "a1",
"dataType": "double",
"id": "0"
},
{
"colDisplayName": "a2",
"colName": "a2",
"dataType": "double",
"id": "0"
},
{
"colDisplayName": "a3",
"colName": "a3",
"dataType": "double",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "test_v",
"tblName": "test_v"
},
{
"columns": [
{
"colDisplayName": "id",
"colName": "id",
"dataType": "bigint",
"id": "0"
},
{
"colDisplayName": "type",
"colName": "type",
"dataType": "string",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "df_web_datasource",
"tblName": "df_web_datasource"
}
],
"errCode": 0,
"exception": "",
"msgParams": null,
"promptMsg": null,
"success": true
}
Responses Data Schema
HTTP Status Code 200
Name | Type | Required | Restrictions | Title | description |
---|---|---|---|---|---|
» success | boolean | true | none | 结果 | true:成功 false:失败 |
» exception | string | true | none | 异常信息 | 异常信息 |
» errCode | integer | true | none | 错误码 | 非零为出错 |
» promptMsg | object | false | none | 异常提示 | 异常提示信息 |
» data | [数据表信息] | false | none | 响应数据体 | 响应数据体 |
Data Schema
数据源配置参数
json
{
"type": "string",
"name": "string",
"description": "string",
"schemaName": "string",
"host": "string",
"port": 0,
"user": "string",
"password": "string",
"db": "string",
"jdbcSuffix": "string"
}
Attribute
Name | Type | Required | Restrictions | Title | Description |
---|---|---|---|---|---|
type | string | true | none | 数据源类型 | none |
name | string | true | none | 数据源名称 | none |
description | string | false | none | 数据源描述 | none |
schemaName | string | false | none | Schema信息 | none |
host | string | true | none | 主机地址 | none |
port | integer | true | none | 端口信息 | none |
user | string | true | none | 用户名 | none |
password | string | true | none | 用户密码 | none |
db | string | true | none | 数据库名 | none |
jdbcSuffix | string | false | none | JDBC附加参数 | none |
数据源配置参数说明
数据源类型参数: type 支持下面的数据源
type | 数据源 |
---|---|
mysql | MySQL |
postgresql | Posgresql |
sqlserver | SQLServer |
oracle | Oracle |
ibmdb2 | IBMDB2 |
gaussdb100 | GaussDB100 |
sybase | Sybase |
greenplum | Greenplum |
clickhouse | Clickhouse |
teradata | Teradata |
doris | Doris |
tidb | TIDB |
hana | Hana |
clickzetta | Clickzetta |
impala | Impala |
dameng | DM8 |
argodb | ArgoDB |
kudu | Kudu |
elasticsearch | Elasticsearch |
mongodb | Mongodb |
prometheus | Prometheus |
hive | Hive |
delta_lake | Delta-Lake |
iceberg | Iceberg |
每种数据源的配置方式多少有点不一样,支持JDBC的数据源配置基本是一样的,上面给的数据源的结构是按JDBC的数据源来的,下面是几个配置样例:
postgres:
json
{
"db": "test_1",
"description": "",
"host": "192.168.0.93",
"jdbcSuffix": "",
"name": "pg93Test1",
"port": 5432,
"schemaName": "public",
"sourceType": "dataSource",
"type": "postgresql",
"user": "postgres",
"password": "postgres"
}
mysql:
json
{
"db": "releaseci",
"description": "",
"host": "192.168.0.93",
"jdbcSuffix": "serverTimezone=GMT-8",
"name": "MySQL93",
"port": 3316,
"schemaName": "releaseci",
"type": "mysql",
"user": "root",
"password": "root"
}
sqlserver:
json
{
"db": "releaseci",
"description": "",
"host": "192.168.0.93",
"jdbcSuffix": "trustServerCertificate=true",
"name": "SQLServer93",
"port": 1433,
"schemaName": "dbo",
"sourceType": "dataSource",
"type": "sqlserver",
"user": "root",
"username": "root"
}
impala:
{
"authType": "NONE",
"db": "default",
"description": "",
"host": "192.168.0.57",
"id": "1765671252440236033",
"jdbcSuffix": "",
"name": "impala",
"port": 21050,
"schemaName": "default",
"sourceType": "dataSource",
"type": "impala",
"user": "",
"password": ""
}
数据表信息
json
{
"id": "string",
"tblName": "string",
"tblDisplayName": "string",
"columns": [
{
"id": "string",
"colName": "string",
"colDisplayName": "string",
"dataType": "string"
}
]
}
Attribute
Name | Type | Required | Restrictions | Title | Description |
---|---|---|---|---|---|
id | string | true | none | 表id | none |
tblName | string | true | none | 原始表名 | none |
tblDisplayName | string | true | none | 显示表名 | none |
columns | [object] | true | none | 列列表 | none |
» id | string | true | none | 列id | none |
» colName | string | true | none | 原始列名 | none |
» colDisplayName | string | true | none | 显示列名 | none |
» dataType | string | true | none | 数据类型 | none |
基本响应对象
json
{
"success": true,
"exception": "string",
"errCode": 0,
"promptMsg": {},
"data": {}
}
Attribute
Name | Type | Required | Restrictions | Title | Description |
---|---|---|---|---|---|
success | boolean | true | none | 结果 | true:成功 false:失败 |
exception | string | true | none | 异常信息 | 异常信息 |
errCode | integer | true | none | 错误码 | 非零为出错 |
promptMsg | object | false | none | 异常提示 | 异常提示信息 |
data | object | false | none | 响应数据体 | 响应数据体 |
PATH:/df/rest/gpt/init
METHOD: POST
初始化上下文[注册表、选表]
Header 请求参数
json
Authorization: Bearer M2M5YzY2TE0ZmEwMDNZjY1MDRkMGNkNWIuYTUxYThkZjJkGQ3NGZlZmJlZmIMGM2YTA3MDhlNg=
Body 请求参数
json
{
"language": "string",
"dataSource": {
"type": "string",
"name": "string",
"description": "string",
"schemaName": "string",
"host": "string",
"port": 0,
"user": "string",
"password": "string",
"db": "string",
"jdbcSuffix": "string"
},
"names": [
"string"
]
}
请求参数
名称 | 位置 | 类型 | 必选 | 说明 |
---|---|---|---|---|
Authorization | header | string | 是 | bearer token |
body | body | object | 否 | none |
» language | body | string | 是 | 语言环境 |
» dataSource | body | object | 否 | 数据源信息 |
»» type | body | string | 是 | 数据源类型 |
»» name | body | string | 是 | 数据源名称 |
»» description | body | string | 否 | 数据源描述 |
»» schemaName | body | string | 否 | Schema信息 |
»» host | body | string | 是 | 主机地址 |
»» port | body | integer | 是 | 端口信息 |
»» user | body | string | 是 | 用户名 |
»» password | body | string | 是 | 用户密码 |
»» db | body | string | 是 | 数据库名 |
»» jdbcSuffix | body | string | 否 | JDBC附加参数 |
» names | body | [string] | 是 | 表显示名列表 |
说明
当 dataSource 为空时,会从系统中选择 names 列表中的表使用。 当 dataSource 不为空时,会注册dataSource中 names 列表中的表到系统中使用[不会重复注册]。
枚举值
language:语言环境
值 | 含义 |
---|---|
chinese | 中文 |
english | 英文 |
dataSource.type:数据源类型参数
值 | 含义 |
---|---|
mysql | MySQL |
postgresql | Posgresql |
sqlserver | SQLServer |
oracle | Oracle |
ibmdb2 | IBMDB2 |
gaussdb100 | GaussDB100 |
sybase | Sybase |
greenplum | Greenplum |
clickhouse | Clickhouse |
teradata | Teradata |
doris | Doris |
tidb | TIDB |
hana | Hana |
clickzetta | Clickzetta |
impala | Impala |
dameng | DM8 |
argodb | ArgoDB |
kudu | Kudu |
elasticsearch | Elasticsearch |
mongodb | Mongodb |
prometheus | Prometheus |
hive | Hive |
delta_lake | Delta-Lake |
iceberg | Iceberg |
数据源参数示例: 每种数据源的配置方式多少有点不一样,支持JDBC的数据源配置基本是一样的,上面给的数据源的结构是按JDBC的数据源来的,下面是几个配置样例:
postgres:
json
{
"db": "test_1",
"description": "",
"host": "192.168.0.93",
"jdbcSuffix": "",
"name": "pg93Test1",
"port": 5432,
"schemaName": "public",
"sourceType": "dataSource",
"type": "postgresql",
"user": "postgres",
"password": "postgres"
}
mysql:
json
{
"db": "releaseci",
"description": "",
"host": "192.168.0.93",
"jdbcSuffix": "serverTimezone=GMT-8",
"name": "MySQL93",
"port": 3316,
"schemaName": "releaseci",
"type": "mysql",
"user": "root",
"password": "root"
}
sqlserver:
json
{
"db": "releaseci",
"description": "",
"host": "192.168.0.93",
"jdbcSuffix": "trustServerCertificate=true",
"name": "SQLServer93",
"port": 1433,
"schemaName": "dbo",
"sourceType": "dataSource",
"type": "sqlserver",
"user": "root",
"username": "root"
}
impala:
{
"authType": "NONE",
"db": "default",
"description": "",
"host": "192.168.0.57",
"id": "1765671252440236033",
"jdbcSuffix": "",
"name": "impala",
"port": 21050,
"schemaName": "default",
"sourceType": "dataSource",
"type": "impala",
"user": "",
"password": ""
}
返回示例
200 Response
json
{
"errCode": 0,
"exception": "string",
"data": "string"
}
返回数据结构
状态码 200
名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
---|---|---|---|---|---|
» errCode | integer | true | none | none | |
» exception | string | true | none | none | |
» data | string | true | none | chat id:后续对话使用 |
PATH:/df/rest/gpt/data
METHOD: POST
对话查询
Header 请求参数
json
Authorization: Bearer M2M5YzY2TE0ZmEwMDNZjY1MDRkMGNkNWIuYTUxYThkZjJkGQ3NGZlZmJlZmIMGM2YTA3MDhlNg=
Body 请求参数
json
{
"input": "string",
"chatId": "string"
}
请求参数
名称 | 位置 | 类型 | 必选 | 说明 |
---|---|---|---|---|
Authorization | header | string | 是 | bearer token |
body | body | object | 否 | none |
» input | body | string | 是 | 用户输入的问题 |
» chatId | body | string | 是 | 对话id |
返回示例
200 Response
json
{
"errCode": 0,
"exception": "string",
"data": {
"code": 0,
"info": "string",
"type": "data",
"content": {
"duration": "string",
"headers": [
{
"suf": "string",
"display": "string",
"name": "string"
}
],
"columns": [
[
"string"
]
],
"count": 0,
"title": "string",
"sql": {
"where_clause": "string",
"order_by_clause": "string",
"select_clause": "string",
"from_clause": "string",
"group_by_clause": "string",
"having_clause": "string"
}
},
"question": "string"
},
"msgParams": null,
"promptMsg": null,
"success": true
}
返回数据结构
状态码 200
名称 | 类型 | 必选 | 约束 | 说明 |
---|---|---|---|---|
» errCode | integer | true | none | none |
» exception | string | true | none | none |
» data | object | true | none | none |
»» code | integer | true | none | 错误码, 非0表示错误 |
»» info | string | true | none | 提示信息或者错误信息 |
»» type | string | true | none | 类型 |
»» content | object | true | none | none |
»»» duration | string | true | none | 查询耗时 |
»»» headers | [object] | true | none | 列头信息 |
»»»» suf | string | true | none | 列头操作 |
»»»» display | string | true | none | 列头名字+列头操作 |
»»»» name | string | true | none | 列头名字 |
»»» columns | [array] | true | none | 查询结果,二维数组 |
»»» count | integer | true | none | 查询的记录数 |
»»» title | string | true | none | 标题 |
»»» sql | object | true | none | 实际执行的sql |
»»»» where_clause | string | true | none | none |
»»»» order_by_clause | string | true | none | none |
»»»» select_clause | string | true | none | none |
»»»» from_clause | string | true | none | none |
»»»» group_by_clause | string | true | none | none |
»»»» having_clause | string | true | none | none |
»» question | string | true | none | 解析后的问题 |
» msgParams | null | true | none | none |
» promptMsg | null | true | none | none |
» success | boolean | true | none | none |
枚举值
type:返回结果类型
值 | 含义 |
---|---|
data | 数据结果 |
assistant | gpt交互信息 |
Bearer token 获取方式如下图:

curl 样例:
json
获取系统内表列表
curl -X GET "https://test.datafocus.ai/df/rest/table/list" -H "Authorization: Bearer ZJmYzg3ZTQ3MzViNGE3OGE0ZDZlMjdiYjAwYTI4ZmMuMzA0OTg4YjI4YzM3NDJkOWEzMjUwMRksNTk0ZDQxZDU="
curl 返回结果:
{
"data": [
{
"columns": [
{
"colDisplayName": "a",
"colName": "a",
"dataType": "string",
"id": "1776861878589542401"
}
],
"id": "1776861878581153793",
"tblDisplayName": "test-test",
"tblName": "test-test"
},
{
"columns": [
{
"colDisplayName": "Id",
"colName": "Id",
"dataType": "int",
"id": "1674954668239998978"
},
{
"colDisplayName": "Reputation",
"colName": "Reputation",
"dataType": "int",
"id": "1674954668239998979"
},
{
"colDisplayName": "公式名",
"colName": "公式名",
"dataType": "string",
"id": "1674954668239998980"
}
],
"id": "1674954668235804674",
"tblDisplayName": "test-test-flow",
"tblName": "test-test-flow"
},
{
"columns": [
{
"colDisplayName": "name",
"colName": "name",
"dataType": "string",
"id": "1706850708101890050"
},
{
"colDisplayName": "age",
"colName": "age",
"dataType": "int",
"id": "1706850708114472962"
},
{
"colDisplayName": "aaa",
"colName": "aaa",
"dataType": "double",
"id": "1706850807854481409"
}
],
"id": "1706850708055752706",
"tblDisplayName": "test-merge",
"tblName": "test-merge"
}
],
"errCode": 0,
"exception": "",
"msgParams": null,
"promptMsg": null,
"success": true
}
-------------------------
获取数据源表列表
curl -X POST "https://test.datafocus.ai/df/rest/datasource/tables" -H "Authorization: Bearer ZJmYzg3ZTQ3MzViNGE3OGE0ZDZlMjdiYjAwYTI4ZmMuMzA0OTg4YjI4YzM3NDJkOWEzMjUwMRksNTk0ZDQxZDU=" -H "Content-Type:application/json" -d '{"db":"test_1","description":"","host":"192.168.0.93","jdbcSuffix":"","name":"releaseci","port":5432,"schemaName":"public","type":"postgresql","user":"postgres","password":"**********"}'
curl 返回结果:
{
"data": [
{
"columns": [
{
"colDisplayName": "id",
"colName": "id",
"dataType": "bigint",
"id": "0"
},
{
"colDisplayName": "datasource_id",
"colName": "datasource_id",
"dataType": "bigint",
"id": "0"
},
{
"colDisplayName": "config_key",
"colName": "config_key",
"dataType": "string",
"id": "0"
},
{
"colDisplayName": "config_value",
"colName": "config_value",
"dataType": "string",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "df_web_datasource_properties",
"tblName": "df_web_datasource_properties"
},
{
"columns": [
{
"colDisplayName": "a1",
"colName": "a1",
"dataType": "double",
"id": "0"
},
{
"colDisplayName": "a2",
"colName": "a2",
"dataType": "double",
"id": "0"
},
{
"colDisplayName": "a3",
"colName": "a3",
"dataType": "double",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "test_v",
"tblName": "test_v"
},
{
"columns": [
{
"colDisplayName": "id",
"colName": "id",
"dataType": "bigint",
"id": "0"
},
{
"colDisplayName": "type",
"colName": "type",
"dataType": "string",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "df_web_datasource",
"tblName": "df_web_datasource"
},
{
"columns": [
{
"colDisplayName": "id",
"colName": "id",
"dataType": "int",
"id": "0"
},
{
"colDisplayName": "name",
"colName": "name",
"dataType": "string",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "test_2",
"tblName": "test_2"
},
{
"columns": [
{
"colDisplayName": "id",
"colName": "id",
"dataType": "int",
"id": "0"
},
{
"colDisplayName": "name",
"colName": "name",
"dataType": "string",
"id": "0"
},
{
"colDisplayName": "sex",
"colName": "sex",
"dataType": "string",
"id": "0"
},
{
"colDisplayName": "u_id",
"colName": "u_id",
"dataType": "int",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "test_1",
"tblName": "test_1"
},
{
"columns": [
{
"colDisplayName": "a1",
"colName": "a1",
"dataType": "double",
"id": "0"
},
{
"colDisplayName": "a2",
"colName": "a2",
"dataType": "double",
"id": "0"
},
{
"colDisplayName": "a3",
"colName": "a3",
"dataType": "double",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "test_num",
"tblName": "test_num"
},
{
"columns": [
{
"colDisplayName": "id",
"colName": "id",
"dataType": "bigint",
"id": "0"
},
{
"colDisplayName": "datasource_id",
"colName": "datasource_id",
"dataType": "bigint",
"id": "0"
},
{
"colDisplayName": "config_key",
"colName": "config_key",
"dataType": "string",
"id": "0"
},
{
"colDisplayName": "config_value",
"colName": "config_value",
"dataType": "string",
"id": "0"
}
],
"id": "0",
"tblDisplayName": "datasource_properties",
"tblName": "datasource_properties"
}
],
"errCode": 0,
"exception": "",
"msgParams": null,
"promptMsg": null,
"success": true
}
-------------------------
初始化对话
curl -X POST "https://test.datafocus.ai//df/rest/gpt/init" -H "Authorization: Bearer ZJmYzg3ZTQ3MzViNGE3OGE0ZDZlMjdiYjAwYTI4ZmMuMzA0OTg4YjI4YzM3NDJkOWEzMjUwMRksNTk0ZDQxZDU=" -H "Content-Type:application/json" -d '{"names":["电商销售数据"]}'
curl 返回结果:
{
"data": "439f3ec2b4a54303981f11ad4dba53c3",
"errCode": 0,
"exception": "",
"msgParams": null,
"promptMsg": null,
"success": true
}
-------------------------
gpt对话
curl -X POST "https://test.datafocus.ai/df/rest/gpt/data" -H "Authorization: Bearer ZJmYzg3ZTQ3MzViNGE3OGE0ZDZlMjdiYjAwYTI4ZmMuMzA0OTg4YjI4YzM3NDJkOWEzMjUwMRksNTk0ZDQxZDU=" -H "Content-Type:application/json" -d '{"chatId":"439f3ec2b4a54303981f11ad4dba53c3", "input":"怎么分析数据"}'
curl 返回结果:
{
"data": {
"content": {
"code": 0,
"info": "您可以从以下几个方面进行数据分析:
1. **时间序列分析**:分析订单日期与销售数量、销售额的趋势和季节性变化。
2. **产品分析**:比较不同产品名称的销售表现,找出畅销产品。
3. **地域分析**:分析不同区域、省份、城市的销售情况,找出销售热点。
4. **客户分析**:分析不同顾客的购买行为,找出高价值客户。
5. **快递公司分析**:分析不同快递公司的服务表现,找出效率高的快递公司。
6. **收款方式分析**:分析不同收款方式的使用情况,找出常用的收款方式。
您可以根据具体的业务需求选择合适的分析方法。如果需要具体的查询或计算,请告诉我。"
},
"question": null,
"type": "assistant"
},
"errCode": 0,
"exception": "",
"msgParams": null,
"promptMsg": null,
"success": true
}
-------------------------
gpt查询
curl -X POST "https://test.datafocus.ai/df/rest/gpt/data" -H "Authorization: Bearer ZJmYzg3ZTQ3MzViNGE3OGE0ZDZlMjdiYjAwYTI4ZmMuMzA0OTg4YjI4YzM3NDJkOWEzMjUwMRksNTk0ZDQxZDU=" -H "Content-Type:application/json" -d '{"chatId":"439f3ec2b4a54303981f11ad4dba53c3", "input":"去年的销售数量"}'
curl 返回结果:
{
"data": {
"content": {
"duration": "0.217257",
"headers": [
{
"suf": "总和",
"display": "销售数量(总和)",
"name": "销售数量"
}
],
"columns": [
[
null
]
],
"count": 1,
"title": "去年 销售数量",
"sql": {
"where_clause": "",
"order_by_clause": "",
"select_clause": "select sum("电商销售数据"."销售数量") as col_1 from "电商销售数据" where ((("电商销售数据"."订单日期" >= try_cast('2024-01-01 00:00:00.000' as timestamp)) and ("电商销售数据"."订单日期" < try_cast('2025-01-01 00:00:00.000' as timestamp))) = true) order by sum("电商销售数据"."销售数量")",
"from_clause": "",
"group_by_clause": "",
"having_clause": ""
}
},
"question": "去年 销售数量",
"type": "data"
},
"errCode": 0,
"exception": "",
"msgParams": null,
"promptMsg": null,
"success": true
}
-------------------------
gpt追问
curl -X POST "https://test.datafocus.ai/df/rest/gpt/data" -H "Authorization: Bearer ZJmYzg3ZTQ3MzViNGE3OGE0ZDZlMjdiYjAwYTI4ZmMuMzA0OTg4YjI4YzM3NDJkOWEzMjUwMRksNTk0ZDQxZDU=" -H "Content-Type:application/json" -d '{"chatId":"439f3ec2b4a54303981f11ad4dba53c3", "input":"那销售金额呢"}'
curl 返回结果:
{
"data": {
"content": {
"duration": "0.206304",
"headers": [
{
"suf": "总和",
"display": "销售金额(总和)",
"name": "销售金额"
}
],
"columns": [
[
1159624.4
]
],
"count": 1,
"title": "去年 销售金额",
"sql": {
"where_clause": "",
"order_by_clause": "",
"select_clause": "select sum("电商销售数据"."销售金额") as col_1 from "电商销售数据" where ((("电商销售数据"."订单日期" >= try_cast('2024-01-01 00:00:00.000' as timestamp)) and ("电商销售数据"."订单日期" < try_cast('2025-01-01 00:00:00.000' as timestamp))) = true) order by sum("电商销售数据"."销售金额")",
"from_clause": "",
"group_by_clause": "",
"having_clause": ""
}
},
"question": "去年 销售金额",
"type": "data"
},
"errCode": 0,
"exception": "",
"msgParams": null,
"promptMsg": null,
"success": true
}
-------------------------
gpt查询
curl -X POST "https://test.datafocus.ai/df/rest/gpt/data" -H "Authorization: Bearer ZJmYzg3ZTQ3MzViNGE3OGE0ZDZlMjdiYjAwYTI4ZmMuMzA0OTg4YjI4YzM3NDJkOWEzMjUwMRksNTk0ZDQxZDU=" -H "Content-Type:application/json" -d '{"chatId":"439f3ec2b4a54303981f11ad4dba53c3", "input":"销售额的年增长率"}''
curl 返回结果:
{
"data": {
"content": {
"duration": "0.414440",
"headers": [
{
"suf": "每年",
"display": "订单日期(每年)",
"name": "订单日期"
},
{
"suf": "环比的总和增长量率",
"display": "销售金额(环比的总和增长量率)",
"name": "销售金额"
},
{
"suf": "总和",
"display": "销售金额(前)(总和)",
"name": "销售金额(前)"
},
{
"suf": "总和",
"display": "销售金额(后)(总和)",
"name": "销售金额(后)"
}
],
"columns": [
[
"2014-01-01 00:00:00.000",
null,
null,
1098535.542
],
[
"2015-01-01 00:00:00.000",
-0.0094446074827131,
1098535.542,
1088160.305
],
[
"2016-01-01 00:00:00.000",
-0.172273145913,
1088160.305,
900699.506
],
[
"2017-01-01 00:00:00.000",
0.039591651557984,
900699.506,
936359.687
]
],
"count": 4,
"title": "销售金额的年增长率",
"sql": {
"where_clause": "",
"order_by_clause": "",
"select_clause": "select col_0 as col_9,case (abs(col_3)) when 0 then 0 else (try_cast((col_1 - col_3) as double))/(abs(col_3)) end as col_6,col_3 as col_7,col_1 as col_8 from (select date_trunc('year', "电商销售数据"."订单日期") as col_0,sum("电商销售数据"."销售金额") as col_1 from "电商销售数据" group by date_trunc('year', "电商销售数据"."订单日期")) tbl_1 LEFT JOIN (select sum("电商销售数据"."销售金额") as col_3,date_add('year', try_cast(1 as bigint), date_trunc('year', "电商销售数据"."订单日期")) as col_5 from "电商销售数据" group by date_add('year', try_cast(1 as bigint), date_trunc('year', "电商销售数据"."订单日期"))) tbl_3 on col_0=col_5 order by col_0",
"from_clause": "",
"group_by_clause": "",
"having_clause": ""
}
},
"question": "销售金额的年增长率",
"type": "data"
},
"errCode": 0,
"exception": "",
"msgParams": null,
"promptMsg": null,
"success": true
}