Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions pipeline/modules/search/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,14 +660,18 @@ def _correct_rerank_line(

def _parse_rerank_response(
self,
useful_relations: List[str],
useful_relations: List[Any],
valid_ids: set,
relation_ids: List[str],
relation_texts: List[str],
) -> List[str]:
"""解析 LLM 返回的 useful_relations,提取 [id] 并纠错"""
"""解析 LLM 返回的 useful_relations,提取纯数字或 [id] 并纠错"""
selected: List[str] = []
for line in useful_relations:
line = str(line).strip()
if line in valid_ids and line not in selected:
selected.append(line)
continue
if "[" not in line or "]" not in line:
continue
rel_id = line[line.find("[") + 1: line.find("]")].strip()
Expand Down Expand Up @@ -749,7 +753,12 @@ async def step7_llm_rerank(
"thought_process": {"type": "string"},
"useful_relations": {
"type": "array",
"items": {"type": "string"},
"items": {
"anyOf": [
{"type": "string"},
{"type": "integer"},
],
},
},
},
"required": ["thought_process", "useful_relations"],
Expand Down
16 changes: 12 additions & 4 deletions pipeline/modules/search/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,18 @@ def _correct_rerank_line(

def _parse_rerank_response(
self,
useful_relations: List[str],
useful_relations: List[Any],
valid_ids: set,
relation_ids: List[str],
relation_texts: List[str],
) -> List[str]:
"""解析 LLM 返回的 useful_relations,提取 [id] 并纠错"""
"""解析 LLM 返回的 useful_relations,提取纯数字或 [id] 并纠错"""
selected: List[str] = []
for line in useful_relations:
line = str(line)
line = str(line).strip()
if line in valid_ids and line not in selected:
selected.append(line)
continue
if "[" not in line or "]" not in line:
continue
rel_id = line[line.find("[") + 1: line.find("]")].strip()
Expand Down Expand Up @@ -672,7 +675,12 @@ async def step7_llm_rerank(
"thought_process": {"type": "string"},
"useful_relations": {
"type": "array",
"items": {"type": "string"},
"items": {
"anyOf": [
{"type": "string"},
{"type": "integer"},
],
},
},
},
"required": ["thought_process", "useful_relations"],
Expand Down
Loading