Skip to content

GPT TEXT TO DATA 接口文档

作用:通过自然语言查询数据, 集成GPT能力, 可多轮对话

接口信息:

PATH:/df/rest/table/list

METHOD: GET

获取系统中所有已导入表信息

Header 请求参数

json
Authorization: Bearer M2M5YzY2TE0ZmEwMDNZjY1MDRkMGNkNWIuYTUxYThkZjJkGQ3NGZlZmJlZmIMGM2YTA3MDhlNg=

请求参数

NameLocationTypeRequiredDescription
namequerystringno表名查询参数
Authorizationheaderstringyesnone

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

NameTypeRequiredRestrictionsTitledescription
» successbooleantruenone结果true:成功 false:失败
» exceptionstringtruenone异常信息异常信息
» errCodeintegertruenone错误码非零为出错
» promptMsgobjectfalsenone异常提示异常提示信息
» data[数据表信息]falsenone响应数据体响应数据体

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

NameLocationTypeRequiredDescription
Authorizationheaderstringyesnone
bodybodyanynonone

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

NameTypeRequiredRestrictionsTitledescription
» successbooleantruenone结果true:成功 false:失败
» exceptionstringtruenone异常信息异常信息
» errCodeintegertruenone错误码非零为出错
» promptMsgobjectfalsenone异常提示异常提示信息
» data[数据表信息]falsenone响应数据体响应数据体

Data Schema

数据源配置参数

json
{
  "type": "string",
  "name": "string",
  "description": "string",
  "schemaName": "string",
  "host": "string",
  "port": 0,
  "user": "string",
  "password": "string",
  "db": "string",
  "jdbcSuffix": "string"
}

Attribute

NameTypeRequiredRestrictionsTitleDescription
typestringtruenone数据源类型none
namestringtruenone数据源名称none
descriptionstringfalsenone数据源描述none
schemaNamestringfalsenoneSchema信息none
hoststringtruenone主机地址none
portintegertruenone端口信息none
userstringtruenone用户名none
passwordstringtruenone用户密码none
dbstringtruenone数据库名none
jdbcSuffixstringfalsenoneJDBC附加参数none

数据源配置参数说明

数据源类型参数: type 支持下面的数据源

type数据源
mysqlMySQL
postgresqlPosgresql
sqlserverSQLServer
oracleOracle
ibmdb2IBMDB2
gaussdb100GaussDB100
sybaseSybase
greenplumGreenplum
clickhouseClickhouse
teradataTeradata
dorisDoris
tidbTIDB
hanaHana
clickzettaClickzetta
impalaImpala
damengDM8
argodbArgoDB
kuduKudu
elasticsearchElasticsearch
mongodbMongodb
prometheusPrometheus
hiveHive
delta_lakeDelta-Lake
icebergIceberg

每种数据源的配置方式多少有点不一样,支持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

NameTypeRequiredRestrictionsTitleDescription
idstringtruenone表idnone
tblNamestringtruenone原始表名none
tblDisplayNamestringtruenone显示表名none
columns[object]truenone列列表none
» idstringtruenone列idnone
» colNamestringtruenone原始列名none
» colDisplayNamestringtruenone显示列名none
» dataTypestringtruenone数据类型none

基本响应对象

json
{
  "success": true,
  "exception": "string",
  "errCode": 0,
  "promptMsg": {},
  "data": {}
}

Attribute

NameTypeRequiredRestrictionsTitleDescription
successbooleantruenone结果true:成功 false:失败
exceptionstringtruenone异常信息异常信息
errCodeintegertruenone错误码非零为出错
promptMsgobjectfalsenone异常提示异常提示信息
dataobjectfalsenone响应数据体响应数据体

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"
  ]
}

请求参数

名称位置类型必选说明
Authorizationheaderstringbearer token
bodybodyobjectnone
» languagebodystring语言环境
» dataSourcebodyobject数据源信息
»» typebodystring数据源类型
»» namebodystring数据源名称
»» descriptionbodystring数据源描述
»» schemaNamebodystringSchema信息
»» hostbodystring主机地址
»» portbodyinteger端口信息
»» userbodystring用户名
»» passwordbodystring用户密码
»» dbbodystring数据库名
»» jdbcSuffixbodystringJDBC附加参数
» namesbody[string]表显示名列表

说明

当 dataSource 为空时,会从系统中选择 names 列表中的表使用。 当 dataSource 不为空时,会注册dataSource中 names 列表中的表到系统中使用[不会重复注册]。

枚举值

language:语言环境

含义
chinese中文
english英文

dataSource.type:数据源类型参数

含义
mysqlMySQL
postgresqlPosgresql
sqlserverSQLServer
oracleOracle
ibmdb2IBMDB2
gaussdb100GaussDB100
sybaseSybase
greenplumGreenplum
clickhouseClickhouse
teradataTeradata
dorisDoris
tidbTIDB
hanaHana
clickzettaClickzetta
impalaImpala
damengDM8
argodbArgoDB
kuduKudu
elasticsearchElasticsearch
mongodbMongodb
prometheusPrometheus
hiveHive
delta_lakeDelta-Lake
icebergIceberg

数据源参数示例: 每种数据源的配置方式多少有点不一样,支持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

名称类型必选约束中文名说明
» errCodeintegertruenonenone
» exceptionstringtruenonenone
» datastringtruenonechat id:后续对话使用

PATH:/df/rest/gpt/data

METHOD: POST

对话查询

Header 请求参数

json
Authorization: Bearer M2M5YzY2TE0ZmEwMDNZjY1MDRkMGNkNWIuYTUxYThkZjJkGQ3NGZlZmJlZmIMGM2YTA3MDhlNg=

Body 请求参数

json
{
  "input": "string",
  "chatId": "string"
}

请求参数

名称位置类型必选说明
Authorizationheaderstringbearer token
bodybodyobjectnone
» inputbodystring用户输入的问题
» chatIdbodystring对话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

名称类型必选约束说明
» errCodeintegertruenonenone
» exceptionstringtruenonenone
» dataobjecttruenonenone
»» codeintegertruenone错误码, 非0表示错误
»» infostringtruenone提示信息或者错误信息
»» typestringtruenone类型
»» contentobjecttruenonenone
»»» durationstringtruenone查询耗时
»»» headers[object]truenone列头信息
»»»» sufstringtruenone列头操作
»»»» displaystringtruenone列头名字+列头操作
»»»» namestringtruenone列头名字
»»» columns[array]truenone查询结果,二维数组
»»» countintegertruenone查询的记录数
»»» titlestringtruenone标题
»»» sqlobjecttruenone实际执行的sql
»»»» where_clausestringtruenonenone
»»»» order_by_clausestringtruenonenone
»»»» select_clausestringtruenonenone
»»»» from_clausestringtruenonenone
»»»» group_by_clausestringtruenonenone
»»»» having_clausestringtruenonenone
»» questionstringtruenone解析后的问题
» msgParamsnulltruenonenone
» promptMsgnulltruenonenone
» successbooleantruenonenone

枚举值

type:返回结果类型

含义
data数据结果
assistantgpt交互信息

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
}