Skip to main content

agentchat.contrib.graph_rag.falkor_graph_query_engine

FalkorGraphQueryEngine

class FalkorGraphQueryEngine()

This is a wrapper for Falkor DB KnowledgeGraph.

__init__

def __init__(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)

Initialize a Falkor DB knowledge graph. Please also refer to https://github.com/FalkorDB/GraphRAG-SDK/blob/main/graphrag_sdk/kg.py

Arguments:

  • name str - Knowledge graph name.
  • host str - FalkorDB hostname.
  • port int - FalkorDB port number.
  • username str|None - FalkorDB username.
  • password str|None - FalkorDB password.
  • model str - OpenAI model to use for Falkor DB to build and retrieve from the graph.
  • schema - Falkor DB knowledge graph schema (ontology), https://github.com/FalkorDB/GraphRAG-SDK/blob/main/graphrag_sdk/schema/schema.py If None, Falkor DB will auto generate a schema from the input docs.

init_db

def init_db(input_doc: List[Document] | None)

Build the knowledge graph with input documents.

query

def query(question: str,
n_results: int = 1,
**kwargs) -> FalkorGraphQueryResult

Query the knowledage graph with a question and optional message history.

Arguments:

  • question - a human input question.

  • n_results - number of returned results. kwargs:

  • messages - a list of message history.

  • Returns - FalkorGraphQueryResult