Merge fe8949ca1c into 96096ea0ff
This commit is contained in:
commit
6c1fee1606
|
|
@ -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,这是必需的
|
||||
|
|
|
|||
|
|
@ -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] + "..."
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue