Overview

This exercise demonstrates how to use the Azure AI Foundry portal’s prompt flow to build a custom chat app. The app leverages a generative AI model (via Azure OpenAI’s GPT-4 variant) to manage conversation by taking a user’s question and the chat history as inputs and generating an answer. The work is divided into several setup and deployment phases.


Step-by-Step Summary

  1. Create an Azure AI Foundry Hub and Project

    • Process:
      Access the Azure AI Foundry portal at https://ai.azure.com and create a new hub project.

    • Configuration Items:

      • Subscription: Your Azure subscription.
      • Resource Group: Create or select an existing resource group.
      • Hub Name: A valid name for your hub.
      • Location: Example values include East US 2 or Sweden Central.

      These items must be provided in the project wizard when creating the project.

  2. Configure Resource Authorization

    • Process:
      Use the Azure portal (https://portal.azure.com) to modify the Azure AI Foundry resource’s identity settings. Turn on the system-assigned identity and grant it the Storage Blob Data Reader role on the associated storage account.

    • Purpose:
      This step ensures that the prompt flow tools can access file-based assets stored in blob storage.

  3. Deploy a Generative AI Model

    • Process:
      In the Azure AI Foundry portal under My AssetsModels + endpoints, select “Deploy base model” and search for the gpt-4o model.

    • Configuration Settings:

      • Deployment Name: A user-supplied valid name.
      • Deployment Type: Global Standard.
      • Automatic Version Update: Enabled.
      • Model Version: Use the most recent available version.
      • Connected AI Resource: Your Azure OpenAI resource connection.
      • Tokens per Minute (TPM) Rate Limit: 50K (or the maximum available in your subscription).
      • Content Filter: DefaultV2.

      These settings ensure that your deployed model is correctly connected and rate-limited for the exercise workload.

  4. Create a Prompt Flow

    • Process:
      In the portal’s navigation, select Prompt flow (under the Build and customize section) and create a new flow using the Chat flow template. Name the folder (for example, Travel-Chat) to group the assets.

    • Flow Structure:

      • Inputs:
        Two inputs are defined:

        • question (a string input)
        • chat_history (a string input)

        Placeholders:
        In the Inputs for the Chat LLM tool, these are defined as:

        question (string): ${inputs.question}
        chat_history (string): ${inputs.chat_history}
        
      • Outputs:
        An output variable is set up to capture the model’s answer.

    • Chat LLM Tool Configuration:
      Within the Chat LLM tool:

      • Connection:
        Select the connection for your Azure OpenAI service.
      • Properties:
        • Api: set to chat.
        • deployment_name: should point to the deployed gpt-4o model (this is a placeholder that you replace with the deployment name).
        • response_format: set as follows:
          {"type": "text"}
          
    • Prompt Field Modification:
      Update the Prompt field with a system message that instructs the model in the role of a travel agent. Here’s the code snippet:

      # system: **Objective**: Assist users with travel-related inquiries, offering tips, advice, and recommendations as a knowledgeable travel agent.
      **Capabilities**:
      - Provide up-to-date travel information, including destinations, accommodations, transportation, and local attractions.
      - Offer personalized travel suggestions based on user preferences, budget, and travel dates.
      - Share tips on packing, safety, and navigating travel disruptions.
      - Help with itinerary planning, including optimal routes and must-see landmarks.
      - Answer common travel questions and provide solutions to potential travel issues.
      **Instructions**:
      1. Engage with the user in a friendly and professional manner, as a travel agent would.
      2. Use available resources to provide accurate and relevant travel information.
      3. Tailor responses to the user's specific travel needs and interests.
      4. Ensure recommendations are practical and consider the user's safety and comfort.
      5. Encourage the user to ask follow-up questions for further assistance.
      
      # user: Read the prompt you added so you are familiar with it. It consists of a system message (which includes an objective, a definition of its capabilities, and some instructions), and the chat history (ordered to show each user question input and each previous assistant answer output)
      

      This snippet is critical as it sets the context for every conversation.

  5. Test and Deploy the Flow

    • Testing:
      Use the chat pane to issue sample questions (e.g., I have one day in London, what should I do?) and verify the response.

    • Deployment Settings:
      When deploying, configure:

      • Endpoint: Create a New Endpoint with a unique name.
      • Deployment Name: A unique name (placeholder to be replaced by a user-defined value).
      • Virtual Machine: Standard_DS3_v2.
      • Instance Count: 1.
      • Inferencing Data Collection: Disabled.
      • Advanced Settings: Use the default values.
    • Post-Deployment:
      After deployment, the Consume page will show connection details and sample code for a client application integration.

  6. Clean Up

    • Process:
      When done, delete the Azure resources (usually by deleting the resource group through the Azure portal) to avoid unwanted charges.

This summary captures the core procedure while clearly highlighting placeholders (e.g., ${inputs.question}, ${inputs.chat_history}, and deployment names) and configuration items required in each step of the setup and deployment process.

Related Posts