graphrag_sdk.schema package
Submodules
graphrag_sdk.schema.auto_detect module
- graphrag_sdk.schema.auto_detect.convert_table(s, client, model, tbl, columns, foreign_keys)[source]
- graphrag_sdk.schema.auto_detect.create_entity_with_relation(s, client, model, name: str, columns, foreign_keys) None[source]
graphrag_sdk.schema.decoder module
graphrag_sdk.schema.encoder module
graphrag_sdk.schema.entity module
- class graphrag_sdk.schema.entity.Attribute(name: str, type: type, desc=None, unique=False, mandatory=False)[source]
Bases:
object
- class graphrag_sdk.schema.entity.Entity(name: str)[source]
Bases:
objectRepresents an ontolegy entity
- add_attribute(name: str, type: type, desc: str | None = None, unique: bool = False, mandatory: bool = False) Entity[source]
Add attribute to entity
- Parameters:
name (str): attribute name type (type): attribute type desc (str): short description for attribute unique (bool): is the attribute value unique mandatory (bool): is the attribute mandatory
- Returns:
Entity
- get_attribute(name: str) Attribute | None[source]
Get attribute
- Parameters:
name (str): name of attribute to get
- Returns:
attribute
graphrag_sdk.schema.from_graph module
graphrag_sdk.schema.functions_gen module
graphrag_sdk.schema.relation module
graphrag_sdk.schema.schema module
- class graphrag_sdk.schema.schema.Schema[source]
Bases:
objectKnowledge Graph schema (ontology) The schema captures entities types in addition to their attributes and the relationship types between the them
- add_entity(name: str) Entity[source]
Add a new entity to schema
- Parameters:
name (str): Entity name.
- Returns:
entity
- add_relation(name: str, src: Entity, dest: Entity) Relation[source]
Add a relationship to schema
- Returns:
relation
- classmethod auto_detect(sources: list[AbstractSource], model='gpt-3.5-turbo-0125') Schema[source]
Auto detect schema from sources
- Parameters:
sources (list[AbstractSource]): list of sources to extract schema from model (str): OpenAI model to use
- Returns:
Schema: schema
- classmethod from_JSON(json: str) Schema[source]
Create a schema from JSON
- Parameters:
json (str): the output from to_JSON
- Returns:
Schema: schema
- classmethod from_graph(g: Graph) Schema[source]
Create a schema from an ontology graph
- Parameters:
g (Graph): ontology graph to load
- Returns:
Schema: schema