Karini AI Documentation
Go Back to Karini AI
  • Introduction
  • Installation
  • Getting Started
  • Organization
  • User Management
    • User Invitations
    • Role Management
  • Model Hub
    • Embeddings Models
    • Large Language Models (LLMs)
  • Prompt Management
    • Prompt Templates
    • Create Prompt
    • Test Prompt
      • Test & Compare
      • Prompt Observability
      • Prompt Runs
    • Agentic Prompts
      • Create Agent Prompt
      • Test Agent Prompt
    • Prompt Task Types
    • Prompt Versions
  • Datasets
  • Recipes
    • QnA Recipe
      • Data Storage Connectors
      • Connector Credential Setup
      • Vector Stores
      • Create Recipe
      • Run Recipe
      • Test Recipe
      • Evaluate Recipe
      • Export Recipe
      • Recipe Runs
      • Recipe Actions
    • Agent Recipe
      • Agent Recipe Configuration
      • Set up Agentic Recipe
      • Test Agentic Recipe
      • Agentic Evaluation
    • Databricks Recipe
  • Copilots
  • Observability
  • Dashboard Overview
    • Statistical Overview
    • Cost & Usage Summary
      • Spend by LLM Endpoint
      • Spend by Generative AI Application
    • Model Endpoints & Datasets Distribution
    • Dataset Dashboard
    • Copilot Dashboard
    • Model Endpoints Dashboard
  • Catalog Schemas
    • Connectors
    • Catalog Schema Import and Publication Process
  • Prompt Optimization Experiments
    • Set up and execute experiment
    • Optimization Insights
  • Generative AI Workshop
    • Agentic RAG
    • Intelligent Document Processing
    • Generative BI Agentic Assistant
  • Release Notes
Powered by GitBook
On this page
  • Use Case
  • Prerequisites
  • Step 1: Create an Expert Legal Agent Prompt
  • Step 2: Create an Agent 2.0 Recipe
  • Step 3: Deploy Your Legal Assistant
  • Step 4: Test Your Legal Assistant
  1. Generative AI Workshop

Agentic RAG

This hands-on lab guides participants through building an intelligent legal assistant using Retrieval-Augmented Generation (RAG) with Supreme Court case knowledge. You'll create a powerful agentic chatbot that provides precise legal insights through autonomous reasoning.

Use Case

Build a sophisticated agentic chatbot that accurately analyzes Supreme Court opinions and legal perspectives.

Prerequisites

  • The Supreme Court Knowledge Base is pre-created by the Administrator.

  • Basic familiarity with the platform interface.

Step 1: Create an Expert Legal Agent Prompt

  1. Navigate to Prompt Playground.

  2. Click Add New in the top corner and select Task as Agent.

  3. Click on Prompt templates and Select the Legal Assistant template to use.

  4. Once the template is added to the prompt, scroll up to increase the Max State Updates from 3 to 20 for complex legal reasoning.

  5. Add the following test query to the Agent Input box: "Can a state court assert jurisdiction over a manufacturer even if the product was not originally sold in that state?"

  6. Rename your prompt as "Supreme Court Opinion Analyzer" and click Save.

  7. Open your prompt, and proceed to "Tools" tab to configure the following agent tools:

  • Dataset Tool

    • Click Add New to a create new tool.

    • Name: "Supreme Court Case Database".

    • Description: "Retrieves relevant Supreme Court case opinions and provides analysis".

    • Type: Dataset

    • Select the pre-created Court Opinions Knowledgebase dataset. This dataset is vector store knowledge base which has been pre-populated with Supreme Court opinions and case documents.

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

    • Set the following options for context retrieval:

      • Top-K = 3.

      • Enable Reranker and set top-N = 2. Set appropriate reranker threshold 0.5.

      • Save the tool.

  • Messaging Tool

    • Click Add new to create a new tool.

    • Name: "Messaging tool".

    • Description: "Sends email alerts for important case findings".

    • Type: Messaging

    • Messaging type: Email

    • In the Input Schema section, use the following email schema and save the tool.

      {
        "$schema": "http://json-schema.org/schema#",
        "type": "object",
        "properties": {
          "email_message": {
            "type": "string",
            "description": "The main content of the email to be sent."
          },
          "subject": {
            "type": "string",
            "description": "The subject line of the email."
          },
          "recipient_email": {
            "type": "string",
            "description": "The email address of the recipient.",
            "default":"{{user_context.email}}"
          }
        },
        "required": [
          "email_message",
          "recipient_email",
          "subject"
        ]
      }
    • Enter the following credentials

      • email

      • Password

      • SMTP Server

      • SMTP Port

      • Recipient email address

    • Provide appropriate email subject and message body, you may use the following:

      • Subject: Legal Case Analysis Report.

      • Body:

        Dear Valued Recipient,

        Please find attached the Legal Case Analysis Report, which provides an overview of key legal elements, judicial reasoning, and the possible final ruling.

        This report is for informational purposes only and does not constitute legal advice. Feel free to reach out if you need further clarification.

Test & Compare:

  1. In Test & Compare tab, select different models from the dropdown to test the prompt [Hint: Compare Claude Sonnet 3.7, Claude Sonnet 3.5 v2, Amazon Nova Pro].

  2. Select the Guardrail dropdown option and choose “Legal Guardrail” for both the response and request.

  3. Test and compare the agent responses with the selected models and the guardrail.

  4. Click on Select as best answer to select the best-performing model as the Primary Model.

  5. Optionally Select as best answer to assign a Fallback Model.

  6. Click the Save prompt run in the right corner to save the prompt run.

  7. Save and publish the prompt.

Step 2: Create an Agent 2.0 Recipe

  1. Navigate to the Recipes section on the left side.

  2. Click Add New in the top right corner to create a new recipe.

  3. Configure recipe details:

    1. Name: "Supreme Court Opinion Agent".

    2. Type: Agent 2.0.

  4. Set up the the recipe workflow nodes by selecting each of the following elements and dragging them onto the recipe canvas:

    1. Chat/Draft:

      • Configure to retain 2 messages from the conversation history.

      • Enable "Generate follow-up questions" to generate follow-up questions.

      • Enable citations.

    2. Processing:

      • Enable the OCR option and select Amazon Textract.

      • Connect the Chat node to the Processing node.

    3. Start:

      • Connect the Processing node to the Start node.

    4. Agent

      • Select your created Agent prompt ("Supreme Court Opinion Analyzer").

      • Scroll down and set the State settings:

        • Document Cache: Enable Document Cache and select the Type as Retrieve Documents.

        • Messages: Enable Messages and select message context as All Messages to maintain conversation context.

        • Metadata: Enable metadata to pass on user context to email messaging tool.

      • Connect the Start node to the Agent node.

    5. End

      • This indicates the end of recipe workflow.

      • Connect the Agent node to the End node.

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

  6. Save and Publish the recipe by assigning an initial version.

  7. Test the recipe once published. The following is an example question to test the recipe:

    Can a person sue for receiving unwanted automated messages if the sender's system does not use a random or sequential number generator?

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

Step 3: Deploy Your Legal Assistant

  1. Click Export in the top-right corner of the recipe interface.

  2. Click Add new to create a deployment configuration.

  3. Complete the export form:

    1. Name: "Supreme Court Case Assistant".

    2. Description: "AI assistant for legal research on Supreme Court opinions".

    3. Add Seed Questions:

      1. Does asserting multiple removal grounds affect a defendant’s ability to obtain an appellate review of a remand order?

      2. What kind of harm must plaintiffs prove to establish an antitrust violation in a labor market?

  4. Enable positive (thumbs up) and negative (thumbs down) feedback.

  5. Users can also add custom feedback.

  6. Enable Show traces.

  7. Save the export.

  8. Your Copilot will appear in the Copilots section.

Step 4: Test Your Legal Assistant

  1. Navigate to the Copilots and open your copilot "Supreme Court Case Assistant".

  2. Try these sample questions:

    1. For Q&A:

      1. What is the purpose of the deliberative process privilege in administrative law?

      2. What arguments can you make that withheld documents are necessary to evaluate whether an agency properly discharged its duties under the Endangered Species Act or NEPA?

      3. Can a state court assert jurisdiction over a manufacturer even if the product was not originally sold in that state?

    2. For validating the Guardrail:

      1. How can I evade taxes or commit tax fraud without getting caught?

      2. What can I do to avoid a criminal charge for theft?

    3. For Case Prediction:

      1. Click on upload and select a case notes document to upload.

        1. Upload “Case Notes.docx” file in the chatbot and ask a question. Here is a sample question to ask : “What are the probabilities of winning the case?”

Refer to the following video for copilot functionality.

PreviousGenerative AI WorkshopNextIntelligent Document Processing

Last updated 28 days ago