> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ag2.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.agents.experimental.InMemoryQueryEngine

<h2 id="autogen.agents.experimental.InMemoryQueryEngine" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

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

```python theme={null}
InMemoryQueryEngine(llm_config: LLMConfig | dict[str, Any])
```

This engine stores ingested documents in memory and then injects them into an internal agent's system message for answering queries.<br />This implements the autogen.agentchat.contrib.rag.RAGQueryEngine protocol.

<b>Parameters:</b>

| Name         | Description                                                                                       |
| ------------ | ------------------------------------------------------------------------------------------------- |
| `llm_config` | **Type:** [LLMConfig](/docs/api-reference/autogen/llm_config/LLMConfig) \| dict\[str, typing.Any] |

### Instance Methods

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

#### add\_docs

```python theme={null}
add_docs(
    self,
    new_doc_dir: Path | str | None = None,
    new_doc_paths_or_urls: Sequence[Path | str] | None = None
) -> None
```

Add additional documents to the in-memory store

Loads new Docling-parsed Markdown files from a specified directory or a list of file paths
and inserts them into the in-memory store.<br />

<b>Parameters:</b>

| Name                    | Description                                                                                                                                                                                                           |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `new_doc_dir`           | The directory path from which to load additional documents.<br /><br />If provided, all eligible files in this directory are loaded.<br /><br />**Type:** pathlib.Path \| str \| None<br /><br />**Default:** None    |
| `new_doc_paths_or_urls` | A list of file paths specifying additional documents to load.<br /><br />Each file should be a Docling-parsed Markdown file.<br /><br />**Type:** Sequence\[pathlib.Path \| str] \| None<br /><br />**Default:** None |

<br />

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

#### connect\_db

```python theme={null}
connect_db(
    self,
    *args: Any,
    **kwargs: Any
) -> bool
```

Not required nor implemented for InMemoryQueryEngine

<b>Parameters:</b>

| Name       | Description   |
| ---------- | ------------- |
| `*args`    | **Type:** Any |
| `**kwargs` | **Type:** Any |

<br />

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

#### init\_db

```python theme={null}
init_db(
    self,
    new_doc_dir: Path | str | None = None,
    new_doc_paths_or_urls: Sequence[Path | str] | None = None,
    *args: Any,
    **kwargs: Any
) -> bool
```

Not required nor implemented for InMemoryQueryEngine

<b>Parameters:</b>

| Name                    | Description                                                                   |
| ----------------------- | ----------------------------------------------------------------------------- |
| `new_doc_dir`           | **Type:** pathlib.Path \| str \| None<br /><br />**Default:** None            |
| `new_doc_paths_or_urls` | **Type:** Sequence\[pathlib.Path \| str] \| None<br /><br />**Default:** None |
| `*args`                 | **Type:** Any                                                                 |
| `**kwargs`              | **Type:** Any                                                                 |

<br />

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

#### query

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

Run a query against the ingested documents and return the answer.

<b>Parameters:</b>

| Name       | Description   |
| ---------- | ------------- |
| `question` | **Type:** str |
| `*args`    | **Type:** Any |
| `**kwargs` | **Type:** Any |

<br />
