> For the complete documentation index, see [llms.txt](https://docs.wisej.com/ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/ai/components/api/tools/wisej.ai.tools.documenttools.md).

# DocumentTools

Namespace: **Wisej.AI.Tools**

Assembly: **Wisej.AI** (3.5.0.0)

* [ToolsContainer](/ai/components/api/tools/wisej.ai.tools.toolscontainer.md)
  * [DocumentTools](/ai/components/api/tools/wisej.ai.tools.documenttools.md)

Provides tools for processing, embedding, and querying documents using AI services.

{% tabs %}
{% tab title="C#" %}

```csharp
public class DocumentTools : ToolsContainer
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class DocumentTools
    Inherits ToolsContainer
```

{% endtab %}
{% endtabs %}

The [DocumentTools](/ai/components/api/tools/wisej.ai.tools.documenttools.md) class enables document processing tasks such as:

* Embedding documents for similarity and summarization tasks.
* Querying documents based on semantic similarity.
* Summarizing document content using clustering techniques.\
  It integrates with various AI services, including tokenization, text splitting, document conversion, and embedding generation.

## Constructors

### ![](/files/ptrKjmmRoQB76pvrIqh0) DocumentTools()

Initializes a new instance of the [DocumentTools](/ai/components/api/tools/wisej.ai.tools.documenttools.md) class.

This constructor injects the required services into the [DocumentTools](/ai/components/api/tools/wisej.ai.tools.documenttools.md) instance using the application's service provider.

## Properties

### ![](/files/KL0Ik37djZRr8a07Wopd) ConversionService

[IDocumentConversionService](/ai/components/api/services/idocumentconversionservice.md): Gets or sets the document conversion service used for converting documents to text.

### ![](/files/KL0Ik37djZRr8a07Wopd) EmbeddingGenerationService

[IEmbeddingGenerationService](/ai/components/api/services/iembeddinggenerationservice.md): Gets or sets the embedding generation service used for generating embeddings from text.

### ![](/files/ptrKjmmRoQB76pvrIqh0) FilePath

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the file path associated with the document. (Default: `null`)

Setting this property will reset the internal document and stream references. If the value changes, the [Stream](#stream) and the internal document are set to `null`.

### ![](/files/ptrKjmmRoQB76pvrIqh0) FileType

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the file type of the document. (Default: `null`)

Setting this property will reset the internal document.

### ![](/files/ptrKjmmRoQB76pvrIqh0) MaxClusters

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Get or sets the maximum number of vector clusters to generate when performing summarization tasks. (Default: `5`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) MaxContextTokens

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Gets or sets the maximum number of context tokens. (Default: `4096`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) MinSimilarity

[Single](https://docs.microsoft.com/dotnet/api/system.single): Gets or sets the minimum similarity threshold for document retrieval. (Default: `0.25`)

### ![](/files/ptrKjmmRoQB76pvrIqh0) RerankingEnabled

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Gets or sets a value indicating whether reranking is enabled. (Default: `False`)

### ![](/files/KL0Ik37djZRr8a07Wopd) RerankingService

[IRerankingService](/ai/components/api/services/irerankingservice.md): Gets or sets the reranking service.

### ![](/files/ptrKjmmRoQB76pvrIqh0) Stream

[Stream](https://docs.microsoft.com/dotnet/api/system.io.stream): Gets or sets the stream associated with the document. (Default: `null`)

Setting this property will reset the internal document and file path references. If the value changes, the [FilePath](#filepath) and the internal document are set to `null`.

### ![](/files/KL0Ik37djZRr8a07Wopd) TextSplitterService

[ITextSplitterService](/ai/components/api/services/itextsplitterservice.md): Gets or sets the text splitter service used for splitting text into smaller chunks.

### ![](/files/KL0Ik37djZRr8a07Wopd) TokenizerService

[ITokenizerService](/ai/components/api/services/itokenizerservice.md): Gets or sets the tokenizer service used for truncating context tokens.

### ![](/files/ptrKjmmRoQB76pvrIqh0) TopN

[Int32](https://docs.microsoft.com/dotnet/api/system.int32): Gets or sets the number of top chunks to retrieve. (Default: `10`)

## Methods

### ![](/files/KL0Ik37djZRr8a07Wopd) EmbedQuestionAsync(question)

Asynchronously generates an embedding for the specified question.

| Parameter    | Type                                                          | Description                                             |
| ------------ | ------------------------------------------------------------- | ------------------------------------------------------- |
| **question** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The question to be embedded. Must not be null or empty. |

**Returns:** [Task\<Embedding>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains the generated [Embedding](/ai/components/api/embeddings/wisej.ai.embeddings.embedding.md) for the question, or `null` if the input is invalid.

This method checks if the provided *question* is null or empty and returns `null` if so. Otherwise, it delegates the embedding generation to the `EmbeddingGenerationService`.

### ![](/files/KL0Ik37djZRr8a07Wopd) query\_document(question)

Queries a single document based on the provided document name and question.

| Parameter    | Type                                                          | Description                             |
| ------------ | ------------------------------------------------------------- | --------------------------------------- |
| **question** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The question to query the document for. |

**Returns:** [Task\<String>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains the query result as a string.

### ![](/files/KL0Ik37djZRr8a07Wopd) RerankAsync(question, chunks)

Asynchronously reranks the provided text chunks based on their relevance to the given question.

| Parameter    | Type                                                              | Description                                   |
| ------------ | ----------------------------------------------------------------- | --------------------------------------------- |
| **question** | [String](https://docs.microsoft.com/dotnet/api/system.string)     | The question used as the basis for reranking. |
| **chunks**   | [String\[\]](https://docs.microsoft.com/dotnet/api/system.string) | An array of text chunks to be reranked.       |

**Returns:** [Task\<String\[\]>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains an array of reranked text chunks.

This method is intended to be overridden in derived classes to implement custom reranking logic. The method should return the *chunks* array reordered by relevance to the *question* .

### ![](/files/KL0Ik37djZRr8a07Wopd) summarize\_document()

Summarizes the content of a specified document.

**Returns:** [Task\<String>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task that represents the asynchronous operation. The task result contains the summary as a string.

## Implements

| Name                                                                          | Description                                                                                           |
| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| [IToolsContainer](/ai/components/api/tools/wisej.ai.tools.itoolscontainer.md) | Represents a container for tools, providing access to a hub, adapter, and a collection of parameters. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/ai/components/api/tools/wisej.ai.tools.documenttools.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
