> For the complete documentation index, see [llms.txt](https://au-dohp.gitbook.io/au-dohp-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://au-dohp.gitbook.io/au-dohp-docs/whats-new/integration-of-a-chat-bot-feature.md).

# Integration of a chat bot feature

### Core Functionality and Architecture <a href="#core-functionality-and-architecture" id="core-functionality-and-architecture"></a>

The feature is activated by opening a data product's details and toggling the blue bubble, which reveals a chat interface. This interface provides AI generated suggestions based on the metadata of the Parquet file, guiding users on potential queries they can explore.

#### Key Components <a href="#key-components" id="key-components"></a>

1. **Fireworks as the Inference Provider**:\
   The system use [Fireworks](https://fireworks.ai/), a cloud based inference provider hosting large open source language models such as LAAMA 3.1 405B and [Qwen 2.5 72B](https://qwenlm.github.io/blog/qwen2.5/), these models are designed for specific tasks in “Chat With my Data Product” confirming accurate and efficient responses to user queries.
2. **Langchain**:\
   [**Langchain** ](https://www.langchain.com/langchain)serves as the foundational framework, offering predefined agents, LLM integration (with Fireworks in this case), and custom prompt engineering templates, this enables the system to handle a wide range of queries from simple data retrieval to complex visualization requests.
3. **Flask as the Backend Service**:\
   The backend is operted by **Flask**, which provides endpoints for processing user requests, Langchain is integrated into Flask(in the same Python virtual environment) allowing the system to convert queries into actionable tasks such as generating SQL queries or creating visualizations.

   Open Data Product Chatbot (2)-20250307-012604.png![Data Product Chatbot (2)-20250307-012604.png](blob:https://speedykom.atlassian.net/62810232-176c-4e35-8e11-77274d1fd49f#media-blob-url=true\&id=fdf24f82-2d08-40c1-b065-46a47a24d4a6\&collection=contentId-2342617109\&contextId=2342617109\&width=4872\&height=1484\&alt=Data%20Product%20Chatbot%20\(2\)-20250307-012604.png)Flowchart of Chat With my Data Product

#### Key Features <a href="#key-features" id="key-features"></a>

1. **Guided Query Suggestions**:\
   Upon opening the chat interface, users are presented with three AI generated questions based on the Parquet file's metadata, these suggestions help users understand the types of queries they can ask.
2. **Natural Language to SQL Conversion**:\
   When a user submits a question, the system processes the query and converts it into an SQL query… The Parquet file, stored in Minio, is first transformed into an Sqlite database file, Sqlite is chosen for its lightweight serverless architecture, a predefined agent generates the appropriate SQL query retrieves the relevant data and uses prompt engineering to deliver a human readable response to the user.
3. **Chart Generation**:\
   For visualization requests such as heatmaps, pie charts, histograms, 3D plots and more… the system routes the query to the appropriate agent, if the request is identified as a charting task, it is handled by the Dataframe agent which generates **Matplotlib** code in a REPL environment, the resulting chart is returned as a base64 encoded image with a descriptive label ready for user review.

#### Technical Workflow <a href="#technical-workflow" id="technical-workflow"></a>

The system employs **prompt engineering** and **agent routing** to determine the appropriate processing path for each query, when a user submits a question the system evaluates whether it should be handled by the **SQL agent** (for data retrieval) or the **dataframe agent** (for visualizations), this decision is based on predefined templates and routing logic.

* **SQL Agent**: Converts user questions into SQL queries, retrieves data from the Sqlite database, and delivers humanized responses.
* **Dataframe Agent**: Generates Matplotlib code for chart creation and returns visualizations as base64-encoded images.


---

# 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://au-dohp.gitbook.io/au-dohp-docs/whats-new/integration-of-a-chat-bot-feature.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.
