graphiti icon indicating copy to clipboard operation
graphiti copied to clipboard

Docs: Missing documentation about how to create and define `Edge`

Open BrodaNoel opened this issue 8 months ago • 3 comments

Hello eveyone!

I have this "entities" file:

from pydantic import BaseModel, Field

class Person(BaseModel):
    """Individual human person"""
    name: str | None = Field(..., description="First name of the person")
    lastname: str | None = Field(..., description="Last name of the person")
    id: str | None = Field(..., description="National Identity Document number")
    birthdate: str | None = Field(..., description="Date of birth")
    address: str | None = Field(..., description="Physical address")

class Actor(Person):
    """Party initiating the legal claim"""
    pass

class Testigo(Person):
    """Individual providing testimony about the facts"""
    pass

class TestigoHasSeenActor(BaseModel):
    source: Testigo
    target: Actor
    descripcion: str = Field(default="Testigo has seen the Actor")
    type: str = Field(default="has_seen")

# Entity type mapping for Graphiti
resolution_entity_types = {
    "Person": Person,
    "Actor": Actor,
    "Testigo": Testigo
}

Has you can see, there are 3 entities, and 1 Edge: TestigoHasSeenActor

There is documentation about how to add the 3 entities, which I use in this way:

                await graphiti.add_episode(
                    uuid=file_id,
                    name=file_type,
                    episode_body=text,
                    reference_time=datetime.now(timezone.utc),
                    source=EpisodeType.text,
                    source_description=f"Document from user {user_id}",
                    group_id=user_id,
                    entity_types=resolution_entity_types
                )

But there is no documentation about how to add the Edge

BrodaNoel avatar May 12 '25 22:05 BrodaNoel

Should I just add TestigoHasSeenActor in resolution_entity_types ?

BrodaNoel avatar May 12 '25 22:05 BrodaNoel

I'm willing to send a PR adding your answers in https://help.getzep.com/graphiti/graphiti

Thanks!

BrodaNoel avatar May 12 '25 22:05 BrodaNoel

We plan to add custom edge types. cc @prasmussen15

danielchalef avatar May 12 '25 23:05 danielchalef

@danielchalef I think this was implemented in the last version, right? Any documentation about it?

BrodaNoel avatar Jun 13 '25 22:06 BrodaNoel

I'm looking for the custom edge types as well. wondering if it's available now @danielchalef ?

taihoang-sourcy avatar Jun 16 '25 07:06 taihoang-sourcy

neo4j.exceptions.CypherTypeError: {code: Neo.ClientError.Statement.TypeError} {message: Property values can only be of primitive types or arrays thereof..`

I got the above when trying to use the edge_types

taihoang-sourcy avatar Jun 16 '25 09:06 taihoang-sourcy

@jackaldenryan Popping documenting Edge Types on your TODO list.

danielchalef avatar Jun 16 '25 19:06 danielchalef

Noted, on to do list

jackaldenryan avatar Jun 16 '25 21:06 jackaldenryan

@jackaldenryan Could you share a quick code snippet here to show how to use it? We'd really appreciate it!

taihoang-sourcy avatar Jun 17 '25 02:06 taihoang-sourcy

@jackaldenryan Yeah, would appreciate a short code snippet if the documentation is gonna take some time :)

andytan0051 avatar Jun 27 '25 09:06 andytan0051

Try this: https://help.getzep.com/graphiti/graphiti/custom-entity-and-edge-types

Let me know if there are any syntax errors in the provided code here

@andytan0051

jackaldenryan avatar Jun 28 '25 18:06 jackaldenryan