This commit is contained in:
Octopus 2026-05-28 17:41:08 -04:00 committed by GitHub
commit 6c1fee1606
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 4 deletions

View File

@ -233,6 +233,11 @@ class GraphBuilderService:
annotations = {}
for attr_def in entity_def.get("attributes", []):
# LLM may return attributes as strings instead of dicts
if isinstance(attr_def, str):
attr_name = safe_attr_name(attr_def)
attr_desc = attr_def
else:
attr_name = safe_attr_name(attr_def["name"]) # 使用安全名称
attr_desc = attr_def.get("description", attr_name)
# Zep API 需要 Field 的 description这是必需的
@ -257,6 +262,11 @@ class GraphBuilderService:
annotations = {}
for attr_def in edge_def.get("attributes", []):
# LLM may return attributes as strings instead of dicts
if isinstance(attr_def, str):
attr_name = safe_attr_name(attr_def)
attr_desc = attr_def
else:
attr_name = safe_attr_name(attr_def["name"]) # 使用安全名称
attr_desc = attr_def.get("description", attr_name)
# Zep API 需要 Field 的 description这是必需的

View File

@ -298,6 +298,11 @@ class OntologyGenerator:
entity_name_map[original_name] = entity["name"]
if "attributes" not in entity:
entity["attributes"] = []
# Normalize attributes: LLM may return strings instead of dicts
entity["attributes"] = [
attr if isinstance(attr, dict) else {"name": attr, "type": "text", "description": attr}
for attr in entity["attributes"]
]
if "examples" not in entity:
entity["examples"] = []
# 确保description不超过100字符
@ -322,6 +327,11 @@ class OntologyGenerator:
edge["source_targets"] = []
if "attributes" not in edge:
edge["attributes"] = []
# Normalize attributes: LLM may return strings instead of dicts
edge["attributes"] = [
attr if isinstance(attr, dict) else {"name": attr, "type": "text", "description": attr}
for attr in edge["attributes"]
]
if len(edge.get("description", "")) > 100:
edge["description"] = edge["description"][:97] + "..."