Teradata Agent Builder Workshop

Portfolio Agent using Teradata Vantage AI

This hands-on lab guides you through building an AI Agentic assistant that converts natural language questions to summarized responses by using MCP(Model Context Protocol) to execute teradata queries, Vector Database for cross referencing compliance information and Database Catalog to down select relevant database tables and columns based on input query.

Use Case:

You are financial advisor and need to query portfolio database for your clients and also refer to SEC and FINRA regulations to ensure that client portfolios are compliant

Prerequisites:

  • Access to the Teradata catalog for client portfolios.

  • Access to the teradata MCP server for database access.

  • Basic familiarity with Karini AI platform.

  • Esure that all participants have access to the Karini AI platform.

Access to Karini AI Generative AI Platform

If a participant has received an email invitation, they should follow the sign-up process using the link provided in the invitation email.

  • Click the Sign Up.

  • Fill in the required information:

    • Full name: Enter full name.

    • Email : Provide a valid email address for communication and account verification.

    • Click Submit.

    • Follow the on-screen instructions to finalize the sign up process.

    Note: Users cannot sign up directly if they did not receive an invitation email.

Login to Karini AI

When logging in for the first time, users are presented with the Karini AI Setup Wizard as shown below:

Click Opt-Out button located on right hand corner.

Upon opting out, the user is redirected to the Karini AI homepage, where they can begin interacting with their environment.

Step 1: Create a Database Catalog

  1. Navigate to Catalog Schema using the vertical menu bar.

  2. Click “Add new”.

  1. Configure the catalog:

    1. Name: "Portfolio Catalog"

    2. Connector type: Teradata.

    3. Enter the required credentials provided separately. (Ensure to populate Database field).

  2. Save the catalog.

  3. Open the saved catalog.

  4. Click on the Browse schema button as shown below.

This action opens the View Schema panel, where the Catalog Explorer section is displayed. From the catalog hierarchy, expand FAsuperuser to view the available tables.

Select the following tables from the Catalog Explorer:

  • transaction_history

  • client_profiles

  • portfolio_holdings

  1. Once the required tables are selected, click the Import selected schemas button located on the right side of the screen to proceed.

  1. After the import, open the Catalog Explorer.

    • Select each table individually.

    • Within the selected table, enable all checkboxes for metadata generation.

    • Click the Generate Metadata button (on the right side).

    • Repeat the process one table at a time until all are completed.

  1. After generating metadata for all imported tables, click the Publish button located in the upper-right corner.

Once the catalog has been published successfully, it is now available for use as a tool within the Agent Prompt.

Refer to the following video to create Database catalog.

Step 2: Create an Agent Prompt

  1. Navigate to Prompt Playground using the vertical menu bar.

  2. Click “Add new

  1. Click “Prompt templates” to select existing prompt template.

  1. From the prompt templates table, select the “Portfolio Advisor” prompt template.

  1. Click on Use template button to select the prompt template.

  1. Increase the “Max State Updates” from 3 to 50 for complex reasoning.

  1. Scroll down to the “Agent input” box to add the following test query :

  2. "How many clients have completed their KYC verification?"

  3. Ensure that you scroll up to rename your prompt with your initials .

  4. Save the prompt.

  5. You will be directed to the Prompt Playground and select your working prompt:

    • Click on the Tools tab to configure the following tools:

    [Hint: Please Save your Changes before you navigate away while adding new tools ]

  • Catalog Tool

    • Click on “Add new” tools.

    • Enter name as “Portfolio Catalog”.

    • Enter the Description as follows :“The catalog tool uses natural language questions to search relevant tables and columns to create a SQL query”.

    • Select Type: Catalog.

    • Select the catalog created in Step 1 from the dropdown menu.

    • Save the tool.

  • MCP Tool

    • Click Add new in tools.

    • Enter name as “Teradata MCP”

    • Enter the Description as follows :“MCP server providing tools to access Teradata database to push down query execution"

    • Select Type: MCP(Model Context Protocol).

    • Select the MCP that was created by your admin (“Teradata”)

    • Save the tool.

  • Dataset Tool

    • Click Add New to create a new tool.

    • Name: "Compliance Reports".

    • Enter the Description as follows: "Retrieves compliance reports from a dataset.".

    • Select Type: Dataset.

    • Select the pre-created “Compliance Reports” dataset.

      • Note: The dataset is a vector store knowledge base which has been pre-populated with Financial Compliance documents from Finra and SEC.

    • In the Prompt context section, Select Use Embedding chunks.

    • Set the following options for context retrieval: Top-K = 3

    • Save the tool.

The interface will appear as shown below. You are now ready to test your agent prompt.

Test & Compare :

  1. Click the “Test and compare” tab.

  2. Select different models [Hint: Compare Bedrock Anthropic Claude Sonnet 3.7, Bedrock Anthropic Claude Sonnet 4.0, Claude 3.5 Sonnet V2].

  3. Click “Test” to invoke the model call.

  4. Wait for all three model responses to be generated. During this time, the status will display as “Generating...”.

Once the responses are available, three icons will appear for each model:

  • Copy (to copy the response)

  • Prompt Lens (to inspect the prompt and response)

  • Trace (to view tool input/output details)

After all responses are visible, click Format Response located on top to see the output in a structured format.

Review the traces to verify which tools were invoked, along with their inputs and outputs.

  1. Compare the output of the selected Models.[Hint: Observe times, input/output tokens etc and observability tracing]

  2. Click Select as Best Answer with Bedrock Anthropic Claude Sonnet 3.7 to designate the best-performing model as the Primary Model.

  1. Click “Save prompt run” to save your experiment with comments.

  2. Save the prompt.

  1. Publish the saved prompt for version control.. Once published, the prompt will be assigned a version number.

Note: Only published prompts are visible in the recipe.

Refer to the following video to create and test agent prompt.

Step 3: Create Agent 2.0 Recipe

  1. Navigate to Recipe in vertical menu bar

  2. Click “Add new” in the top corner.

  1. Configure recipe details:

    1. Name: "Portfolio Advisor".

    2. Description: "Intelligent assistant for portfolio advisor".

    3. Type: Agent 2.0

  2. Set up the workflow :

    1. Drag and drop Chat node:

      1. In the Conversation history dropdown, select 2 messages.

      2. Enable Generate follow-up questions.

      3. Enable citation.

    2. Drag and drop Start node:

      1. Connect the Chat node to the Start node.

    3. Drag and drop Agent node:

      1. Select your Agent prompt from the dropdown that was created in step 2.

      2. Scroll down and Set the Messages dropdown to All Messages to maintain conversation context.

      3. Connect the Start node to the Agent node.

    4. Drag and drop End node:

      1. Connect the Agent node to the End node.

  3. On the right side, set the Number of state updates to a higher value such as 75.

  4. Click on the empty space in the canvas, then click Save.

  5. Select your recipe from the recipe table.

  6. Ensure you click on Publish the recipe.

  1. Add appropriate tags to categorize and identify the recipe version before publishing.

  1. By default, the V1 version is deployed once it is published.

  2. For subsequent versions, use the Actions button and select Deploy to deploy the new version. [Hint: Use Actions Button to select Deploy dropdown].

  3. Click the Test button on the right side to verify functionality.

  1. Chat widget will be displayed to enter the questions.

  2. Test with sample questions:

    1. How many clients have completed their KYC verification?

    2. Which portfolios have any single stock position over 30%? Check against FINRA concentration limits.

  3. Wait for a few moments while the system processes the query. Response times may vary depending on the complexity of the question and data availability.

    Once the answer is displayed, the following options and details will be available:

    • Response :the generated response to your query.

    • Prompt Lens :view the prompt details and response breakdown.

    • Trace: inspect the tools invoked along with their input and output.

    • Statics : review metadata such as response time, token usage, and timestamps.

Refer to the following video to create and test the recipe.

Step 4: Create a Chat Assistant

STOP: Make sure you have "published" the recipe before continuing to this step

  1. Click the Action -> Export button located at the top-right corner of your recipe.

  1. Click “Add new” to create an Export configuration.

  1. Complete the export form:

    1. Name: "Portfolio Advisor Assistant"

    2. Add a Welcome message, as preferred.

    3. Add Description as follows: The Portfolio Advisor Assistant is designed to help you analyze and understand clients portfolio

    4. Add Seed Questions:

      1. How should investment advisers document “best interest” determinations under the SEC’s proposed Regulation Best Execution compared with FINRA Rule 5310?

      2. How many clients have completed their KYC verification

      3. Which portfolios have any single stock position over 30%? Check against FINRA concentration limits.

      4. Are there any accounts with a single ticker representing over 20% of portfolio value? Validate concentration rules.

    5. Add Error message as follows: “Apologies for the error, please try again”

    6. Enable positive (thumbs up) and negative (thumbs down) feedback. [Hint: Optionally, You can also add custom feedback.]

    7. Select “Show traces”.

    8. Click Save.

  2. User can access the Copilot in two ways:

    • From the Exported Recipe

      1. Open the saved export , click the < icon on the right panel.

      2. The Visit Copilot button will appear.

      3. Click Visit Copilot to open and interact with your Copilot.

  • From the left menu

    • The Copilot will be displayed in the Copilots section of the vertical menu.

  1. After redirecting, the Copilot interface will appear as shown below.

  1. Click on one of the available seed questions.

  2. Wait for a few moments while the system processes the query. Response times may vary depending on the complexity of the question.

  3. After submitting the question, the Trace icon will appear, allowing you to view the tools invoked along with their inputs and outputs.

  4. Once the response is generated, the following elements will be visible:

  • Answer : the system’s response to the question (text or table format).

  • Citations : sources referenced in the response, so you can access the original documents.

  • Follow-up Questions : suggested related questions that allow you to continue exploring the topic.

  • Prompt Lens :to inspect the underlying prompt and response details.

  • Copy button :to copy the answer for reuse.

  • Feedback options : to rate the response with a thumbs up or thumbs down.

Questions:

  • How should investment advisers document “best interest” determinations under the SEC’s proposed Regulation Best Execution compared with FINRA Rule 5310?

  • How many clients have completed their KYC verification?

  • Which portfolios have any single stock position over 30%? Check against FINRA concentration limits.

  • Are there any accounts with a single ticker representing over 20% of portfolio value? Validate concentration rules

Refer to the following video for copilot functionality.

Congratulations, Now you are certified in Karini AI Generative AI Platform and Teradata, World's leading Analytics Platform

Last updated