> 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/smartadapter/wisej.ai.adapters.smartdocumentadapter.md).

# SmartDocumentAdapter

Namespace: **Wisej.AI.Adapters**

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

* [SmartAdapter](/ai/components/api/smartadapter.md)
  * [SmartDocumentAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartdocumentadapter.md)

Represents a document adapter that can perform AI tasks using a document as a data source and interact with the user through a ChatBox control.

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

```csharp
public class SmartDocumentAdapter : SmartAdapter
```

{% endtab %}

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

```visual-basic
Public Class SmartDocumentAdapter
    Inherits SmartAdapter
```

{% endtab %}
{% endtabs %}

This class integrates with the [IEmbeddingStorageService](/ai/components/api/services/iembeddingstorageservice.md) to search within the document being managed.\
It provides properties to configure the bot's appearance and document handling, and events to manage responses.

## Constructors

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

Initializes a new instance of the [SmartDocumentAdapter](/ai/components/api/smartadapter/wisej.ai.adapters.smartdocumentadapter.md) class.

## Properties

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

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Gets or sets a value indicating whether the history of the conversation is cleared after each response. (Default: `False`)

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

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the avatar image source of the bot. (Default: `"resource.wx/Wisej.AI/Icons/wisej-avatar.svg"`)

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

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the name of the bot. (Default: `"Wisej.AI"`)

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

[ChatBox](https://docs.wisej.com/api?q=wisej.web.ext.chatcontrol.chatbox): Gets the associated ChatBox control.

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

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

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

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

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

[String](https://docs.microsoft.com/dotnet/api/system.string): Gets or sets the file type. i.e. .docx, .pdf, .txt. If null it will be detected automatically. (Default: `null`)

### ![](/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) MinSimilarity

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

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

[Stream](https://docs.microsoft.com/dotnet/api/system.io.stream): Gets or sets the file path of the document. (Default: `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/ptrKjmmRoQB76pvrIqh0) TopN

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

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

[User](https://docs.wisej.com/api?q=wisej.web.ext.chatcontrol.user): Gets the user representing the bot.

## Methods

### ![](/files/ptrKjmmRoQB76pvrIqh0) AskAsync(question)

| Parameter    | Type                                                          | Description |
| ------------ | ------------------------------------------------------------- | ----------- |
| **question** | [String](https://docs.microsoft.com/dotnet/api/system.string) |             |

**Returns:** [Task\<String>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1).

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception)\
  When question is null.

### ![](/files/KL0Ik37djZRr8a07Wopd) OnAnswerReceived(e)

Raises the [AnswerReceived](#answerreceived) event.

| Parameter | Type                                                                                                         | Description                                                                                                                                          |
| --------- | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [AnswerReceivedArgs](https://docs.wisej.com/api?q=wisej.ai.adapters.smartdocumentadapter+answerreceivedargs) | The [AnswerReceivedArgs](https://docs.wisej.com/api?q=wisej.ai.adapters.smartdocumentadapter.answerreceivedargs) instance containing the event data. |

### ![](/files/KL0Ik37djZRr8a07Wopd) OnControlCreated(control)

| Parameter   | Type                                                      | Description |
| ----------- | --------------------------------------------------------- | ----------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) |             |

### ![](/files/KL0Ik37djZRr8a07Wopd) OnControlDisposed(control)

| Parameter   | Type                                                      | Description |
| ----------- | --------------------------------------------------------- | ----------- |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) |             |

### ![](/files/KL0Ik37djZRr8a07Wopd) ParseAnswer(text)

| Parameter | Type                                                          | Description |
| --------- | ------------------------------------------------------------- | ----------- |
| **text**  | [String](https://docs.microsoft.com/dotnet/api/system.string) |             |

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string).

### ![](/files/KL0Ik37djZRr8a07Wopd) ParseSourceText(text)

| Parameter | Type                                                          | Description |
| --------- | ------------------------------------------------------------- | ----------- |
| **text**  | [String](https://docs.microsoft.com/dotnet/api/system.string) |             |

**Returns:** [String](https://docs.microsoft.com/dotnet/api/system.string).

### ![](/files/ptrKjmmRoQB76pvrIqh0) ResetSession(removeMessages)

Resets the conversation history.

| Parameter          | Type                                                            | Description                                                                     |
| ------------------ | --------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| **removeMessages** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | Indicates whether all messages from the ChatBox control should also be removed. |

### ![](/files/KL0Ik37djZRr8a07Wopd) RunAsyncCore(control)

Executes the core logic asynchronously.

| Parameter   | Type                                                      | Description                                |
| ----------- | --------------------------------------------------------- | ------------------------------------------ |
| **control** | [Control](https://docs.wisej.com/api?q=wisej.web.control) | The control associated with the operation. |

**Returns:** [Task\<Message>](https://docs.microsoft.com/dotnet/api/system.threading.tasks.task-1). A task representing the asynchronous operation.

## Events

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

[AnswerReceivedHandler](https://docs.wisej.com/api?q=wisej.ai.adapters.smartdocumentadapter+answerreceivedhandler) Occurs when an answer is received.

## Implements

| Name                                                                              | Description                                |
| --------------------------------------------------------------------------------- | ------------------------------------------ |
| [IToolProvider](/ai/components/api/smarttool/wisej.ai.smarttool.itoolprovider.md) | Represents a provider that supplies tools. |


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/ai/components/api/smartadapter/wisej.ai.adapters.smartdocumentadapter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
