Merge remote-tracking branch 'origin/main' into agent-update
This commit is contained in:
parent
f3707c34bc
commit
42384236f8
35
.github/ISSUE_TEMPLATE/提交一个bug.md
vendored
Normal file
35
.github/ISSUE_TEMPLATE/提交一个bug.md
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
name: 提交一个BUG
|
||||||
|
about: 提交一个 BUG
|
||||||
|
title: "[BUG]"
|
||||||
|
labels: bug
|
||||||
|
assignees: xerrors
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 描述这个 bug
|
||||||
|
|
||||||
|
简单描述一下这个 BUG:
|
||||||
|
|
||||||
|
### 如何复现
|
||||||
|
|
||||||
|
什么情况下出现:
|
||||||
|
|
||||||
|
### 相关信息
|
||||||
|
|
||||||
|
**1)检查 `docker logs`**
|
||||||
|
|
||||||
|
请运行以下命令,并提供部分相关日志:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker logs --tail=100 api-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
如果问题与模型调用相关,请尝试切换到其他在线模型
|
||||||
|
|
||||||
|
**2)相关截图**
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**3)其他相关信息**
|
||||||
@ -61,6 +61,7 @@ services:
|
|||||||
- NEO4J_AUTH=neo4j/0123456789
|
- NEO4J_AUTH=neo4j/0123456789
|
||||||
- NEO4J_server_bolt_listen__address=0.0.0.0:7687
|
- NEO4J_server_bolt_listen__address=0.0.0.0:7687
|
||||||
- NEO4J_server_http_listen__address=0.0.0.0:7474
|
- NEO4J_server_http_listen__address=0.0.0.0:7474
|
||||||
|
- ENTITY_EMBEDDING=true
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
|
|
||||||
|
|||||||
@ -218,7 +218,19 @@ class GraphDatabase:
|
|||||||
|
|
||||||
def query_by_vector(self, entity_name, threshold=0.9, kgdb_name='neo4j', hops=2, num_of_res=5):
|
def query_by_vector(self, entity_name, threshold=0.9, kgdb_name='neo4j', hops=2, num_of_res=5):
|
||||||
self.use_database(kgdb_name)
|
self.use_database(kgdb_name)
|
||||||
|
def _index_exists(tx, index_name):
|
||||||
|
"""检查索引是否存在"""
|
||||||
|
result = tx.run("SHOW INDEXES")
|
||||||
|
for record in result:
|
||||||
|
if record["name"] == index_name:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def query(tx, text):
|
def query(tx, text):
|
||||||
|
# 首先检查索引是否存在
|
||||||
|
if not _index_exists(tx, "entityEmbeddings"):
|
||||||
|
raise Exception("向量索引不存在,请先创建索引")
|
||||||
|
|
||||||
embedding = self.get_embedding(text)
|
embedding = self.get_embedding(text)
|
||||||
result = tx.run("""
|
result = tx.run("""
|
||||||
CALL db.index.vector.queryNodes('entityEmbeddings', 10, $embedding)
|
CALL db.index.vector.queryNodes('entityEmbeddings', 10, $embedding)
|
||||||
@ -227,9 +239,14 @@ class GraphDatabase:
|
|||||||
""", embedding=embedding)
|
""", embedding=embedding)
|
||||||
return result.values()
|
return result.values()
|
||||||
|
|
||||||
|
try:
|
||||||
with self.driver.session() as session:
|
with self.driver.session() as session:
|
||||||
results = session.execute_read(query, entity_name)
|
results = session.execute_read(query, entity_name)
|
||||||
|
except Exception as e:
|
||||||
|
if "向量索引不存在" in str(e):
|
||||||
|
logger.error(f"向量索引不存在,请先创建索引: {e}, {traceback.format_exc()}")
|
||||||
|
return []
|
||||||
|
raise e
|
||||||
|
|
||||||
# 筛选出分数高于阈值的实体
|
# 筛选出分数高于阈值的实体
|
||||||
qualified_entities = [result[0] for result in results[:num_of_res] if result[1] > threshold]
|
qualified_entities = [result[0] for result in results[:num_of_res] if result[1] > threshold]
|
||||||
|
|||||||
@ -76,6 +76,8 @@ class Retriever:
|
|||||||
results = []
|
results = []
|
||||||
if refs["meta"].get("use_graph") and config.enable_knowledge_base:
|
if refs["meta"].get("use_graph") and config.enable_knowledge_base:
|
||||||
for entity in refs["entities"]:
|
for entity in refs["entities"]:
|
||||||
|
if entity == "":
|
||||||
|
continue
|
||||||
result = graph_base.query_by_vector(entity)
|
result = graph_base.query_by_vector(entity)
|
||||||
if result != []:
|
if result != []:
|
||||||
results.extend(result)
|
results.extend(result)
|
||||||
|
|||||||
@ -434,7 +434,7 @@ const fetchChatResponse = (user_input, cur_res_id) => {
|
|||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
query: user_input,
|
query: user_input,
|
||||||
history: getHistory(),
|
history: getHistory().slice(0, -1), // 去掉最后一条刚添加的用户消息,
|
||||||
meta: meta,
|
meta: meta,
|
||||||
cur_res_id: cur_res_id,
|
cur_res_id: cur_res_id,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user