> ## Documentation Index
> Fetch the complete documentation index at: https://private-04b27de1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.agentchat.contrib.graph_rag.falkor_graph_query_engine.FalkorGraphQueryEngine

<h2 id="autogen.agentchat.contrib.graph_rag.falkor_graph_query_engine.FalkorGraphQueryEngine" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">FalkorGraphQueryEngine</span>
</h2>

```python theme={null}
FalkorGraphQueryEngine(
    name: str,
    host: str = '127.0.0.1',
    port: int = 6379,
    username: str | None = None,
    password: str | None = None,
    model: ForwardRef('GenerativeModel') | None = None,
    ontology: ForwardRef('Ontology') | None = None
)
```

This is a wrapper for FalkorDB KnowledgeGraph.<br />Initialize a FalkorDB knowledge graph.<br />Please also refer to [https://github.com/FalkorDB/GraphRAG-SDK/blob/main/graphrag\_sdk/kg.py](https://github.com/FalkorDB/GraphRAG-SDK/blob/main/graphrag_sdk/kg.py)

TODO: Fix LLM API cost calculation for FalkorDB usages.<br />

<b>Parameters:</b>

| Name       | Description                                                                  |
| ---------- | ---------------------------------------------------------------------------- |
| `name`     | **Type:** str                                                                |
| `host`     | **Type:** str<br /><br />**Default:** '127.0.0.1'                            |
| `port`     | **Type:** int<br /><br />**Default:** 6379                                   |
| `username` | **Type:** str \| None<br /><br />**Default:** None                           |
| `password` | **Type:** str \| None<br /><br />**Default:** None                           |
| `model`    | **Type:** ForwardRef('GenerativeModel') \| None<br /><br />**Default:** None |
| `ontology` | **Type:** ForwardRef('Ontology') \| None<br /><br />**Default:** None        |

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### add\_records

```python theme={null}
add_records(self, new_records: list[Document]) -> bool
```

<b>Parameters:</b>

| Name          | Description                                                                                            |
| ------------- | ------------------------------------------------------------------------------------------------------ |
| `new_records` | **Type:** list\[[Document](/docs/api-reference/autogen/agentchat/contrib/graph_rag/document/Document)] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### connect\_db

```python theme={null}
connect_db(self) -> None
```

Connect to an existing knowledge graph.

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### delete

```python theme={null}
delete(self) -> bool
```

Delete graph and its data from database.

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### init\_db

```python theme={null}
init_db(self, input_doc: list[Document]) -> None
```

Build the knowledge graph with input documents.

<b>Parameters:</b>

| Name        | Description                                                                                            |
| ----------- | ------------------------------------------------------------------------------------------------------ |
| `input_doc` | **Type:** list\[[Document](/docs/api-reference/autogen/agentchat/contrib/graph_rag/document/Document)] |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### query

```python theme={null}
query(
    self,
    question: str,
    n_results: int = 1,
    **kwargs: Any
) -> GraphStoreQueryResult
```

Query the knowledge graph with a question and optional message history.<br />

<b>Parameters:</b>

| Name        | Description                                                                    |
| ----------- | ------------------------------------------------------------------------------ |
| `question`  | a human input question.<br /><br />**Type:** str                               |
| `n_results` | number of returned results.<br /><br />**Type:** int<br /><br />**Default:** 1 |
| `**kwargs`  | **Type:** Any                                                                  |

<b>Returns:</b>

| Type                                                                                                                      | Description            |
| ------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
| [GraphStoreQueryResult](/docs/api-reference/autogen/agentchat/contrib/graph_rag/graph_query_engine/GraphStoreQueryResult) | FalkorGraphQueryResult |

<br />
