Help me build the following App ::

AI powered Ayurvedic App.

Conducts health assessment, provides diagnosis along with treatment planning and medication recommendation.

1. Overall Architecture:
    - RAG (Retrieval-Augmented Generation) architecture
    - Built with Langchain, Langgraph, and GoogleGenerativeAI (Gemini API)
    - Developed in Google Colab notebook for prototyping
    - Uses Qdrant vector database (pre-populated with Ayurvedic knowledge)
2. Agent System:
    - Two-agent workflow
    
    A. Agent 1: Triage and Interview
    
    - Conducts dynamic, realistic interview
    - Creates detailed report on current scenario
    - Does not provide diagnosis
    - Interview process:
        1. Asks user what brought them to the app
        2. For each user response:
            - Checks vector database for context
            - Considers entire chat history
            - Formulates next question based on retrieved information
        3. Repeats until a comprehensive, relevant report is generated
        4. Sends report to Agent 2
    
    B. Agent 2: Diagnostics and Treatment Planning
    
    - Receives report from Agent 1
    - Provides diagnosis
    - Develops treatment plan
    - Recommends medications
    - Uses vector database for Ayurvedic knowledge retrieval
3. Key Components:
    - GoogleGenerativeAI with Gemini API for natural language processing
    - Qdrant vector database for storing and retrieving Ayurvedic knowledge
    - Langchain for building the language model pipeline
    - Langgraph for managing the agent workflow
4. Workflow:
    1. User initiates interaction
    2. Agent 1 conducts interview and generates report
    3. Report is sent to Agent 2
    4. Agent 2 analyzes report and provides diagnosis, treatment plan, and medication recommendations
    5. Results are presented to the user
5. Development Environment:
    - Google Colab notebook for prototyping and development

To achieve a realistic interview, Agent 1 employs a dynamic and context-aware approach. Here's a detailed explanation of how this process works:

1. Initialization:
    - The agent starts with a broad, open-ended question like "What brings you here today?" or "How can I help you?"
    - This allows the user to express their concerns in their own words.
2. Active Listening and Context Building:
    - As the user responds, the agent processes the input and begins building a context model.
    - It identifies key terms, symptoms, or concerns mentioned by the user.
3. Vector Database Querying:
    - The agent queries the Qdrant vector database using the identified key terms and concepts.
    - This retrieves relevant Ayurvedic knowledge and potential follow-up questions.
4. Natural Language Understanding:
    - Using the Gemini API, the agent analyzes the user's response for sentiment, urgency, and implicit information.
5. Dynamic Question Formulation:
    - Based on the retrieved information and NLU analysis, the agent formulates the next question.
    - Questions are tailored to probe deeper into the user's specific concerns.
    - The agent avoids redundant questions by keeping track of information already provided.
6. Contextual Memory:
    - The agent maintains a running summary of the conversation, updating it with each exchange.
    - This allows for reference to previously mentioned information, making the conversation feel more natural and connected.
7. Empathetic Responses:
    - The agent is programmed to recognize emotional cues and respond with appropriate empathy.
    - It may use phrases like "I understand that must be difficult" or "It's good that you're seeking help for this."
8. Clarification and Expansion:
    - If the user's responses are vague or incomplete, the agent asks for clarification or more details.
    - It might say, "Could you tell me more about when you first noticed this symptom?"
9. Holistic Approach:
    - In line with Ayurvedic principles, the agent asks about various aspects of the user's life, including diet, sleep patterns, stress levels, and daily routines.
10. Adaptive Questioning:
    - The agent adjusts the complexity and depth of questions based on the user's responses and perceived health literacy.
11. Non-Linear Conversation Flow:
    - While the agent has certain key areas it needs to cover, it allows the conversation to flow naturally, following the user's lead when appropriate.
12. Time and Relevance Management:
    - The agent is programmed to keep the interview focused and relevant, gently steering the conversation back on track if it diverges too far.
13. Comprehensive Coverage:
    - The agent ensures all relevant areas are covered before concluding the interview.
    - It may use a checklist approach internally but presents questions in a conversational manner.
14. Conclusion and Handover:
    - Once sufficient information is gathered, the agent summarizes the key points of the interview.
    - It informs the user that it will now compile a report for further analysis.

By combining these elements, Agent 1 can conduct an interview that feels natural, responsive, and thorough, mimicking the approach of a skilled Ayurvedic practitioner. The use of AI and the vector database allows for a vast knowledge base to inform the questioning, while the natural language processing capabilities ensure a human-like interaction.

Let me elaborate on how the agent utilizes the entire chat context and continuously refers to the vector database to guide the interview process:

1. Continuous Context Update:
    - After each user response, the agent updates its understanding of the entire conversation context.
    - This context includes not just the latest response, but the cumulative information from the entire chat history.
2. Vector Database Querying:
    - With each context update, the agent formulates a query based on the entire conversation context.
    - This query is sent to the Qdrant vector database.
3. Relevant Information Retrieval:
    - The vector database returns the most relevant Ayurvedic knowledge, potential questions, and interview strategies based on the current context.
4. Dynamic Interview Path:
    - Using the retrieved information, the agent determines the most appropriate direction for the interview.
    - This could involve exploring a new area of concern, diving deeper into a previously mentioned issue, or shifting focus based on newly understood connections.
5. Adaptive Questioning Strategy:
    - The agent uses the vector database's suggestions to formulate questions that are most relevant to the user's specific situation.
    - This ensures that the interview doesn't follow a pre-determined script, but rather adapts in real-time to the user's unique health profile.
6. Contextual Understanding:
    - As the interview progresses, the agent builds a more comprehensive understanding of the user's health situation.
    - This understanding is continually refined with each database query and user response.
7. Holistic Approach Maintenance:
    - The vector database helps the agent maintain a holistic Ayurvedic approach by suggesting questions about different aspects of the user's life that may not be immediately obvious but are relevant in Ayurvedic practice.
8. Knowledge-Guided Probing:
    - When the user mentions symptoms or conditions, the agent queries the database for related Ayurvedic concepts.
    - This allows the agent to ask informed follow-up questions that a knowledgeable Ayurvedic practitioner would ask.
9. Conversation Flow Management:
    - The agent uses the database's input to manage the flow of the conversation, ensuring all relevant areas are covered while maintaining a natural dialogue.
10. Relevance Checking:
    - With each potential question, the agent cross-references with the vector database to ensure its relevance to the current context of the conversation.
11. Insight Generation:
    - As the interview progresses, the agent uses the database to generate insights about potential connections between different pieces of information provided by the user.
12. Interview Progression Tracking:
    - The agent tracks the progress of the interview against Ayurvedic diagnostic criteria stored in the vector database, ensuring comprehensive coverage.

By constantly referring to the vector database and considering the entire chat context, the agent can conduct a highly personalized, knowledge-driven interview that feels natural and adapts in real-time to the user's responses. This approach allows for a dynamic interview process that can uncover relevant health information even if the user doesn't initially present it, mimicking the intuitive and holistic approach of an experienced Ayurvedic practitioner.


This is the current code in my Google Colab Notebook that will give you an Idea of how far i have come ::

{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "gpuType": "T4",
      "authorship_tag": "ABX9TyPJ/eKpwYAoXZ3KpKnwjZQL",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/Phoenix-7Theta-Fi/AridWigglyTransformations/blob/main/2nd_October.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": true,
        "id": "By_dWE0HSeDP"
      },
      "outputs": [],
      "source": [
        "# Install required libraries\n",
        "!pip install langchain\n",
        "!pip install langchain-community\n",
        "!pip install -q langchain-google-genai langchain-qdrant qdrant-client\n",
        "!pip install protobuf==3.20.3"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# Required imports\n",
        "from langchain_google_genai import GoogleGenerativeAI\n",
        "import os\n",
        "import getpass\n",
        "\n",
        "# Set the Google API key\n",
        "if \"GOOGLE_API_KEY\" not in os.environ:\n",
        "    os.environ[\"GOOGLE_API_KEY\"] = \"AIzaSyCAkNL5AENDygdCFgx3E2ASH8n3tVeORHY\"\n",
        "\n",
        "# Initialize Google Generative AI (Gemini 1.5 Pro) for both Triage and Diagnostic agents\n",
        "triage_agent = GoogleGenerativeAI(model=\"gemini-1.5-pro\", google_api_key=os.environ[\"GOOGLE_API_KEY\"])\n",
        "diagnostic_agent = GoogleGenerativeAI(model=\"gemini-1.5-pro\", google_api_key=os.environ[\"GOOGLE_API_KEY\"])\n"
      ],
      "metadata": {
        "id": "WU627AaKTXik"
      },
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Required imports for Qdrant and Google embeddings\n",
        "from qdrant_client import QdrantClient\n",
        "from langchain_qdrant import QdrantVectorStore\n",
        "from langchain_google_genai import GoogleGenerativeAIEmbeddings\n",
        "import os\n",
        "\n",
        "# Set the Google API key and Qdrant API key directly from the provided credentials\n",
        "os.environ[\"GOOGLE_API_KEY\"] = \"AIzaSyCAkNL5AENDygdCFgx3E2ASH8n3tVeORHY\"  # Provided Google API key\n",
        "\n",
        "QDRANT_API_KEY = \"Zuve0HmtPgefnl5zHWf6GSmh1IM1hasHqdeqIG_0ujUxjXq0G1Jq3Q\"\n",
        "QDRANT_URL = \"https://229b929d-06ae-4ee8-83f0-5d7bee918989.europe-west3-0.gcp.cloud.qdrant.io\"  # Provided Qdrant URL\n",
        "\n",
        "# Initialize Qdrant client using the cloud URL and API key\n",
        "client = QdrantClient(url=QDRANT_URL, api_key=QDRANT_API_KEY)\n",
        "\n",
        "# Initialize Google Generative AI Embeddings model for vectorization\n",
        "embeddings = GoogleGenerativeAIEmbeddings(model=\"models/embedding-001\")\n",
        "\n",
        "# Use the existing \"ayurveda_collection\" in Qdrant\n",
        "vector_store = QdrantVectorStore(\n",
        "    client=client,\n",
        "    collection_name=\"ayurveda_collection\",  # Provided collection name\n",
        "    embedding=embeddings,  # Embedding model for semantic search\n",
        ")\n"
      ],
      "metadata": {
        "id": "4jtE5hpSUuJe"
      },
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from langchain.memory import ConversationBufferMemory\n",
        "\n",
        "# Initialize conversation buffer for managing consultation context\n",
        "conversation_memory = ConversationBufferMemory()\n"
      ],
      "metadata": {
        "id": "qfocpCZmVh_G"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Import necessary modules\n",
        "from langchain.chains import LLMChain\n",
        "from langchain.prompts import ChatPromptTemplate\n",
        "from langchain.memory import ConversationBufferMemory\n",
        "\n",
        "# Initialize conversation buffer for managing consultation context\n",
        "conversation_memory = ConversationBufferMemory(memory_key=\"chat_history\", return_messages=True)\n",
        "\n",
        "# Define the system message template for the Triage Agent\n",
        "triage_system_prompt = \"\"\"\n",
        "You are an Ayurvedic health assistant conducting an interview to gather a comprehensive health history.\n",
        "Ask questions to assess the user's health concerns, symptoms, lifestyle, and other relevant Ayurvedic health factors.\n",
        "Formulate the next question based on the user's previous answers, and avoid repetition.\n",
        "\n",
        "You can ask about:\n",
        "- The reason for visiting\n",
        "- Current symptoms\n",
        "- Lifestyle habits (diet, sleep, stress levels)\n",
        "- Ayurvedic Dosha imbalances (if relevant)\n",
        "- Medical history (Ayurvedic or general)\n",
        "\"\"\"\n",
        "\n",
        "# Define the conversation prompt\n",
        "triage_prompt = ChatPromptTemplate.from_messages([\n",
        "    (\"system\", triage_system_prompt),\n",
        "    (\"human\", \"{input}\")\n",
        "])\n",
        "\n",
        "# Use LLMChain to replace ConversationChain and handle interaction\n",
        "triage_agent_chain = LLMChain(\n",
        "    llm=triage_agent,  # Your initialized GoogleGenerativeAI (Gemini) model\n",
        "    prompt=triage_prompt,\n",
        "    memory=conversation_memory,\n",
        "    verbose=True\n",
        ")\n"
      ],
      "metadata": {
        "id": "qgBGrr9GHnC4"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Function to conduct the interview with the user and generate report when ready\n",
        "def conduct_interview_and_generate_report(triage_agent_chain, vector_store, max_questions=15):\n",
        "    print(\"Welcome to the Ayurvedic Health Assessment. Let's start with a few questions.\")\n",
        "\n",
        "    for i in range(max_questions):\n",
        "        # Ask the user the next question generated by the AI\n",
        "        user_input = input(f\"User [{i+1}]: \")  # Simulate user input, in a real app this would be dynamic user input\n",
        "        response = triage_agent_chain.run(input=user_input)  # Ensure input structure is correct\n",
        "\n",
        "        # Optionally, retrieve relevant Ayurvedic knowledge using Qdrant\n",
        "        retrieved_info = vector_store.similarity_search_with_score(user_input)\n",
        "\n",
        "        # Print the agent's response (the next question or follow-up)\n",
        "        print(f\"Agent [{i+1}]: {response}\")\n",
        "\n",
        "        # Optionally, show the relevant Ayurvedic knowledge for user info\n",
        "        if retrieved_info:\n",
        "            print(f\"Relevant Ayurvedic Insight: {retrieved_info[0][0].page_content}\")\n",
        "\n",
        "        # The agent checks if it's ready to generate the report\n",
        "        if \"Is there anything else you'd like to add?\" in response or \"Do you feel like we've covered everything?\" in response:\n",
        "            user_confirmation = input(\"User [confirmation]: \").lower()\n",
        "\n",
        "            if user_confirmation in [\"yes\", \"y\", \"that's everything\", \"i'm done\"]:\n",
        "                print(\"\\nGenerating report based on the gathered information...\\n\")\n",
        "\n",
        "                # Generate and display the report\n",
        "                report = generate_report(triage_agent_chain.memory)\n",
        "                print(report)\n",
        "                return report  # Return report for use in Agent 2\n",
        "\n",
        "            # If the user says there's more to add, the loop continues for additional questions.\n",
        "            print(\"Okay, let's continue with the assessment.\")\n",
        "\n",
        "    # If the max_questions is reached, the agent concludes the interview.\n",
        "    print(\"\\nMax number of questions reached. Generating report...\\n\")\n",
        "    report = generate_report(triage_agent_chain.memory)\n",
        "    print(report)\n",
        "    return report\n",
        "\n",
        "# Helper function to generate the report based on the conversation history\n",
        "def generate_report(memory):\n",
        "    # Retrieve the chat history (memory of the conversation)\n",
        "    chat_history = memory.load_memory_variables({})[\"chat_history\"]\n",
        "\n",
        "    # Generate a simple report summary from the chat history\n",
        "    report = \"\\n\".join([f\"{msg['role'].capitalize()}: {msg['content']}\" for msg in chat_history])\n",
        "\n",
        "    return f\"\\nHere is a summary of your health assessment:\\n\\n{report}\"\n",
        "\n",
        "# Start the interview and generate the report when the agent and user agree\n",
        "report = conduct_interview_and_generate_report(triage_agent_chain, vector_store)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "XkgMBDSvJyyo",
        "outputId": "43399883-b824-4b16-b32c-2b5c4107b40b"
      },
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Welcome to the Ayurvedic Health Assessment. Let's start with a few questions.\n",
            "User [1]: head ache and nausea\n",
            "\n",
            "\n",
            "\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
            "Prompt after formatting:\n",
            "\u001b[32;1m\u001b[1;3mSystem: \n",
            "You are an Ayurvedic health assistant conducting an interview to gather a comprehensive health history.\n",
            "Ask questions to assess the user's health concerns, symptoms, lifestyle, and other relevant Ayurvedic health factors.\n",
            "Formulate the next question based on the user's previous answers, and avoid repetition.\n",
            "\n",
            "You can ask about:\n",
            "- The reason for visiting\n",
            "- Current symptoms\n",
            "- Lifestyle habits (diet, sleep, stress levels)\n",
            "- Ayurvedic Dosha imbalances (if relevant)\n",
            "- Medical history (Ayurvedic or general)\n",
            "\n",
            "Human: head ache and nausea\u001b[0m\n",
            "\n",
            "\u001b[1m> Finished chain.\u001b[0m\n",
            "Agent [1]: I understand you're experiencing headaches and nausea. To help me understand your concerns better, could you tell me when these symptoms started and how often they occur? For example, are they constant, intermittent, or triggered by something specific? \n",
            "\n",
            "Relevant Ayurvedic Insight: aching head pain; a feeling of hot coals on the scalp;burning vapor from nostrils (diminishes at night or when\n",
            "applying cold packs to the head).\n",
            "Kapha: Headaches; a sticky mucus-coated palate and\n",
            "User [2]: after meals\n",
            "\n",
            "\n",
            "\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
            "Prompt after formatting:\n",
            "\u001b[32;1m\u001b[1;3mSystem: \n",
            "You are an Ayurvedic health assistant conducting an interview to gather a comprehensive health history.\n",
            "Ask questions to assess the user's health concerns, symptoms, lifestyle, and other relevant Ayurvedic health factors.\n",
            "Formulate the next question based on the user's previous answers, and avoid repetition.\n",
            "\n",
            "You can ask about:\n",
            "- The reason for visiting\n",
            "- Current symptoms\n",
            "- Lifestyle habits (diet, sleep, stress levels)\n",
            "- Ayurvedic Dosha imbalances (if relevant)\n",
            "- Medical history (Ayurvedic or general)\n",
            "\n",
            "Human: after meals\u001b[0m\n",
            "\n",
            "\u001b[1m> Finished chain.\u001b[0m\n",
            "Agent [2]: After meals, do you experience any particular digestive discomfort? For example, do you feel bloated, gassy, or sluggish? \n",
            "\n",
            "Relevant Ayurvedic Insight: commented\tthat\tbecause\tof\tthe\tsatisfying\tmeal\tat\tmidday\tthey\twere\table\tto\tforgo\n",
            "any\tin-between\tmeals\tor\tsnacks.\n",
            "Except\tin\tsummer\tor\tin\tvery\thot\tclimates,\tone\tshould\teat\tdinner\tbefore\t7\tp.m.\n",
            "User [3]: sluggish\n",
            "\n",
            "\n",
            "\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
            "Prompt after formatting:\n",
            "\u001b[32;1m\u001b[1;3mSystem: \n",
            "You are an Ayurvedic health assistant conducting an interview to gather a comprehensive health history.\n",
            "Ask questions to assess the user's health concerns, symptoms, lifestyle, and other relevant Ayurvedic health factors.\n",
            "Formulate the next question based on the user's previous answers, and avoid repetition.\n",
            "\n",
            "You can ask about:\n",
            "- The reason for visiting\n",
            "- Current symptoms\n",
            "- Lifestyle habits (diet, sleep, stress levels)\n",
            "- Ayurvedic Dosha imbalances (if relevant)\n",
            "- Medical history (Ayurvedic or general)\n",
            "\n",
            "Human: sluggish\u001b[0m\n",
            "\n",
            "\u001b[1m> Finished chain.\u001b[0m\n",
            "Agent [3]: That's helpful to know. Could you tell me more about what you mean by feeling sluggish? Is it a lack of energy, motivation, or something else? \n",
            "\n",
            "Relevant Ayurvedic Insight: grounded; deep heavy voice\n",
            "Slow/Dull slow walk, talk; slow digestion, metabolism; sluggish gestures\n",
            "Cool (Cold) cold clammy skin; steady appetite and thirst with slow metabolism and  \n",
            "digestion; repeated cold, congestion and cough\n",
            "User [4]: lack of energy\n",
            "\n",
            "\n",
            "\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
            "Prompt after formatting:\n",
            "\u001b[32;1m\u001b[1;3mSystem: \n",
            "You are an Ayurvedic health assistant conducting an interview to gather a comprehensive health history.\n",
            "Ask questions to assess the user's health concerns, symptoms, lifestyle, and other relevant Ayurvedic health factors.\n",
            "Formulate the next question based on the user's previous answers, and avoid repetition.\n",
            "\n",
            "You can ask about:\n",
            "- The reason for visiting\n",
            "- Current symptoms\n",
            "- Lifestyle habits (diet, sleep, stress levels)\n",
            "- Ayurvedic Dosha imbalances (if relevant)\n",
            "- Medical history (Ayurvedic or general)\n",
            "\n",
            "Human: lack of energy\u001b[0m\n",
            "\n",
            "\u001b[1m> Finished chain.\u001b[0m\n",
            "Agent [4]: I understand you're experiencing a lack of energy. Could you tell me more about when you started feeling this way and how it affects your daily life? \n",
            "\n",
            "Relevant Ayurvedic Insight: gradual loss of strength, energy, motor and sensory organs;\n",
            "poor nutritio n, physical exertion, and mental exhaustion.\n",
            "This results in depleted tissues, debilitation, poor\n",
            "comple xion, and poor r esistance to disease.\n",
            "User [5]: 4 days ago\n",
            "\n",
            "\n",
            "\u001b[1m> Entering new LLMChain chain...\u001b[0m\n",
            "Prompt after formatting:\n",
            "\u001b[32;1m\u001b[1;3mSystem: \n",
            "You are an Ayurvedic health assistant conducting an interview to gather a comprehensive health history.\n",
            "Ask questions to assess the user's health concerns, symptoms, lifestyle, and other relevant Ayurvedic health factors.\n",
            "Formulate the next question based on the user's previous answers, and avoid repetition.\n",
            "\n",
            "You can ask about:\n",
            "- The reason for visiting\n",
            "- Current symptoms\n",
            "- Lifestyle habits (diet, sleep, stress levels)\n",
            "- Ayurvedic Dosha imbalances (if relevant)\n",
            "- Medical history (Ayurvedic or general)\n",
            "\n",
            "Human: 4 days ago\u001b[0m\n",
            "\n",
            "\u001b[1m> Finished chain.\u001b[0m\n",
            "Agent [5]: Please tell me, what brings you in today? What are your main health concerns at the moment? \n",
            "\n",
            "Relevant Ayurvedic Insight: methods\tor\tan\tAyurvedic\n",
            "\t\n",
            "therapy\tcould\n",
            "not\tbe\tperformed\tas\tthe\tcondition\tof\tthe\tpatients\tdid\tnot\tallow\tit.\n",
            "•\tTreatment\tin\tour\tpractice\tis\tgiven\tMonday\tto\tSaturday.\tTherefore,\tday\tone\n"
          ]
        },
        {
          "output_type": "error",
          "ename": "KeyboardInterrupt",
          "evalue": "Interrupted by user",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-14-c82c78e249e9>\u001b[0m in \u001b[0;36m<cell line: 52>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     50\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     51\u001b[0m \u001b[0;31m# Start the interview and generate the report when the agent and user agree\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 52\u001b[0;31m \u001b[0mreport\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mconduct_interview_and_generate_report\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtriage_agent_chain\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvector_store\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
            "\u001b[0;32m<ipython-input-14-c82c78e249e9>\u001b[0m in \u001b[0;36mconduct_interview_and_generate_report\u001b[0;34m(triage_agent_chain, vector_store, max_questions)\u001b[0m\n\u001b[1;32m      5\u001b[0m     \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmax_questions\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      6\u001b[0m         \u001b[0;31m# Ask the user the next question generated by the AI\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m         \u001b[0muser_input\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"User [{i+1}]: \"\u001b[0m\u001b[0;34m)\u001b[0m  \u001b[0;31m# Simulate user input, in a real app this would be dynamic user input\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      8\u001b[0m         \u001b[0mresponse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtriage_agent_chain\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0muser_input\u001b[0m\u001b[0;34m)\u001b[0m  \u001b[0;31m# Ensure input structure is correct\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      9\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[0;34m(self, prompt)\u001b[0m\n\u001b[1;32m    849\u001b[0m                 \u001b[0;34m\"raw_input was called, but this frontend does not support input requests.\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    850\u001b[0m             )\n\u001b[0;32m--> 851\u001b[0;31m         return self._input_request(str(prompt),\n\u001b[0m\u001b[1;32m    852\u001b[0m             \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    853\u001b[0m             \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;32m/usr/local/lib/python3.10/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m    893\u001b[0m             \u001b[0;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    894\u001b[0m                 \u001b[0;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 895\u001b[0;31m                 \u001b[0;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Interrupted by user\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    896\u001b[0m             \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    897\u001b[0m                 \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Invalid Message:\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mKeyboardInterrupt\u001b[0m: Interrupted by user"
          ]
        }
      ]
    }
  ]
}