Generative Business Intelligence
Build Text-2-SQL agentic assistant
This lab focuses on developing an agentic chatbot that converts natural language queries into SQL commands by leveraging catalog schemas and databases. You will integrate NLP models, schema parsing, and automated SQL generation to enable efficient, intelligent, and user-friendly database interactions.
Use case:
Enterprise sales advisor chatbot analyzes ticket sales data for various events covering a range of performances, such as musicals, concerts, and other shows.
Prerequisites:
Use the Redshift catalog for enterprise sales data.
Step 1: Catalog Creation
Setup Redshift Catalog in Catalog Schema builder.
Click Add new button in the top corner in Catalog Schemas
Enter the name and select Redshift as the connector type.
Enter the credentials.
Save catalog.
Open the saved catalog.
Browse and Import schema.
To generate business metadata, select a table, enable checkboxes, and then click "Generate Metadata." Repeat this process for each table individually.
Publish the catalog.
The catalog is now ready for use in the Prompt Playground.
Step 2: Create an Agent prompt
Navigate to Prompt Playground.
Click the Add new button in the top corner of Prompt Playground.
Select prompt template Enterprise Sales Agent-Redshift.
Increase the Max State Updates from 3 to 20.
Add your natural language question "What is the total sales amount for each seller?" to the Agent Input (mandatory) text box.
Ensure you rename your prompt as loaded from the prompt template before saving it.
Save the prompt. After saving the prompt, the Tool tab becomes visible within the prompt.
Set up a Catalog tool.
Click Add New in the tool section and enter an appropriate name and description.
Select the type Catalog.
Select the catalog created in Step 1.
Save tool.
Set up a Database tool.
Click Add New in the tool section and enter an appropriate name and description.
Choose Database as the type and select Redshift as the connector.
Use Redshift Datawarehouse credentials.
Save tool.
In the Test & Compare tab, choose the preferred models, assess their outputs, and identify the most optimal model. Subsequently, click "Select as Best Answer" to designate it as the Primary Model. Additionally, if necessary, you may assign an alternative model as the Fallback Model. However, selecting a Primary Model is mandatory.
Click "Save prompt run" button provided at the right corner.
Save and publish prompt.
Step 3: Create Agent 2.0 Recipe
Navigate to Recipe.
Click the Add new button in the top corner of Recipe.
Provide a suitable name and description of the recipe.
Select type Agent 2.0.
Setup following tiles.
Chat
Start - Connect the Chat tile to the Start tile.
Agent (Select the Agentic prompt created in Step 2).
In the Agent Tile, select All Messages from the Messages dropdown under the Agent State flag.
Connect the Start tile to the Agent tile.
End - Connect Agent tile to End tile.
Save and Publish the recipe.
Click Test button on Chat tile to test the recipe.
Ask questions in the recipe Test.
What is the average sales amount among top 10 sellers?
What is the total sales amount for top 10 sellers?
What is the total sales amount for each seller?
Step 4: Create a copilot.
Click the "Export" button located at the top-right corner of the recipe interface.
Click Add new button.
Configure the export form by referring to the sample resource recipe provided below.
Save the export form.
The Copilot will be displayed in the Copilot section of the interface.
Step 5: Ask Questions in the chatbot
Go to the Copilot tab and open your chatbot.
Ask questions.
What is the average sales amount among top 10 sellers?
What is the total sales amount for the top 10 sellers?
What is the total sales amount for each seller?
Sample resources
Catalog schema: Enterprise-Sale-Data (Redshift)
Prompt:Enterprise Sales Agent-Redshift
Recipe: Enterprise Sales Advisor
Copilot: Enterprise Sales Advisor
Refer following video to create recipe.
Last updated