观远chatbi public-api 接口说明
  1. 会话
观远chatbi public-api 接口说明
  • public-api 使用文档
  • public-api
    • 知识库
      • public-api 获取问答知识库
    • 反馈
      • public-api 消息收藏列表
      • public-api 常用问题列表
      • public-api 添加常用问题
      • public-api 更新常用问题
      • public-api 删除常用问题
      • public-api 收藏消息
      • public-api 重命名收藏标题
      • public-api 取消收藏消息
      • public-api 点赞踩
    • 主题
      • public-api 主题列表
      • public-api 获取主题的使用者和所有者
      • public-api 获取主题配置
      • public-api 查询 theme_info
      • 获取分析专家列表
    • 会话
      • public-api 会话列表
        GET
      • public-api 获取会话状态
        GET
      • public-api 发送消息
        POST
      • public-api L1发送消息(同步版)
        POST
      • public-api 停止生成
        POST
      • public-api L1单条消息详情
        GET
      • public-api L1会话消息列表
        GET
      • public-api L2单组回复消息v3
        GET
      • public-api L2会话消息列表v3
        GET
      • public-api L2单条回复内容
        GET
      • public-api L2会话报告列表
        GET
      • public-api 删除会话
        POST
      • public-api 重命名会话
        POST
      • public-api 触发SQL查询的解释说明
        POST
      • public-api 引导问题
        POST
      • public-api L1推荐问题
        POST
  1. 会话

public-api L1单条消息详情

GET
/public-api/chat/get-message
发送消息后,通过该接口进行轮询,获取消息回答(含SQL查数结果)。
1.
先等待 answer_status 变为success,获取 answer 内容即消息回答,同步可访问 rewritten_question,以及 sql、table 字段(如果有 sql 生成);
2.
再等待 final_status 变为 success,表示回答流程完全结束。
注,当前为过渡版,query_status 可替代 final_status,未来调整为:
1.
先等待 answer_status 变为success,获取 answer 内容即消息回答,同步可访问 rewritten_question,以及 sql、table 字段(如果有 sql 生成);
2.
如果有 sql 生成,再等待 query_status 变为 success,可以访问 query_result、query_context、query_stats;
3.
最后等待 final_status 变为 success,表示回答流程完全结束,可以访问 finished_at、card、visual_insight等所有字段。

各状态字段值组合明细表#

answer_statusquery_statusfinal_statuscomment
waiting/waiting
failure/failure
stopped/stopped
success/success未生成sql但正常文本回复,则无查询任务。
successwaitingwaiting
successfailurefailure
successstoppedstopped
successsuccess(过渡版为waiting)waiting过渡版逻辑:如果整体任务未结束,查询状态强制设为waiting
successsuccesssuccess
successsuccessfailure异常组合。极端情况下会出现,比如网络问题等导致两个服务之间断联,server完成查询,但datamind未及时接收到查询状态(也就无法执行后续的可视化、解读等环节),最终标记失败。
注:可视化、解读等环节被视为非阻塞环节,单纯失败不会导致整体任务被标记为失败。

请求参数

Query 参数

Header 参数

请求示例代码

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location -g --request GET '/public-api/chat/get-message?theme_id={{theme_id_local}}&message_id={{message_id_local}}' \
--header 'Timestamp;' \
--header 'Cookie: {{cookie}}' \
--header 'Content-Type: application/json'

返回响应

🟢200成功
application/json
Body

示例
{
    "code": 200,
    "message": "SUCCESS",
    "data": {
        "theme_id": "eade767f-8b20-4072-a5bf-b671c93ce0ba",
        "session_id": "6450d7be-4154-45f8-bafb-a4519c2fc2c4",
        "message_id": "e258ba42-d20a-4837-87cf-e9d6dc1257ef",
        "question": "23年7月小紫瓶销售额是多少?",
        "rewritten_question": "23年7月小紫瓶销售额是多少?",
        "answer": {
            "action": "query",
            "explain": "查询2023年7月期间,系列名称包含“小紫瓶”的商品总销售额。",
            "thoughts": "The user is asking for the sales revenue of the '小紫瓶' series in July 2023. I need to filter the data for the specified series and date range, then sum the sales revenue.",
            "query": "SELECT SUM(`订单公司零售额`) AS `销售额` FROM `销售表` WHERE `系列` LIKE '%小紫瓶%' AND `成交日期` >= '2023-07-01' AND `成交日期` <= '2023-07-31'"
        },
        "sql": "SELECT SUM(`订单公司零售额`) AS `销售额` FROM `销售表` WHERE `系列` LIKE '%小紫瓶%' AND `成交日期` >= '2023-07-01' AND `成交日期` <= '2023-07-31'",
        "card": {
            "dimensions": [],
            "metrics": [
                {
                    "name": "销售额",
                    "formatType": "NUMBER"
                }
            ],
            "viz_config": null
        },
        "table": [
            {
                "table_id": "l1332d5da34154206bf23152",
                "table_name": "销售表"
            }
        ],
        "recommended_cards": [
            {
                "card_id": "p3316b9dbf8ed4b479500962",
                "card_name": "用户访问次数",
                "page_id": "sfaa1c3306db24e2e8ba1d14",
                "page_name": "BI平台用户行为分析",
                "recommend_id": "ab5dc6e4-83df-4100-a026-40750abe126d",
                "relevance_score": 6.466653,
                "is_relevant_feedback": false
            }
        ],
        "user_info": {
            "user_id": "Y2hlbm1pbmd6aG91",
            "username": "陈铭洲"
        },
        "feedback": {
            "is_collected": false,
            "vote": {
                "vote_type": null,
                "comment": null
            }
        },
        "answer_status": "success",
        "created_at": "2025-01-06 16:04:01",
        "task_context": {
            "stage": "finished",
            "history": [
                {
                    "stage": "intent_recognition",
                    "content": {
                        "rewritten_question": "23年7月小紫瓶销售额是多少?",
                        "intent": "write query"
                    },
                    "end_time": "2025-01-06 16:04:04"
                },
                {
                    "stage": "knowledge_search",
                    "content": {
                        "knowledge": []
                    },
                    "end_time": "2025-01-06 16:04:07"
                },
                {
                    "stage": "choose_table",
                    "content": {
                        "tables": [
                            {
                                "table_id": "l1332d5da34154206bf23152",
                                "table_name": "销售表"
                            }
                        ]
                    },
                    "end_time": "2025-01-06 16:04:08"
                },
                {
                    "stage": "reply_generation",
                    "content": {
                        "thought": "The user is asking for the sales revenue of the '小紫瓶' series in July 2023. I need to filter the data for the specified series and date range, then sum the sales revenue."
                    },
                    "end_time": "2025-01-06 16:04:14"
                }
            ]
        },
        "query_status": "success",
        "query_result": {
            "columns": [
                {
                    "name": "销售额",
                    "fdType": "DOUBLE",
                    "seqNo": 0
                }
            ],
            "preview": [
                [
                    "2706.058367607085"
                ]
            ]
        },
        "query_context": null
    }
}
修改于 2026-03-03 06:31:28
上一页
public-api 停止生成
下一页
public-api L1会话消息列表
Built with