Skip to content

3.1 Create a New Prompty

Prompty is an open-source project from Microsoft that provides a new asset class (.prompty) for LLM prompts, with an emphasis on observability, portability, and understandability. The Prompty Specification describe the asset format and functionality in more detail.

The Prompty Extension for VS Code simplifies the creation, configuration, and execution, of Prompty assets - bringing the playground experience right into your editor. You can modify template paramters, model configuration, system context and instructions - then execute then with a sample input right in VS Code to view the generated response.


IDEATE WITH PROMPTY - LEARNING OBJECTIVES

The Contoso Chat repository defines the chat AI prompt asset in src/api/contoso_chat/chat.prompty. This is the final version of the prompt asset used in the production deployment.

In this section we'll start from scratch and build our .prompty asset iteratively, till we get close to that final version. The goal is to give you an intuitive sense for prompt engineering using the Prompty asset and tooling. To keep this separate from the final version, we'll do our ideation steps in a new sandbox/ folder.


1. Create Sandbox Folder

  1. Return to the GitHub Codespaces tab and open the VS Code terminal.
  2. Create an empty directory in root of your filesytem. From the Terminal:

    1
    mkdir sandbox
    
    1. Switch to the new directory

    1
    cd sandbox
    

2. Create New Prompty

  1. The VS Code Extension makes this easy.
    • Find the sandbox folder in the File explorer sidebar.
    • Right-click on the folder name to get the drop-down menu
    • Select the New Prompty option (at the bottom of drop-down)
  2. You should see a basic.prompty file that looks like this:

    The basic.prompty asset

    basic.prompty
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    ---
    name: ExamplePrompt
    description: A prompt that uses context to ground an incoming question
    authors:
    - Seth Juarez
    model:
    api: chat
    configuration:
        type: azure_openai
        azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
        azure_deployment: <your-deployment>
        api_version: 2024-07-01-preview
    parameters:
        max_tokens: 3000
    sample:
    firstName: Seth
    context: >
        The Alpine Explorer Tent boasts a detachable divider for privacy, 
        numerous mesh windows and adjustable vents for ventilation, and 
        a waterproof design. It even has a built-in gear loft for storing 
        your outdoor essentials. In short, it's a blend of privacy, comfort, 
        and convenience, making it your second home in the heart of nature!
    question: What can you tell me about your tents?
    ---
    
    system:
    You are an AI assistant who helps people find information. As the assistant, 
    you answer questions briefly, succinctly, and in a personable manner using 
    markdown and even add some personal flair with appropriate emojis.
    
    # Customer
    You are helping {{firstName}} to find answers to their questions.
    Use their name to address them in your responses.
    
    # Context
    Use the following context to provide a more personalized response to {{firstName}}:
    {{context}}
    
    user:
    {{question}}
    

3. Run The Prompty

NOTE: This step will fail with an error. Don't worry, that's expected.

  1. Open the basic.prompty file in the VS Code editor.
  2. Click the play icon seen at top-right corner (or press F5).
  3. You will be prompted to sign in as shown below. Click Allow.

    The extension 'Prompty' wants to sign in using Microsoft.

  4. Select your Azure account when prompted in the dialog.

  5. This will complete the run process.
  6. RESULT:
    • Your Visual Studio Code terminal will switch to the "Output" tab and show this error:
    • ❌ | Error: 404 The API deployment for this resource does not exist.

We can see from the prompty code (line 11) that the azure-deployment property value has a placeholder that needs to be updated. Let's fix that, next!


CONGRATULATIONS. You created and ran your first Prompty!