fix: extract entities tool_calls some times is an array (#2481)

This commit is contained in:
Sergio Toro
2025-04-09 20:33:52 +02:00
committed by GitHub
parent 244e60cea6
commit 55df395fd6

View File

@@ -164,7 +164,10 @@ class MemoryGraph:
entity_type_map = {}
try:
for item in search_results["tool_calls"][0]["arguments"]["entities"]:
for tool_call in search_results["tool_calls"]:
if tool_call['name'] != "extract_entities":
continue
for item in tool_call["arguments"]["entities"]:
entity_type_map[item["entity"]] = item["entity_type"]
except Exception as e:
logger.exception(
@@ -172,7 +175,7 @@ class MemoryGraph:
)
entity_type_map = {k.lower().replace(" ", "_"): v.lower().replace(" ", "_") for k, v in entity_type_map.items()}
logger.debug(f"Entity type map: {entity_type_map}")
logger.debug(f"Entity type map: {entity_type_map}\n search_results={search_results}")
return entity_type_map
def _establish_nodes_relations_from_data(self, data, filters, entity_type_map):