Toggle navigation
Toggle navigation
This project
Loading...
Sign in
万朱浩
/
Venue-Ops
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
马一丁
2025-12-20 14:16:35 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9696eefd23931e083a1c3496781cadd739917f62
9696eefd
1 parent
26084a09
Normalize keyword type before matching
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
ReportEngine/graphrag/query_engine.py
ReportEngine/nodes/graphrag_query_node.py
ReportEngine/graphrag/query_engine.py
View file @
9696eef
...
...
@@ -136,6 +136,13 @@ class QueryEngine:
def
_matches_keywords
(
self
,
node
:
Node
,
keywords
:
List
[
str
])
->
bool
:
"""检查节点是否匹配关键词"""
# 防御性检查:确保 keywords 为列表类型
# 若传入字符串,逐字符迭代会导致单字符匹配(如 'a', 'e'),污染结果
if
isinstance
(
keywords
,
str
):
keywords
=
[
k
.
strip
()
for
k
in
keywords
.
replace
(
','
,
' '
)
.
split
()
if
k
.
strip
()]
elif
not
isinstance
(
keywords
,
list
):
keywords
=
[]
if
not
keywords
:
# 无关键词时:只匹配 section 类型(避免返回整个图谱)
# 这样至少能获取到各引擎的段落摘要
...
...
ReportEngine/nodes/graphrag_query_node.py
View file @
9696eef
...
...
@@ -151,8 +151,16 @@ class GraphRAGQueryNode(BaseNode):
break
# 4. 执行查询:按 LLM 给出的参数查询本地图谱
# 规范化 keywords:确保为列表类型(LLM 可能返回字符串)
raw_keywords
=
decision
.
get
(
'keywords'
,
[])
if
isinstance
(
raw_keywords
,
str
):
# 按空格和逗号分割字符串为关键词列表
raw_keywords
=
[
k
.
strip
()
for
k
in
raw_keywords
.
replace
(
','
,
' '
)
.
split
()
if
k
.
strip
()]
elif
not
isinstance
(
raw_keywords
,
list
):
raw_keywords
=
[]
params
=
QueryParams
(
keywords
=
decision
.
get
(
'keywords'
,
[])
,
keywords
=
raw_keywords
,
node_types
=
decision
.
get
(
'node_types'
),
engine_filter
=
decision
.
get
(
'engine_filter'
),
depth
=
decision
.
get
(
'depth'
,
1
)
...
...
Please
register
or
login
to post a comment