SmartReportAdapter
Last updated
Last updated
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:
Determines whether the conversation history is cleared after each response. Preserves the messages in the connected ChatBox.
Default is false.
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.
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.
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.
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.
Sends a query to the AI model, utilizing the connected report.
Clears the history in the current session. The adapter will create a new session when it processes the next question.
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.
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.
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.
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.