mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 15:45:58 +08:00
fix SILICONFLOW rerank error (#2980)
### What problem does this PR solve? #2977 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
91ea559f9e
commit
89d5b2414e
@ -320,9 +320,28 @@ def knowledge_graph():
|
|||||||
for id in sres.ids[:2]:
|
for id in sres.ids[:2]:
|
||||||
ty = sres.field[id]["knowledge_graph_kwd"]
|
ty = sres.field[id]["knowledge_graph_kwd"]
|
||||||
try:
|
try:
|
||||||
obj[ty] = json.loads(sres.field[id]["content_with_weight"])
|
content_json = json.loads(sres.field[id]["content_with_weight"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(traceback.format_exc(), flush=True)
|
continue
|
||||||
|
|
||||||
|
if ty == 'mind_map':
|
||||||
|
node_dict = {}
|
||||||
|
|
||||||
|
def repeat_deal(content_json, node_dict):
|
||||||
|
if 'id' in content_json:
|
||||||
|
if content_json['id'] in node_dict:
|
||||||
|
node_name = content_json['id']
|
||||||
|
content_json['id'] += f"({node_dict[content_json['id']]})"
|
||||||
|
node_dict[node_name] += 1
|
||||||
|
else:
|
||||||
|
node_dict[content_json['id']] = 1
|
||||||
|
if 'children' in content_json and content_json['children']:
|
||||||
|
for item in content_json['children']:
|
||||||
|
repeat_deal(item, node_dict)
|
||||||
|
|
||||||
|
repeat_deal(content_json, node_dict)
|
||||||
|
|
||||||
|
obj[ty] = content_json
|
||||||
|
|
||||||
return get_json_result(data=obj)
|
return get_json_result(data=obj)
|
||||||
|
|
||||||
|
@ -344,6 +344,9 @@ class SILICONFLOWRerank(Base):
|
|||||||
self.base_url, json=payload, headers=self.headers
|
self.base_url, json=payload, headers=self.headers
|
||||||
).json()
|
).json()
|
||||||
rank = np.zeros(len(texts), dtype=float)
|
rank = np.zeros(len(texts), dtype=float)
|
||||||
|
if "results" not in response:
|
||||||
|
return rank, 0
|
||||||
|
|
||||||
for d in response["results"]:
|
for d in response["results"]:
|
||||||
rank[d["index"]] = d["relevance_score"]
|
rank[d["index"]] = d["relevance_score"]
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user