LogoLogo
HomeNewsSupportVideos
  • Welcome
  • Wisej.NET
  • Concepts
    • Getting Started
    • General Concepts
    • Architecture
    • Extensibility
    • AI Providers
    • Vector Databases
    • Usage Metrics
    • Logging & Error Handling
  • Markup
  • Components
    • API
      • SmartAdapter
        • SmartAudioTTSAdapter
        • SmartAudioWhisperAdapter
        • SmartCalendarAdapter
        • SmartChartAdapter
        • SmartChartJS3Adapter
        • SmartChatBoxAdapter
        • SmartComboBoxAdapter
        • SmartCopilotAdapter
        • SmartDataEntryAdapter
        • SmartDocumentAdapter
        • SmartFullCalendarAdapter
        • SmartObjectAdapter
        • SmartPictureBoxAdapter
        • SmartQueryAdapter
        • SmartRealtimeAdapter
        • SmartReportAdapter
        • SmartTextBoxAdapter
        • SmartAdapter.ExtendsAttribute
        • SmartAdapter.FieldNameAttribute
        • SmartAdapter.FieldPromptAttribute
        • SmartAdapter.FieldRectangleAttribute
        • SmartAdapter.WorksWithAttribute
      • SmartEndpoint
        • AmazonBedrockEndpoint
        • AnthropicEndpoint
        • AzureAIEndpoint
        • CerebrasEndpoint
        • DeepSeekEndpoint
        • GoogleAIEndpoint
        • GroqCloudEndpoint
        • GroqCloudEndpointWhisper
        • HuggingFaceEndpoint
        • HuggingFaceJavaScriptEndpoint
        • LocalAIEndpoint
        • LocalAIEndpointImageGen
        • LocalAIEndpointTTS
        • LocalAIEndpointWhisper
        • NvidiaAIEndpoint
        • OllamaEndpoint
        • OpenAIEndpoint
        • OpenAIEndpointDallE
        • OpenAIEndpointRealtime
        • OpenAIEndpointTTS
        • OpenAIEndpointWhisper
        • SambaNovaEndpoint
        • SmartHttpEndpoint
        • TogetherAIEndpoint
        • XAIEndpoint
        • SmartEndpoint.Metrics
        • SmartEndpoint.Response
      • SmartExtensions
      • SmartHub
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
      • SmartObject
      • SmartPrompt
        • SmartAgentPrompt
        • SmartParallelPrompt
        • SmartPrompt.Parameter
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
      • SmartRealtimeSession
      • SmartSession
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.Message
        • SmartSession.MessageCollection
        • SmartSession.MessageRole
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
        • SmartSession.TrimmingStrategy
      • SmartTool
        • SmartTool.IToolProvider
        • SmartTool.ToolAttribute
        • SmartTool.ToolContext
      • Markup
        • MarkupExtensions
      • Controls
        • UVLightOverlay
      • Embeddings
        • EmbeddedDocument
        • Embedding
        • Matches
        • Metadata
      • Helpers
        • ApiKeys
        • Markdown
        • TextTokenizer
      • Services
        • DefaultSessionTrimmingService
        • IDocumentConversionService
          • DefaultDocumentConversionService
        • IEmbeddingGenerationService
          • DefaultEmbeddingGenerationService
          • HuggingFaceEmbeddingGenerationService
        • IEmbeddingStorageService
          • AzureAISearchEmbeddingStorageService
          • ChromaEmbeddingStorageService
          • FileSystemEmbeddingStorageService
          • MemoryEmbeddingStorageService
          • PineconeEmbeddingStorageService
          • QdrantEmbeddingStorageService
        • IHttpClientService
          • DefaultHttpClientService
        • ILoggerService
          • DefaultLoggerService
        • IOCRService
          • DefaultOCRService
        • IRerankingService
          • DefaultRerankingService
          • LocalAIRerankingService
          • PineconeRerankingService
        • ISessionTrimmingService
          • DefaultSessionTrimmingService
        • ITextSplitterService
          • RecursiveCharacterTextSplitterService
          • TextSplitterServiceBase
        • ITokenizerService
          • DefaultTokenizerService
        • IWebSearchService
          • BingWebSearchService
          • BraveWebSearchService
          • GoogleWebSearchService
      • Tools
        • ArxivTools
        • ChartJS3Tools
        • DatabaseTools
        • DataTableFilterTools
        • DocumentSearchTools
        • DocumentTools
        • FullCalendarTools
        • IToolsContainer
        • MathTools
        • ToolsContainer
        • UtilityTools
        • WebSearchTools
    • Built-in Services
      • IOCRService
      • ILoggerService
      • ITextSplitterService
      • ITokenizerService
      • IHttpClientService
      • IWebSearchService
      • IRerankingService
      • ISessionTrimmingService
      • IDocumentConversionService
      • IEmbeddingStorageService
      • IEmbeddingGenerationService
    • Built-in SmartTools
      • ToolsContainer
      • MathTools
      • UtilityTools
      • DatabaseTools
      • DocumentTools
      • DocumentSearchTools
      • WebSearchTools
      • ChartJS3Tools
      • FullCalendarTools
    • Built-in SmartAdapters
      • SmartAdapter
      • SmartAudioTTSAdapter
      • SmartAudioWhisperAdapter
      • SmartCalendarAdapter
      • SmartChartAdapter
      • SmartChartJS3Adapter
      • SmartChatBoxAdapter
      • SmartComboBoxAdapter
      • SmartCopilotAdapter
      • SmartDataEntryAdapter
      • SmartDocumentAdapter
      • SmartFullCalendarAdapter
      • SmartObjectAdapter
      • SmartPictureBoxAdapter
      • SmartQueryAdapter
      • SmartRealtimeAdapter
      • SmartReportAdapter
      • SmartTextBoxAdapter
    • Configure Services
    • Using SmartHub
    • Using SmartTools
    • Using SmartPrompt
    • Using SmartSession
    • Using SmartRealTimeAdapter
    • UVLightOverlay Control
Powered by GitBook
On this page
  • Overview
  • Properties
  • AutoReset
  • User
  • BotName
  • BotAvatar
  • ChatBox
  • Methods
  • AskAsync
  • ResetSession
  • Events
  • AnswerReceived
  • ReadingReport
Export as PDF
  1. Components
  2. Built-in SmartAdapters

SmartReportAdapter

PreviousSmartRealtimeAdapterNextSmartTextBoxAdapter

Last updated 3 days ago

Overview

This adapter operates in a manner similar to the by answering questions and executing tasks specifically related to a single document. However, it is specifically designed to work with reports containing data, often organized in tables.

Such reports typically do not perform well when using conventional similarity searches based on the semantic meaning of document chunks.

Tabular data, or any data that is not presented in a narrative or conversational format, poses indexing challenges. Lines containing numbers and dates lack inherent semantic meaning, making them difficult to relate directly to user queries. Consequently, traditional methods that rely on semantic context are ineffective for indexing such data, as these methods depend on linguistic and semantic elements typically absent in purely numerical or date-based entries.

For instance, imagine a 50-page tabular report containing a list of invoices. If you were to ask an AI model a question such as "Who are the top 5 clients by revenue, and include a brief description of the work done," it would be infeasible to extract the pertinent sections of the document using any type of embedding-based similarity. This task would require the model to process and analyze the entire document, as traditional search methods fall short when navigating large volumes of tabular data without clear semantic links.

The adapter employs a two-prompt system to handle tabular data extraction. The first prompt generates a JSON schema, which is designed to capture the data necessary to answer specific questions from each page of the document. The second prompt then utilizes this schema to process each individual page and extract the corresponding data. Once the data is extracted, it is compiled into a RAG (Retrieval-Augmented Generation) context string, which is subsequently used for final processing.

To assist with data analysis, the adapter also provides an internal evaluate_expression tool that enables the model to perform simple calculations. This comprehensive approach ensures that every page of the report is processed thoroughly, allowing for accurate data extraction and analysis.

These are the built-in prompts:

#
# SmartReportAdapter
#
[SmartReportAdapter.Prompt]
Your job is to answer the user’s question about the report identified below.
Use the "get_data" tool to retrieve the information from the report required answer the questin with 100% accuracy.

## Rules:
- Do not explain your answer
- Do not answer without retrieving the necessary information from the report FIRST
- Do not return expressions or formulas, evaluate and return the result with your answer
- Unless you have 100% confidence that your answer is accurate, always use the "get_data"

```Report
{{report_metadata}}
```

[SmartReportAdapter.get_data]
Extracts the requested information from the report.

[SmartReportAdapter.get_data.question]
Rewrite the user’s question to optimize it for extracting the relevant information from the report pages.

[SmartReportAdapter.DataExtractionPrompt]
Your job is to extract the information necessary to answer the user’s question strictly using the specified JSON schema.

## Rules:
- Only provide the answer without any explanations
- Exclude rows with aggregated total values
- Return an empty answer if there is no data
- Do not add empty fields to the response

```JSON schema
{{schema}}
```

```User’s question
{{user_question}}
```

[SmartReportAdapter.SchemaPrompt]
Your job is to build a flat JSON schema with the fields that are necessary to capture the information required to answer the user’s question.
The data will be extracted from the pages of a report. Use the page example provided below to deduct the fields for the schema.

## Rules:
- It is imperative to specify ONLY the fields that are strictly related to answering the user’s question
- The description of the data should NOT indicate the value it should contain
- Never include sentences like "In this case it should be...", "Such as..." in the field descriptions
- The fields in the JSON schema should be defined like this:

{
	"<fieldName>": "<Description of the type of information that should be extracted into this field>"
}

```Page example
{{page_sample}}
```

[SmartReportAdapter.DataExtractionPrompt]
Your job is to extract the data necessary to answer the user’s question strictly using the specified JSON schema.

## Rules:
- Only provide the answer without any explanations
- Exclude rows with aggregated total values
- Return an empty answer if there is no data
- Do not add empty fields to the response

```JSON schema
{{schema}}
```

Properties

AutoReset

Determines whether the conversation history is cleared after each response. Preserves the messages in the connected ChatBox.

Default is false.

User

Represents the AI user in the ChatBox as an instance of the ChatBox.User class. This property is read-only and identifies the AI participant within the chat interface. To customize the AI’s display name or avatar, use the BotName and BotAvatar properties, respectively. The property itself cannot be reassigned, but you can modify the AI user's appearance through these options.

BotName

The BotName property specifies the display name of the AI bot within the ChatBox. By default, this name is set to "Wisej." You can use this property to assign a custom name to your bot, allowing you to better personalize the chat experience for your application’s users.

BotAvatar

The BotAvatar property specifies the image that represents the AI bot in the ChatBox. You can set this property to either the name of a built-in image or the URL of a custom image. This allows you to personalize the bot's appearance by displaying a specific avatar in the chat interface.

ChatBox

The ChatBox property is read-only and returns the instance of the ChatBox control associated with the adapter. This association is established when you call this.smartHub.GetAI(this.chatBox) and assign the adapter using this.smartHub.GetAI(this.chatBox).Adapter = this.smartReportAdapter. The property provides access to the specific ChatBox control that is linked to the current AI adapter instance.

Methods

AskAsync

Sends a query to the AI model, utilizing the connected report.

var adapter = new SmartReportAdapter
{
	Hub = new SmartHub { 
		Endpoint = new OpenAIEndpoint { ApiKey = "..." }
	},
	FilePath = Application.MapPath("UnpaidInvoices.pdf");
};

// The adapter will index the document once, on first use.
Console.WriteLine((await adapter.AskAsync("Top 3 clients in order of unpaid amount")).Text);

ResetSession

Clears the history in the current session. The adapter will create a new session when it processes the next question.

Events

AnswerReceived

The AnswerReceived event provides all the information related to the answer generated by the AI. Using this event, you can access the original message and answer returned by the model.

Name
Description

e.Message

The agent message, includes the full text of the answer and the usage.

e.Answer

The original answer from the AI model. Can be changed.

ReadingReport

Since this adapter must read and process each page in the document, it provides this event to the application to offer progress feedback to the user.

Please note that pages are processed in parallel, so this event may trigger out of order, as some pages may be processed more quickly than others.

Name
Description

e.PageIndex

The current page index being processed during the data extraction phase.

e.PageCount

The total number of pages.

In addition to the properties inherited from the , the SmartReportAdapter exposes the following additional properties.

SmartDocumentAdapter
SmartAdapter