The Q&A API supports security review integration. To enable this feature, set the `green_net` parameter to `true` in the general parameters. The security review for Q&A is a two-step process. First, the input question is reviewed for security and compliance. If the question does not meet security standards, the API returns an error message. Second, the response generated by the model is reviewed for security and compliance. For streaming responses, a review is performed for every 10 characters. If the model's response does not meet security standards, the API also returns an error message. Note that the error message format differs between streaming and non-streaming conversations. For more information, see the detailed descriptions below.
General parameters
Request parameters
Top-level parameter | Description | Type | Required |
input | Information for the Large Language Model (LLM). | {} | Yes |
parameters | LLM parameters. | {} | Yes |
debug | Debug mode. | boolean | Yes. The default is false. |
Top-level parameter | Second-level parameter | Description | Type | Required | Default |
input | session_id | The context ID of the conversation. If left empty, a new conversation is created. | string | Required for continuous conversations. | "" |
prompts | The question to ask. | string | Yes | ||
plugin_schemas | Plugin parameters. | {} | |||
max_tokens | The maximum number of tokens in the output. | int | No | 512 | |
stream | Specifies whether to use a streaming conversation. | boolean | No | true | |
tenant_id | Search Service Identity | string | Yes | Static field "msearch" | |
app_id | The service ID. | long | Yes | ||
system_prompt | Pre-set instructions. | string | No | "" | |
green_net | Security review. | boolean | No | false | |
parameters | top_p | The nucleus sampling value of the model. | float | No | 0.7 |
top_k | The sampling range size of the model. | int | No | 50 | |
temperature | The sampling temperature. | int | No | 1 | |
allow_direct_answer | Specifies whether to enable the LLM. | boolean | No | true | |
num_doc | The number of documents to include in the summary. | int | No | 3 | |
tp_search | Specifies whether to force a search. | string | No | "" | |
tp_query_rewrite | Specifies whether to perform query rewriting. | string | No | "" | |
content_fields | Used to concatenate reference information. Use a comma (,) as the separator for multiple fields. | string | No | "" | |
reject_templete | Rejection template. | string | No | "" | |
max_cotent_length | The maximum length of a single knowledge entry, from 50 to 2000. The value of `num_docs` × `max_content_length` must be 6000 or less. | int | No | 1000 |
Second-level parameter | Third-level parameter | Fourth-level parameter | Description | Type | Required | Default |
plugin_schemas | search_enhance | vector_recall_ratio | The vector retrieval ratio, from 0.1 to 0.9. | float | No | 0.7 |
acc_sorting | The number of documents for fine-grained sorting, from 50 to 500. | int | No | 200 | ||
custom_sorting | Custom sorting parameters. | {} | No | "" | ||
search_size | The number of retrieved results for a single query. | int | No | 3 | ||
custom_config_info | Custom search configuration. | {} | No | |||
filters | Filter parameter settings. | [] | No | |||
fields | Retrieval fields (forward index). Use a comma (,) as the separator for multiple fields. | string | No | "" |
Response parameters
Non-streaming conversation: Returns a standard HTTP response. The `data` field contains the chat response data.
Top-level parameter | Second-level parameter | Description |
data | content | The content of the chat response. |
attachment | References, search recommendations, and other information for the current search conversation. | |
session_id | The context information of the current conversation. | |
item_id | A system-generated ID for debugging. | |
hasRisk | Indicates whether the model's response contains sensitive content.
|
Second-level parameter | Third-level parameter | Description |
attachment | refer | Reference information for the current response. |
search_recommend | Search recommendations for the next turn in the conversation. | |
content_fields | Used to concatenate reference information. | |
fields | The primary key used to identify reference information. The first field is used by default. | |
debug | In debug mode, a `debug` field is added. For more information about its content, see Streaming conversation. |
Input question contains non-compliant content:
{
"code" : 8004,
"data" : "The question contains sensitive information",
"httpStatusCode" : 200,
"msg" : "The question contains sensitive information",
"requestId" : "4A930161-3BA8-406A-A76C-540F8B98DCA2",
"success" : true
}Model response contains non-compliant content
{
"code" : 8001,
"data" : {
"attachment" : {
"content_fields" : [
"id",
"gmt_create",
"gmt_modified",
"file_name",
"file_type",
"url"
],
"debug" : {
"child_execs" : [
{
"end_time" : 1705397334081,
"exec_kind" : "AI_FLOW_STEP",
"exec_name" : "search_toggle",
"exec_params" : {
"api_key" : "sk-f******46de",
"history_messages" : [
],
"max_new_tokens" : 512,
"model_id" : "daily-top_qad-392",
"query" : "Alibaba Cloud Summit",
"stream" : false,
"system_prompt" : "",
"top_p" : 0.69999999999999996,
"tp_search" : ""
},
"exec_result" : {
"do_search" : true
},
"exec_status" : true,
"start_time" : 1705397333671,
"trace_id" : "AD6E0C1B-E5DE-488C-BCC9-D2CA08CDEC0D"
},
{
"end_time" : 1705397334676,
"exec_kind" : "AI_FLOW_STEP",
"exec_name" : "search_rewrite",
"exec_params" : {
"api_key" : "sk-f******46de",
"history_messages" : [
],
"max_new_tokens" : 512,
"model_id" : "daily-top_qad-392",
"query" : "Alibaba Cloud Summit",
"stream" : false,
"system_prompt" : "",
"top_p" : 0.69999999999999996,
"tp_query_rewrite" : ""
},
"exec_result" : {
"queries_r" : [
"Alibaba Cloud Summit"
]
},
"exec_status" : true,
"start_time" : 1705397334081,
"trace_id" : "AD6E0C1B-E5DE-488C-BCC9-D2CA08CDEC0D"
},
{
"end_time" : 1705397335075,
"exec_kind" : "AI_FLOW_STEP",
"exec_name" : "search",
"exec_params" : {
"customConfigInfo" : {
"rerankSize" : 200,
"uqVectorRecallRatio" : 0.5
},
"fields" : [
"id",
"gmt_create",
"gmt_modified",
"file_name",
"file_type",
"url"
],
"page" : 1,
"rankModelInfo" : {
"default" : {
"aggregate_algo" : "weight_avg",
"features" : [
{
"name" : "vector_index",
"norm" : true,
"norm_factor" : 0.00050000000000000001,
"score_type" : "L2",
"threshold" : 0,
"weights" : 1
},
{
"field" : "_rc_t_score",
"name" : "static_value",
"norm" : true,
"threshold" : 0,
"weights" : 0.5
}
]
}
},
"rid" : "AD6E0C1B-E5DE-488C-BCC9-D2CA08CDEC0D",
"rows" : 3,
"scene" : "dolphin_search_ms_index_es_1743_pre",
"type" : "file_name,file_type,url,id,vector",
"uq" : "Alibaba Cloud Summit"
},
"exec_result" : {
"code" : 200,
"data" : {
"data" : {
"docs" : [
{
"_id" : "1_10",
"_q_score" : 1,
"_rc_score" : 1,
"_rc_t_score" : 5.5928690000000003,
"_rc_v_score" : 0.55256680000000002,
"_score" : 1.4981447458267212,
"_scores" : {
"static_value(_rc_t_score)" : 0.49814474582672119,
"vector_index" : 1
},
"file_name" : "0- Alibaba Cloud Summit_Xiaoyaozi.pdf",
"file_type" : "pdf",
"gmt_create" : "2024-01-09 16:43:07",
"gmt_modified" : "2024-01-10 16:32:46",
"id" : 1,
"url" : "oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf"
},
{
"_id" : "1_4",
"_q_score" : 1,
"_rc_score" : 1,
"_rc_t_score" : 5.5928690000000003,
"_rc_v_score" : 0.55708396000000004,
"_score" : 1.4981447458267212,
"_scores" : {
"static_value(_rc_t_score)" : 0.49814474582672119,
"vector_index" : 1
},
"file_name" : "0- Alibaba Cloud Summit_Xiaoyaozi.pdf",
"file_type" : "pdf",
"gmt_create" : "2024-01-09 16:43:07",
"gmt_modified" : "2024-01-10 16:32:46",
"id" : 1,
"url" : "oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf"
},
{
"_id" : "1_20",
"_q_score" : 1,
"_rc_score" : 1,
"_rc_t_score" : 5.5928690000000003,
"_rc_v_score" : 0.53299249999999998,
"_score" : 1.4981447458267212,
"_scores" : {
"static_value(_rc_t_score)" : 0.49814474582672119,
"vector_index" : 1
},
"file_name" : "0- Alibaba Cloud Summit_Xiaoyaozi.pdf",
"file_type" : "pdf",
"gmt_create" : "2024-01-09 16:43:07",
"gmt_modified" : "2024-01-10 16:32:46",
"id" : 1,
"url" : "oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf"
}
],
"keywords" : [
{
"fuzzy" : true,
"name" : "full_text",
"schema" : "file_name,file_type,url,id",
"value" : "Alibaba Cloud Summit"
}
],
"qpInfos" : [
{
"cleanQuery" : "Alibaba Cloud Summit",
"operator" : "AND",
"query" : "Alibaba Cloud Summit",
"recognitions" : [
],
"rewrite" : "Alibaba Cloud Summit",
"sensitive" : false,
"spellcheck" : false,
"spellchecked" : "Alibaba Cloud Summit",
"stopWords" : [
],
"synonymWords" : [
],
"tokenized" : [
"Alibaba Cloud",
"Summit"
]
}
],
"total" : 27,
"totalDistinct" : 27
},
"headers" : {
"__d_head_engine_rt" : "q:194-s:[t116,v116]-r:4-i:18",
"__d_head_es_rt" : "t:12",
"__d_head_rtm" : "1705397335069",
"__d_head_sip" : "192.169.X.XXX",
"__d_head_ver" : "0.0.1"
},
"rid" : "AD6E0C1B-E5DE-488C-BCC9-D2CA08CDEC0D",
"status" : 0,
"success" : true
},
"httpStatusCode" : 200,
"requestId" : "AD6E0C1B-E5DE-488C-BCC9-D2CA08CDEC0D",
"success" : true
},
"exec_status" : true,
"start_time" : 1705397334676,
"trace_id" : "AD6E0C1B-E5DE-488C-BCC9-D2CA08CDEC0D"
},
{
"end_time" : 1705397337929,
"exec_kind" : "AI_FLOW_STEP",
"exec_name" : "search_recommend",
"exec_params" : {
"api_key" : "sk-f******46de",
"history_messages" : [
{
"content" : "Alibaba Cloud Summit",
"role" : "user"
},
{
"content" : "According to the provided search results, the presentation file for the Alibaba Cloud Summit can be referred to as 'Alibaba Cloud Summit_Xiaoyaozi.pdf'. This file is stored in Jilin Mobile Search Cloud at oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf [1][2][3].",
"role" : "assistant"
}
],
"max_new_tokens" : 512,
"model_id" : "daily-top_qad-392",
"stream" : false,
"system_prompt" : "",
"top_p" : 0.69999999999999996
},
"exec_result" : {
"queries_s" : [
"What is the Alibaba Cloud Summit?",
"Who are the key speakers?",
"What is the theme of the summit?"
]
},
"exec_status" : true,
"start_time" : 1705397336739,
"trace_id" : "AD6E0C1B-E5DE-488C-BCC9-D2CA08CDEC0D"
}
],
"exec_kind" : "AI_FLOW",
"exec_name" : "corp_search_v2.json",
"exec_params" : {
"async_run" : false,
"debug" : true,
"flow_json_url" : "https://******/corp_search_v2.json",
"flow_params" : {
"allow_direct_answer" : true,
"api_key" : "sk-f******46de",
"content_fields" : "id,gmt_create,gmt_modified,file_name,file_type,url",
"custom_config_info" : "{\"rerankSize\": 200, \"uqVectorRecallRatio\": 0.5}",
"fields" : "id,gmt_create,gmt_modified,file_name,file_type,url",
"human_input" : "Alibaba Cloud Summit",
"max_content_length" : 1000,
"max_new_tokens" : 512,
"num_doc" : 3,
"rank_model_info" : "{\"default\": {\"features\": [{\"name\": \"vector_index\", \"weights\": 1, \"threshold\": 0, \"norm\": true, \"norm_factor\": 0.0005, \"score_type\": \"L2\"}, {\"name\": \"static_value\", \"field\": \"_rc_t_score\", \"weights\": 0.5, \"threshold\": 0, \"norm\": true}], \"aggregate_algo\": \"weight_avg\"}}",
"reject_template" : "",
"scene" : "dolphin_search_ms_index_es_1743_pre",
"search_size" : 3,
"system_input" : "",
"temperature" : 1,
"top_k" : 50,
"top_p" : 0.69999999999999996,
"tp_query_rewrite" : "",
"tp_search" : "",
"type" : "file_name,file_type,url,id,vector"
},
"round_id" : "f-r-6ShmeWG46UEMTVho34YBTv",
"session_id" : "f-s-WztQqCTsSrBSbtyPSa9qWB",
"streaming" : false
},
"exec_result" : {
"ext" : {
},
"prompt" : "{\"query\": \"Alibaba Cloud Summit\", \"model_id\": \"daily-top_qad-392\", \"api_key\": \"sk-f******46de\", \"stream\": false, \"search_results\": [{\"id\": 1, \"content\": \"1\\n2024-01-09 16:43:07\\n2024-01-10 16:32:46\\n0- Alibaba Cloud Summit_Xiaoyaozi.pdf\\npdf\\noss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf\", \"raw_search_result\": {\"gmt_create\": \"2024-01-09 16:43:07\", \"_rc_v_score\": 0.5525668, \"file_name\": \"0- Alibaba Cloud Summit_Xiaoyaozi.pdf\", \"_q_score\": 1.0, \"gmt_modified\": \"2024-01-10 16:32:46\", \"_score\": 1.4981447458267212, \"url\": \"oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf\", \"_rc_score\": 1.0, \"_rc_t_score\": 5.592869, \"_scores\": {\"vector_index\": 1.0, \"static_value(_rc_t_score)\": 0.4981447458267212}, \"file_type\": \"pdf\", \"id\": 1, \"_id\": \"1_10\"}}, {\"id\": 2, \"content\": \"1\\n2024-01-09 16:43:07\\n2024-01-10 16:32:46\\n0- Alibaba Cloud Summit_Xiaoyaozi.pdf\\npdf\\noss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf\", \"raw_search_result\": {\"gmt_create\": \"2024-01-09 16:43:07\", \"_rc_v_score\": 0.55708396, \"file_name\": \"0- Alibaba Cloud Summit_Xiaoyaozi.pdf\", \"_q_score\": 1.0, \"gmt_modified\": \"2024-01-10 16:32:46\", \"_score\": 1.4981447458267212, \"url\": \"oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf\", \"_rc_score\": 1.0, \"_rc_t_score\": 5.592869, \"_scores\": {\"vector_index\": 1.0, \"static_value(_rc_t_score)\": 0.4981447458267212}, \"file_type\": \"pdf\", \"id\": 1, \"_id\": \"1_4\"}}, {\"id\": 3, \"content\": \"1\\n2024-01-09 16:43:07\\n2024-01-10 16:32:46\\n0- Alibaba Cloud Summit_Xiaoyaozi.pdf\\npdf\\noss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf\", \"raw_search_result\": {\"gmt_create\": \"2024-01-09 16:43:07\", \"_rc_v_score\": 0.5329925, \"file_name\": \"0- Alibaba Cloud Summit_Xiaoyaozi.pdf\", \"_q_score\": 1.0, \"gmt_modified\": \"2024-01-10 16:32:46\", \"_score\": 1.4981447458267212, \"url\": \"oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf\", \"_rc_score\": 1.0, \"_rc_t_score\": 5.592869, \"_scores\": {\"vector_index\": 1.0, \"static_value(_rc_t_score)\": 0.4981447458267212}, \"file_type\": \"pdf\", \"id\": 1, \"_id\": \"1_20\"}}], \"history_messages\": [], \"seed\": 1705397335, \"system_prompt\": \"\", \"temperature\": 1.0, \"top_p\": 0.7, \"top_k\": 50, \"length_penalty\": 1.0, \"num_doc\": 3, \"answer_doc\": false, \"max_new_tokens\": 512, \"tp_answer\": \"\", \"allow_direct_answer\": true, \"max_content_length\": 1000, \"reject_template\": \"\"}",
"result" : [
"According to the provided search results, the presentation file for the Alibaba Cloud Summit can be referred to as 'Alibaba Cloud Summit_Xiaoyaozi.pdf'. This file is stored in Jilin Mobile Search Cloud at oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf [1][2][3]."
]
},
"exec_status" : true,
"start_time" : 1705397333669,
"trace_id" : "AD6E0C1B-E5DE-488C-BCC9-D2CA08CDEC0D"
},
"fields" : [
"id",
"gmt_create",
"gmt_modified",
"file_name",
"file_type",
"url"
],
"refer" : [
{
"file_name" : "0- Alibaba Cloud Summit_Xiaoyaozi.pdf",
"file_type" : "pdf",
"gmt_create" : "2024-01-09 16:43:07",
"gmt_modified" : "2024-01-10 16:32:46",
"id" : 1,
"score" : 1.4981447458267212,
"url" : "oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf"
},
{
"file_name" : "0- Alibaba Cloud Summit_Xiaoyaozi.pdf",
"file_type" : "pdf",
"gmt_create" : "2024-01-09 16:43:07",
"gmt_modified" : "2024-01-10 16:32:46",
"id" : 1,
"score" : 1.4981447458267212,
"url" : "oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf"
},
{
"file_name" : "0- Alibaba Cloud Summit_Xiaoyaozi.pdf",
"file_type" : "pdf",
"gmt_create" : "2024-01-09 16:43:07",
"gmt_modified" : "2024-01-10 16:32:46",
"id" : 1,
"score" : 1.4981447458267212,
"url" : "oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf"
}
],
"search_recommend" : [
"What is the Alibaba Cloud Summit?",
"Who are the key speakers?",
"What is the theme of the summit?"
]
},
"content" : "**The text may contain sensitive information**",
"hasRisk" : true,
"item_id" : "f-r-6ShmeWG46UEMTVho34YBTv",
"session_id" : "f-s-WztQqCTsSrBSbtyPSa9qWB"
},
"httpStatusCode" : 200,
"msg" : "**The text may contain sensitive information**",
"requestId" : "AD6E0C1B-E5DE-488C-BCC9-D2CA08CDEC0D",
"success" : true
}Streaming conversation
Input question contains non-compliant content
id:system
event:error
data:{"errorCode":8004,"errorMsg":"The question contains sensitive information","data":"The question contains sensitive information"}
retry:3000Model response contains non-compliant content
id:system
event:open
data:success
retry:3000
id:85712A88-4BA3-45C1-A6F7-A346F4BCDA86
event:control
data:{"attachment":{"ext":null,"payload":{"do_search":true},"name":"search_toggle"},"item_id":"f-r-G43qdUWdN2VVwFe5ecLJsJ","session_id":"f-s-jmnBcTDqNMKUUsGwHMXhfS","content":"search_toggle"}
retry:3000
id:85712A88-4BA3-45C1-A6F7-A346F4BCDA86
event:control
data:{"attachment":{"ext":null,"payload":{"queries_r":["Alibaba Cloud Summit"]},"name":"search_rewrite"},"item_id":"f-r-G43qdUWdN2VVwFe5ecLJsJ","session_id":"f-s-jmnBcTDqNMKUUsGwHMXhfS","content":"search_rewrite"}
retry:3000
id:85712A88-4BA3-45C1-A6F7-A346F4BCDA86
event:control
data:{"attachment":{"ext":null,"payload":{"refer":[{"gmt_create":"2024-01-09 16:43:07","score":1.4981447458267212,"file_name":"0- Alibaba Cloud Summit_Xiaoyaozi.pdf","file_type":"pdf","id":1,"gmt_modified":"2024-01-10 16:32:46","url":"oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf"},{"gmt_create":"2024-01-09 16:43:07","score":1.4981447458267212,"file_name":"0- Alibaba Cloud Summit_Xiaoyaozi.pdf","file_type":"pdf","id":1,"gmt_modified":"2024-01-10 16:32:46","url":"oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf"},{"gmt_create":"2024-01-09 16:43:07","score":1.4981447458267212,"file_name":"0- Alibaba Cloud Summit_Xiaoyaozi.pdf","file_type":"pdf","id":1,"gmt_modified":"2024-01-10 16:32:46","url":"oss://msearch-cloud-jilin/dz_test/testDir/0- Alibaba Cloud Summit_Xiaoyaozi.pdf"}],"uq":"Alibaba Cloud Summit"},"name":"search"},"item_id":"f-r-G43qdUWdN2VVwFe5ecLJsJ","session_id":"f-s-jmnBcTDqNMKUUsGwHMXhfS","content":"search"}
retry:3000
id:85712A88-4BA3-45C1-A6F7-A346F4BCDA86
event:message
data:{"attachment":null,"item_id":"f-r-G43qdUWdN2VVwFe5ecLJsJ","session_id":"f-s-jmnBcTDqNMKUUsGwHMXhfS","content":"According to the provided sea"}
retry:3000
id:system
event:error
data:{"errorCode":8001,"errorMsg":"**The text may contain sensitive information**","data":"**The text may contain sensitive information**"}
retry:3000
id:system
event:close
data:success
retry:3000