graphiti icon indicating copy to clipboard operation
graphiti copied to clipboard

[BUG] neo4j 不支持提取出的嵌套关系

Open gs-max opened this issue 2 months ago • 1 comments

Bug Description

neo4j can't support map structure.The code is copied from the offical doucment mostly。

class Company(BaseModel):
    """A business organization."""
    industry: Optional[str] = Field(default=None, description="Primary industry")
    founded_year: Optional[int] = Field(default=None, description="Year company was founded")
    stock_code: Optional[str] = Field(default=None, description="Stock code")
class Investment(BaseModel):
    """Investment relationship between entities."""
    amount: Optional[float] = Field(default=None, description="Investment amount in USD")
    investment_type: Optional[str] = Field(default=None, description="Type of investment (equity, debt, etc.)")
    stake_percentage: Optional[float] = Field(default=None, description="Percentage ownership")
    investment_date: Optional[datetime] = Field(default=None, description="Date of investment")
class Partnership(BaseModel):
    """Partnership relationship between companies."""
    partnership_type: Optional[str] = Field(default=None, description="Type of partnership")
    duration: Optional[str] = Field(default=None, description="Expected duration")
    deal_value: Optional[float] = Field(default=None, description="Financial value of partnership")

entity_types = {
    "Company": Company,
}
edge_types = {
    "Investment": Investment,
    "Partnership": Partnership
}
edge_type_map = {
    ("Company", "Company"): ["Partnership", "Investment"],
}

await client.add_episode(
        name=f'Conversation {session_id}',
        episode_body=message,
        source_description='Customer Support Conversation',
        reference_time=datetime.now(timezone.utc),
        entity_types=entity_types,
        edge_types=edge_types,
        edge_type_map=edge_type_map
    )
    print(f"✅ 对话 {session_id} 已存入知识图谱", flush=True)

## Expected Behavior
    print(f"✅ 对话 {session_id} 已存入知识图谱", flush=True) execute successfully.

## Actual Behavior
⚠️ 存入知识图谱失败: {neo4j_code: Neo.ClientError.Statement.TypeError} {message: Property values can only be of primitive types or arrays thereof. Encountered: Map{industry -> Map{anyOf -> List{Map{type -> String("string")}, Map{type -> String("null")}}, description -> String("Primary industry"), default -> NO_VALUE, title -> String("Industry")}, stock_code -> Map{anyOf -> List{Map{type -> String("string")}, Map{type -> String("null")}}, description -> String("Stock code"), default -> NO_VALUE, title -> String("Stock Code")}, founded_year -> Map{anyOf -> List{Map{type -> String("integer")}, Map{type -> String("null")}}, description -> String("Year company was founded"), default -> NO_VALUE, title -> String("Founded Year")}}.} {gql_status: 22G03} {gql_status_description: error: data exception - invalid value type}

## Environment
- **Graphiti Version**: [0.22.0]
- **Python Version**: [e.g. 3.10.5]
- **Operating System**: [macOS 15.5]
- **Database Backend**: [Neo4j 5.26]

gs-max avatar Oct 18 '25 15:10 gs-max

@gs-max Is this still an issue? Please confirm within 14 days or this issue will be closed.

claude[bot] avatar Nov 17 '25 00:11 claude[bot]