[Question]: The answer returned by the API call, but "reference": [], is empty.
Describe your problem
`def get_completion(conversation_id, message, headers):
url_completion = f"{base_url}/completion"
data = {
"conversation_id": conversation_id,
"messages": [
{
"role": "user",
"content": message
}
]
}
response = requests.post(url_completion, json=data, headers=headers)
print("Raw response status code:", response.status_code)
print("Raw response content:", response.text) `
data:{"retcode": 0, "retmsg": "", "data": {"answer": "Quantum entanglement is a phenomenon in quantum mechanics where two or more particles become interconnected in such a way that the state of one particle instantly influences the state of another, no matter how far apart they are. This correlation between particles is non-classical and cannot be explained by classical physics.\n\nIn the knowledge base provided, quantum entanglement is described in various contexts:\n\n1. Quantum Teleportation: Quantum teleportation relies on entanglement to transfer quantum states between distant parties without physical transmission of particles. Alice and Bob share entangled particles, and when Alice performs a joint measurement on her particles, it affects Bob's particle instantaneously, allowing for the teleportation of the quantum state (Introduction).\n\n2. Protection Against Decoherence: Entanglement is crucial for quantum technologies like computing and communication. Strategies such as error correction, decoherence-free subspaces, and dynamical decoupling are used to protect entangled states from environmental noise that can degrade quantum information (Conclusions).\n\n3. Entanglement Sudden Death (ESD): The knowledge base also mentions ESD, which refers to the sudden disappearance of entanglement in a finite amount of time due to environmental interactions (Conclusions).\n\n4. Non-Markovian Quantum-State-Diffusion (QSD) Methodology: The QSD methodology is employed to study the dynamics of entangled systems under relaxation and dephasing noise, highlighting the importance of understanding how environmental influences affect entangled states (Introduction).\n\nIn summary, quantum entanglement is a fundamental resource in quantum information science, enabling phenomena like teleportation and serving as a key element in protecting quantum states from decoherence. It represents a deep connection between particles that transcends classical understanding and has significant implications for developing advanced quantum technologies.", "reference": [], "prompt": "You are an intelligent assistant. Please summarize the content of the knowledge base to answer the question. Please list the data in the knowledge base and answer in detail. When all knowledge base content is irrelevant to the question, your answer must include the sentence "The answer you are looking for is not found in the knowledge base!" Answers need to consider chat history.\n Here is the knowledge base:\n d stability of quantum entanglement.\n\n\n\section*{Conclusions }\n\label{4}\nIn conclusion, our research ha..... a known two-qubit quantum state to the Nth order using\n The above is the knowledge base.\n ", "id": "a1dc17ac69d111ef83f00242ac120002"}} data:{"retcode": 0, "retmsg": "", "data": true}
How to properly obtain reference.
mee too,wait for close
+1
No matter what the question is, the reference is empy, isn't it? Try add a parameter after URL conversation/completion?quote=True
mee too +1
No matter what the question is, the reference is empy, isn't it? Try add a parameter after URL conversation/completion?quote=True
在 0.8.0 版本后,completion api 的响应结构 reference 的数据类型由 {} 变为 [] ,并且不会返回任何内容,该问题已跨过 3 个 release 仍没有被修复
me too
This is a post request: conversation/completion What about adding the parameter "quote": true ?
yes. At the beginning, it was set as not allowed. Later, I updated the code and searched extensively. I looked at the program code and API code, and found that it was the problem.
Here is return
{
"retcode": 0,
"retmsg": "",
"data": {
"answer": "您的输入是“1”,但是没有具体的问题或者上下文,我无法给出准确的回答。请提供更多细节或提出一个具体问题以便我能更好地帮助您。如果当前提供的内容来源于特定情境或相关技术问题,请明确指出。根据现有的知识库内容,它主要涉及ElasticSearch查询构造和处理,包括排序、高亮显示选项、向量查询以及过滤器的应用等。如果您有关于这些主题的问题,欢迎提问!若您的问题是其他方面,请提供更多信息。如果我的理解有误或是您需要的信息在上述知识库中未能涵盖,请告知。知识库中未找到您要的答案!请尝试提供更多信息 ##5$$。",
"reference": {
"total": 35,
"chunks": [
{
"chunk_id": "0da7f310fed135578518497b06ed9a13",
"content_ltks": "\r\n\r\n原文链接: http://blog.csdn.net/hustyichi/articl/detail/139162109 ",
"content_with_weight": "\r\n \r\n原文链接:https://blog.csdn.net/hustyichi/article/details/139162109",
"doc_id": "5c5999ec7be811ef9cab0242ac120005",
"kb_id": "c7ee74067a2c11efb21c0242ac120006",
"important_kwd": [],
"img_id": "",
"similarity": 0.7988756515874501,
"vector_similarity": 0.32958550529150055,
"term_similarity": 1.0,
"positions": [
""
],
"doc_name": "1.txt"
},
{
"chunk_id": "bd94afaf822744f55bad32deb5aa227c",
"content_ltks": ") els:s=s.sort ({``page_num_int'':{``order'':``asc'',``unmapped_typ'':``float'',``mode'':``avg'',``numeric_typ'':``doubl''}},{``top_int'':{``order'':``asc'',``unmapped_typ'':``float'',``mode'':``avg'',``numeric_typ'':``doubl''}},{``create_tim'':{``order'':``desc'',``unmapped_typ'':``date''}},{``create_timestamp_flt'':{``order'':``desc'',``unmapped_typ'':``float''}}) if qst:",
"content_with_weight": " )\r\n else:\r\n s = s.sort(\r\n {\"page_num_int\": {\"order\": \"asc\", \"unmapped_type\": \"float\",\r\n \"mode\": \"avg\", \"numeric_type\": \"double\"}},\r\n {\"top_int\": {\"order\": \"asc\", \"unmapped_type\": \"float\",\r\n \"mode\": \"avg\", \"numeric_type\": \"double\"}},\r\n {\"create_time\": {\"order\": \"desc\", \"unmapped_type\": \"date\"}},\r\n {\"create_timestamp_flt\": {\r\n \"order\": \"desc\", \"unmapped_type\": \"float\"}}\r\n )\r\n\r\n if qst:\r\n",
"doc_id": "5c5999ec7be811ef9cab0242ac120005",
"kb_id": "c7ee74067a2c11efb21c0242ac120006",
"important_kwd": [],
"img_id": "",
"similarity": 0.699711587634386,
"vector_similarity": 0.26897231870836696,
"term_similarity": 0.8843141314598228,
"positions": [
""
],
"doc_name": "1.txt"
},
{
"chunk_id": "99756fc56baf8e80a24fa3ce5cd78296",
"content_ltks": "if not ins_embd:return[] ,[] ,[] for i in sres.id:if isinst (sres.field[i].get (``important_kwd'',[]) , str) :sres.field[i][``important_kwd'']=[ sres.field[i][``important_kwd'']]ins_tw=[]for i in sres.id:content_ltk=sres.field[i][ cfield].split (````) title_tk=[ t for t in sres.field[i].get (``title_tk'',``'') .split (````) if t]important_kwd=sres.field[i].get (``important_kwd'',[])",
"content_with_weight": " if not ins_embd:\r\n return [], [], []\r\n\r\n for i in sres.ids:\r\n if isinstance(sres.field[i].get(\"important_kwd\", []), str):\r\n sres.field[i][\"important_kwd\"] = [sres.field[i][\"important_kwd\"]]\r\n ins_tw = []\r\n for i in sres.ids:\r\n content_ltks = sres.field[i][cfield].split(\" \")\r\n title_tks = [t for t in sres.field[i].get(\"title_tks\", \"\").split(\" \") if t]\r\n important_kwd = sres.field[i].get(\"important_kwd\", [])\r\n",
"doc_id": "5c5999ec7be811ef9cab0242ac120005",
"kb_id": "c7ee74067a2c11efb21c0242ac120006",
"important_kwd": [],
"img_id": "",
"similarity": 0.6947410312104952,
"vector_similarity": 0.2701449572594527,
"term_similarity": 0.8767107771895135,
"positions": [
""
],
"doc_name": "1.txt"
},
{
"chunk_id": "1360477f35a2928400d2a01416738a20",
"content_ltks": "``q_1024_vec'',``q_1536_vec'',``available_int'',``content_with_weight'']) s=s.queri (bqri) [pg*p:( pg+1) *p]s=s.highlight (``content_ltk'') s=s.highlight (``title_ltk'') if not qst:if not req.get (``sort''):s=s.sort ({``create_tim'':{``order'':``desc'',``unmapped_typ'':``date''}},{``create_timestamp_flt'':{``order'':``desc'',``unmapped_typ'':``float''}}",
"content_with_weight": " \"q_1024_vec\", \"q_1536_vec\", \"available_int\", \"content_with_weight\"])\r\n\r\n s = s.query(bqry)[pg * ps:(pg + 1) * ps]\r\n s = s.highlight(\"content_ltks\")\r\n s = s.highlight(\"title_ltks\")\r\n if not qst:\r\n if not req.get(\"sort\"):\r\n s = s.sort(\r\n {\"create_time\": {\"order\": \"desc\", \"unmapped_type\": \"date\"}},\r\n {\"create_timestamp_flt\": {\r\n \"order\": \"desc\", \"unmapped_type\": \"float\"}}\r\n",
"doc_id": "5c5999ec7be811ef9cab0242ac120005",
"kb_id": "c7ee74067a2c11efb21c0242ac120006",
"important_kwd": [],
"img_id": "",
"similarity": 0.6680254367045655,
"vector_similarity": 0.2651866742328425,
"term_similarity": 0.8406706206210184,
"positions": [
""
],
"doc_name": "1.txt"
},
{
"chunk_id": "f64ef0a681ed5be5e99855fb3f618487",
"content_ltks": " s=s.highlight_option (\r\nfragment_size=120 ,\r\n number_of_fragment=5 ,\r\n boundari_scanner_local=\" zh-cn\",\r\n boundari_scanner=\" sentenc\",\r\n boundari_char=\" , ./;:\\\\! () ,。?:!…… ()——、\"\r\n) \r\n s=s.to_dict ()\r\n#补充向量查询的信息\r\n\r\nq_vec=[]\r\nif req.get (\" vector\"):\r\nassert emb_mdl ,\"no embed model select\"\r\ns[\" knn\"]=self._vector (\r\nqst , emb_mdl , req.get (\r\n\" similar\", 0.1) , topk) \r\n",
"content_with_weight": " s = s.highlight_options(\r\n fragment_size=120,\r\n number_of_fragments=5,\r\n boundary_scanner_locale=\"zh-CN\",\r\n boundary_scanner=\"SENTENCE\",\r\n boundary_chars=\",./;:\\\\!(),。?:!……()——、\"\r\n )\r\n s = s.to_dict()\r\n # 补充向量查询的信息\r\n\r\n q_vec = []\r\n if req.get(\"vector\"):\r\n assert emb_mdl, \"No embedding model selected\"\r\n s[\"knn\"] = self._vector(\r\n qst, emb_mdl, req.get(\r\n \"similarity\", 0.1), topk)\r\n",
"doc_id": "5c5999ec7be811ef9cab0242ac120005",
"kb_id": "c7ee74067a2c11efb21c0242ac120006",
"important_kwd": [],
"img_id": "",
"similarity": 0.6542140532470838,
"vector_similarity": 0.27881693313841094,
"term_similarity": 0.815098533293658,
"positions": [
""
],
"doc_name": "1.txt"
},
{
"chunk_id": "43260c65ddbf92d85b11727d900d53c2",
"content_ltks": " r\"^[0-9]{ 1 , 2}of[0-9]{ 1 , 2}$\",\"^ http://[^]{12 ,}\" ,\r\n\"(资料|数据)来源[::]\" ,\"[ 0-9 a-z._-]+@[ a-z 0-9-]+\\\\.[a-z]{ 2 , 3}\" ,\r\n\"\\\\( cid*:*[ 0-9]+*\\\\)\"\r\n]\r\n return ani ([ re.search (p , b[\" text\"]) forp in patt])\r\n 1\r\n 2\r\n 3\r\n 4\r\n 5\r\n 6\r\n 7\r\n文档中版权内容,参考来源信息等内容会被清理。 ",
"content_with_weight": " r\"^[0-9]{1,2} of [0-9]{1,2}$\", \"^http://[^ ]{12,}\",\r\n \"(资料|数据)来源[::]\", \"[0-9a-z._-]+@[a-z0-9-]+\\\\.[a-z]{2,3}\",\r\n \"\\\\(cid *: *[0-9]+ *\\\\)\"\r\n ]\r\n return any([re.search(p, b[\"text\"]) for p in patt])\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n文档中版权内容,参考来源信息等内容会被清理。",
"doc_id": "5c5999ec7be811ef9cab0242ac120005",
"kb_id": "c7ee74067a2c11efb21c0242ac120006",
"important_kwd": [],
"img_id": "",
"similarity": 0.6490023706257155,
"vector_similarity": 0.33193716775238924,
"term_similarity": 0.7848874575714269,
"positions": [
""
],
"doc_name": "1.txt"
},
{
"chunk_id": "d65b767a9684090991d72c6c6e27ce68",
"content_ltks": " bqri=add_filter (bqri) \r\n bqry.boost=0.05\r\n\r\n#构造elasticsearch文本查询的请求\r\n\r\ns=search ()\r\n pg=int (req.get (\" page\", 1) )-1\r\n p=int (req.get (\" size\", 1000) )\r\n topk=int (req.get (\" topk\", 1024) )\r\n src=req.get (\" field\",[\" docnm_kwd\",\"content_ltk\",\"kb_id\",\"img_id\",\"titl_tk\",\"import_kwd\",\r\n\"imag_id\",\"doc_id\",\"q_512_vec\",\"q_768_vec\",\"posit_int\",\r\n",
"content_with_weight": " bqry = add_filters(bqry)\r\n bqry.boost = 0.05\r\n\r\n # 构造 ElasticSearch 文本查询的请求\r\n\r\n s = Search()\r\n pg = int(req.get(\"page\", 1)) - 1\r\n ps = int(req.get(\"size\", 1000))\r\n topk = int(req.get(\"topk\", 1024))\r\n src = req.get(\"fields\", [\"docnm_kwd\", \"content_ltks\", \"kb_id\", \"img_id\", \"title_tks\", \"important_kwd\",\r\n \"image_id\", \"doc_id\", \"q_512_vec\", \"q_768_vec\", \"position_int\",\r\n",
"doc_id": "5c5999ec7be811ef9cab0242ac120005",
"kb_id": "c7ee74067a2c11efb21c0242ac120006",
"important_kwd": [],
"img_id": "",
"similarity": 0.6438075500075432,
"vector_similarity": 0.2827550369535943,
"term_similarity": 0.7985443413163785,
"positions": [
""
],
"doc_name": "1.txt"
},
{
"chunk_id": "fe847155be74a1a86659fc2125c1402e",
"content_ltks": " s[\" knn\"][\" filter\"]=bqry.to_dict ()\r\n if\"highlight\"ins:\r\ndels[\" highlight\"]\r\n q_vec=s[\" knn\"][\" queri_vector\"]\r\n\r\n#将构造的完整查询提交给 elasticsearch进行查询\r\n\r\nre=self.es.search (deepcopi (s) , idxnm=idxnm , timeout=\" 600 s\", src=src) \r\n\r\n kwd=set ([])\r\n forkin keyword:\r\nkwds.add (k) \r\n for kk in rag_tokenizer.fine_grain_token (k) . split (\"\"):\r\nif len (kk) <2:\r\n",
"content_with_weight": " s[\"knn\"][\"filter\"] = bqry.to_dict()\r\n if \"highlight\" in s:\r\n del s[\"highlight\"]\r\n q_vec = s[\"knn\"][\"query_vector\"]\r\n\r\n # 将构造的完整查询提交给 ElasticSearch 进行查询\r\n\r\n res = self.es.search(deepcopy(s), idxnm=idxnm, timeout=\"600s\", src=src)\r\n\r\n kwds = set([])\r\n for k in keywords:\r\n kwds.add(k)\r\n for kk in rag_tokenizer.fine_grained_tokenize(k).split(\" \"):\r\n if len(kk) < 2:\r\n",
"doc_id": "5c5999ec7be811ef9cab0242ac120005",
"kb_id": "c7ee74067a2c11efb21c0242ac120006",
"important_kwd": [],
"img_id": "",
"similarity": 0.6421252968705483,
"vector_similarity": 0.2839901901180077,
"term_similarity": 0.7956117711930659,
"positions": [
""
],
"doc_name": "1.txt"
}
],
"doc_aggs": [
{
"doc_name": "1.txt",
"doc_id": "5c5999ec7be811ef9cab0242ac120005",
"count": 8
}
]
},
"prompt": "你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史。\n 以下是知识库:\n \r\n \r\n原文链接:https://blog.csdn.net/hustyichi/article/details/139162109\n------\n )\r\n else:\r\n s = s.sort(\r\n {\"page_num_int\": {\"order\": \"asc\", \"unmapped_type\": \"float\",\r\n \"mode\": \"avg\", \"numeric_type\": \"double\"}},\r\n {\"top_int\": {\"order\": \"asc\", \"unmapped_type\": \"float\",\r\n \"mode\": \"avg\", \"numeric_type\": \"double\"}},\r\n {\"create_time\": {\"order\": \"desc\", \"unmapped_type\": \"date\"}},\r\n {\"create_timestamp_flt\": {\r\n \"order\": \"desc\", \"unmapped_type\": \"float\"}}\r\n )\r\n\r\n if qst:\r\n\n------\n if not ins_embd:\r\n return [], [], []\r\n\r\n for i in sres.ids:\r\n if isinstance(sres.field[i].get(\"important_kwd\", []), str):\r\n sres.field[i][\"important_kwd\"] = [sres.field[i][\"important_kwd\"]]\r\n ins_tw = []\r\n for i in sres.ids:\r\n content_ltks = sres.field[i][cfield].split(\" \")\r\n title_tks = [t for t in sres.field[i].get(\"title_tks\", \"\").split(\" \") if t]\r\n important_kwd = sres.field[i].get(\"important_kwd\", [])\r\n\n------\n \"q_1024_vec\", \"q_1536_vec\", \"available_int\", \"content_with_weight\"])\r\n\r\n s = s.query(bqry)[pg * ps:(pg + 1) * ps]\r\n s = s.highlight(\"content_ltks\")\r\n s = s.highlight(\"title_ltks\")\r\n if not qst:\r\n if not req.get(\"sort\"):\r\n s = s.sort(\r\n {\"create_time\": {\"order\": \"desc\", \"unmapped_type\": \"date\"}},\r\n {\"create_timestamp_flt\": {\r\n \"order\": \"desc\", \"unmapped_type\": \"float\"}}\r\n\n------\n s = s.highlight_options(\r\n fragment_size=120,\r\n number_of_fragments=5,\r\n boundary_scanner_locale=\"zh-CN\",\r\n boundary_scanner=\"SENTENCE\",\r\n boundary_chars=\",./;:\\\\!(),。?:!……()——、\"\r\n )\r\n s = s.to_dict()\r\n # 补充向量查询的信息\r\n\r\n q_vec = []\r\n if req.get(\"vector\"):\r\n assert emb_mdl, \"No embedding model selected\"\r\n s[\"knn\"] = self._vector(\r\n qst, emb_mdl, req.get(\r\n \"similarity\", 0.1), topk)\r\n\n------\n r\"^[0-9]{1,2} of [0-9]{1,2}$\", \"^http://[^ ]{12,}\",\r\n \"(资料|数据)来源[::]\", \"[0-9a-z._-]+@[a-z0-9-]+\\\\.[a-z]{2,3}\",\r\n \"\\\\(cid *: *[0-9]+ *\\\\)\"\r\n ]\r\n return any([re.search(p, b[\"text\"]) for p in patt])\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n文档中版权内容,参考来源信息等内容会被清理。\n------\n bqry = add_filters(bqry)\r\n bqry.boost = 0.05\r\n\r\n # 构造 ElasticSearch 文本查询的请求\r\n\r\n s = Search()\r\n pg = int(req.get(\"page\", 1)) - 1\r\n ps = int(req.get(\"size\", 1000))\r\n topk = int(req.get(\"topk\", 1024))\r\n src = req.get(\"fields\", [\"docnm_kwd\", \"content_ltks\", \"kb_id\", \"img_id\", \"title_tks\", \"important_kwd\",\r\n \"image_id\", \"doc_id\", \"q_512_vec\", \"q_768_vec\", \"position_int\",\r\n\n------\n s[\"knn\"][\"filter\"] = bqry.to_dict()\r\n if \"highlight\" in s:\r\n del s[\"highlight\"]\r\n q_vec = s[\"knn\"][\"query_vector\"]\r\n\r\n # 将构造的完整查询提交给 ElasticSearch 进行查询\r\n\r\n res = self.es.search(deepcopy(s), idxnm=idxnm, timeout=\"600s\", src=src)\r\n\r\n kwds = set([])\r\n for k in keywords:\r\n kwds.add(k)\r\n for kk in rag_tokenizer.fine_grained_tokenize(k).split(\" \"):\r\n if len(kk) < 2:\r\n\n 以上是知识库。\n### Elapsed\n - Retrieval: 1261.1 ms\n - LLM: 11008.6 ms",
"id": "ba7559e87c8911ef9b970242ac120006"
}
}