SafeQuestionPoll - Poll for Question Results

Poll to query the analysis execution status and results for a specified question.

Interface Description

After submitting a question via Text2InsightQuery, the client must call this interface in a loop to retrieve the analysis progress and final results. Each call returns all responses messages produced so far.

Polling Strategy

ParameterRecommended Value
Polling interval2 seconds
Single request timeout60 seconds
Total timeout360 seconds

Termination Condition

On each poll, check the dataType of the last message in the responses array. Stop polling when the value is one of the following:

  • finish — Analysis completed normally
  • finish_stop — User actively stopped the analysis
  • error — Execution error occurred

Request Method

POST /open/safe_question_poll?tenantId={tenantId}&userId={userId}&loginToken={loginToken}

Request Parameters

ParameterLocationTypeRequiredDescription
tenantIdQuery + BodyIntegerYesTenant ID
userIdQuery + BodyIntegerYesUser ID
domainIdBodyIntegerYesData domain ID
questionIdBodyIntegerYesQuestion ID, obtained via Text2InsightQuery
loginTokenQuery + BodyStringYesAuthentication Token

Response Parameters

ParameterTypeDescription
successBooleanWhether the request was successful
data.responsesArrayMessage list containing all messages produced during the analysis
data.responses[].idStringMessage ID
data.responses[].dataTypeStringMessage type, see description below
data.responses[].messageStringMessage text content
data.responses[].modelResObjectRaw structure returned by the model
data.responses[].modelRes.codeIntegerModel response code
data.responses[].modelRes.dataObjectBusiness data returned by the model

Message Type Description (dataType)

TypeDescriptionKey Fields
messageGeneral message; may contain knowledge details or execution logsmessage, knowledgeData
notifyProgress notification (e.g., "Thinking")message
summaryAnalysis summary containing the final answersummaryData
metricMetric calculation resultmessage, metricDsl, physicalMetricDsl
echarts_plusChart datamessage, chartType, columns, calculateSql
codeCode block (e.g., generated SQL)message, codeType, code
finishAnalysis ended normallymessage
finish_stopUser actively stoppedmessage
errorExecution errormessage

Field Read Priority

Business fields in each responses message may appear at different levels. Read in the following priority order:

  1. Top level: response[fieldName]
  2. modelRes: response.modelRes.data[fieldName]
  3. rawRes: parse response.rawRes (JSON string) and retrieve data[fieldName]

Request Example

POST /open/safe_question_poll Content-Type: application/json { "tenantId": 10, "userId": 1, "domainId": 106, "questionId": 34339, "loginToken": "eyJhbGciOiJIUzI1NiJ9..." }

Response Examples

Analysis In Progress

{ "success": true, "data": { "responses": [ { "id": "745601", "dataType": "notify", "message": "Thinking next step" } ] } }

Analysis Complete (with metric results)

{ "success": true, "data": { "responses": [ { "id": "745618", "dataType": "message", "message": "Viewed knowledge details: Beijing Second-hand Housing 10-year Transaction Data", "modelRes": { "code": 200, "data": { "dataType": "message", "message": "Viewed knowledge details: Beijing Second-hand Housing 10-year Transaction Data", "knowledgeData": { "detailItems": [ { "id": 51, "keys": "Beijing Second-hand Housing 10-year Transaction Data", "value": "{\"desc\": \"If no time is explicitly specified in the question, use yesterday\", \"type\": \"time_range_func\"}", "type": "TEXT" } ] } } } }, { "id": "745620", "dataType": "metric", "message": "Metric: Total Transaction Amount by District in the Past 6 Years", "modelRes": { "code": 200, "data": { "dataType": "metric", "message": "Metric: Total Transaction Amount by District in the Past 6 Years", "metricDsl": "{\"useDefaultLimit\":true,\"metricId\":{\"metricType\":\"SQL_SIMPLE\",\"id\":631},\"name\":\"Total Transaction Amount by District in the Past 6 Years\"}", "physicalMetricDsl": "{\"useDefaultLimit\":true,\"metricId\":{\"metricType\":\"SQL_SIMPLE\",\"id\":631}}" } } }, { "id": "745625", "dataType": "echarts_plus", "message": "Beijing Second-hand Housing Total Transaction Amount by District in the Past 6 Years (2015-2021)", "modelRes": { "code": 200, "data": { "dataType": "echarts_plus", "chartType": "ECHARTS", "columns": "District (STRING), Total Transaction Amount (10K CNY) (LONG)", "calculateSql": "SELECT region AS district, SUM(transaction_price) AS total_transaction_amount FROM ... GROUP BY region" } } }, { "id": "745630", "dataType": "summary", "message": "Analysis complete", "modelRes": { "code": 200, "data": { "dataType": "summary", "summaryData": "**Beijing Second-hand Housing Total Transaction Amount by District in the Past 6 Years:**\n- Chaoyang District: CNY 103.49 billion\n- Haidian District: CNY 58.50 billion\n..." } } }, { "id": "745631", "dataType": "finish", "message": "Analysis complete" } ] } }

Error Codes

Error CodeDescription
success=falseToken is invalid, questionId does not exist, or insufficient permissions