Node Distance Reranker: Limit max hops (and cleanup prints) (#72)
* limit SHORTEST max hops * cleanup prints
This commit is contained in:
parent
79a63cc366
commit
fe20c0f51d
3 changed files with 1 additions and 3 deletions
|
|
@ -60,6 +60,5 @@ class OpenAIClient(LLMClient):
|
||||||
result = response.choices[0].message.content or ''
|
result = response.choices[0].message.content or ''
|
||||||
return json.loads(result)
|
return json.loads(result)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(openai_messages)
|
|
||||||
logger.error(f'Error in generating LLM response: {e}')
|
logger.error(f'Error in generating LLM response: {e}')
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
|
|
@ -424,7 +424,7 @@ async def node_distance_reranker(
|
||||||
records, _, _ = await driver.execute_query(
|
records, _, _ = await driver.execute_query(
|
||||||
"""
|
"""
|
||||||
MATCH (source:Entity)-[r:RELATES_TO {uuid: $edge_uuid}]->(target:Entity)
|
MATCH (source:Entity)-[r:RELATES_TO {uuid: $edge_uuid}]->(target:Entity)
|
||||||
MATCH p = SHORTEST 1 (center:Entity)-[:RELATES_TO]-+(n:Entity)
|
MATCH p = SHORTEST 1 (center:Entity)-[:RELATES_TO*1..10]->(n:Entity)
|
||||||
WHERE center.uuid = $center_uuid AND n.uuid IN [source.uuid, target.uuid]
|
WHERE center.uuid = $center_uuid AND n.uuid IN [source.uuid, target.uuid]
|
||||||
RETURN min(length(p)) AS score, source.uuid AS source_uuid, target.uuid AS target_uuid
|
RETURN min(length(p)) AS score, source.uuid AS source_uuid, target.uuid AS target_uuid
|
||||||
""",
|
""",
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,6 @@ async def extract_edges(
|
||||||
}
|
}
|
||||||
|
|
||||||
llm_response = await llm_client.generate_response(prompt_library.extract_edges.v2(context))
|
llm_response = await llm_client.generate_response(prompt_library.extract_edges.v2(context))
|
||||||
print(llm_response)
|
|
||||||
edges_data = llm_response.get('edges', [])
|
edges_data = llm_response.get('edges', [])
|
||||||
|
|
||||||
end = time()
|
end = time()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue