graphrag_sdk package
Subpackages
- graphrag_sdk.schema package
- Submodules
- graphrag_sdk.schema.auto_detect module
- graphrag_sdk.schema.decoder module
- graphrag_sdk.schema.encoder module
- graphrag_sdk.schema.entity module
- graphrag_sdk.schema.from_graph module
- graphrag_sdk.schema.functions_gen module
- graphrag_sdk.schema.relation module
- graphrag_sdk.schema.schema module
- graphrag_sdk.schema.to_graph module
- graphrag_sdk.schema.tools_gen module
- Module contents
Submodules
graphrag_sdk.kg module
- class graphrag_sdk.kg.KnowledgeGraph(name: str, host: str = '127.0.0.1', port: int = 6379, username: str | None = None, password: str | None = None, model: str = 'gpt-4-1106-preview', schema: Schema | None = None)[source]
Bases:
objectKnowledge Graph model data as a network of entities and relations To create one it is best to provide a schema which will define the graph’s ontology In addition to a set of sources from which entities and relations will be extracted.
- ask(question: str, history: list | None = None) tuple[str, list][source]
Query the knowledge graph using natural language if the query is asked as part of a longer conversation make sure to include past history.
- Rreturns:
tuple[str, list]: answer, conversation history
- Example:
>>> ans, history = kg.ask("Which actor has the most oscars") >>> ans, history = kg.ask("List a few movies in which that actored played in", history)
- list_sources() list[AbstractSource][source]
List of sources associated with knowledge graph
- Returns:
list[AbstractSource]: sources
- process_sources(sources: list[AbstractSource]) None[source]
Add entities and relations found in sources into the knowledge-graph
- Parameters:
sources (list[AbstractSource]): list of sources to extract knowledge from
graphrag_sdk.prompts module
graphrag_sdk.query_graph module
graphrag_sdk.source module
- class graphrag_sdk.source.AbstractSource(source: str)[source]
Bases:
ABCAbstract class representing a source file
- class graphrag_sdk.source.HTML(source)[source]
Bases:
AbstractSourceHTML resource
- class graphrag_sdk.source.PDF(source)[source]
Bases:
AbstractSourcePDF resource
- graphrag_sdk.source.Source(source: str) AbstractSource[source]
Creates a source object
- Parameters:
source (str): path to source
- Returns:
AbstractSource: source
- class graphrag_sdk.source.TEXT(source)[source]
Bases:
AbstractSourceTEXT resource