观远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 获取单条回复v4
        GET
      • public-api 获取会话消息列表v4
        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
/api/chat/public-api/chat/get-message
轮询只关注 final_status:waiting 继续轮询,success / failure / stopped 均视为完成
final_status:
  waiting ──────────> 继续轮询
  success/failure/stopped ──> 完成

- final_status = stopped
  -> 显示已取消 / 已停止生成

- final_status = failure
  -> 若 query_status = failure,优先显示 query_context.err_msg
  -> 否则显示 answer_context.msg/detail

- final_status = success
      ├── action = reply/reject  → 渲染 answer.explain
      └── action = query
              └── query_status = success
                     ├── maybe_empty = true  → 查询结果为空;如需 SQL 解释,调用 explain-sql 获取
                     └── maybe_empty = false → 渲染图表(依据 card/query_result),可补充 visual_insight
关键字段说明:
字段说明
answer_status大模型生成状态:waiting / success / failure / stopped
query_statusSQL 查询状态:waiting / success / failure / stopped
final_status消息最终状态,success 时 answer_status 和 query_status(若有)均为 success
answer.action回答类型:query(查询数据)、reply(文字回答)、reject(拒绝回答)
answer.explain文字回答内容(action=reply/reject 时),或空行查询的 SQL 解释(action=query, maybe_empty=true 时)
answer_context错误上下文:msg(错误名称)、detail(错误详情),answer_status=failure 时可用
query_context查询错误上下文:err_msg(错误信息),query_status=failure 时可用
query_stats查询结果统计:maybe_empty(查询结果为空)、row_count、column_count
card图表配置(图表类型、维度指标、格式化等)
query_result查询结果数据(columns 列定义 + preview 行数据)
visual_insightAI 数据解读
其他:
answer.action=query:表示图表结果
answer.action=reply:表示文本结果,当前 API 无法区分“自定义回复”与“反问澄清”

请求参数

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 '/api/chat/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
    }
}
🟠401未认证
🟠404未找到
🟠422无法处理的实体
🔴500服务器内部错误
修改于 2026-04-09 11:13:39
上一页
public-api 停止生成
下一页
public-api L1会话消息列表
Built with