Skip to content

3.2: Customize To App

ITERATION STEP 0: Let's fix the error and customize the defaults!

1. Create chat-0.prompty

Our final Contoso Chat application is called chat.prompty.

Let's reflect that by copying over the basic.prompty to a starter asset called chat-0.prompty. We can then bump up the version number with each step to get an intuitive sense of the iterative nature of prompt engineering.

Make sure you are in the sandbox/ folder - then run this command!

cp basic.prompty chat-0.prompty

Open or reload the chat-0.prompty file in your editor!


2. Before → Identify Fixes

Look at the file contents (below). Let's identify the fixes to make in this iteration:

  • Update App Metadata: Lines 2-5 should describe the application and developer details.
  • Update Model Config: Line 11 should replace <your-deployment> with a model name.
  • Remove Context Lines 17-22 provide sample context that is irrelevant to our app.
  • Remove Usage Also remove Lines 35-37 since the context variable no longer exists.

chat-0.prompty (before)

 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. After → Apply Fixes

  1. For convenience, we've got staged versions that have these fixes completed. Let's copy that over.

    cp ../docs/workshop/src/1-build/chat-0.prompty .
    
  2. This is what our first iteration looks like. Let's run this next to validate the fixes.

    chat-0.prompty (after)

     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
    ---
    name: Contoso Chat Prompt
    description: A retail assistant for Contoso Outdoors products retailer.
    authors:
        - Nitya Narasimhan
    model:
        api: chat
        configuration:
            type: azure_openai
            azure_deployment: gpt-4o-mini
            azure_endpoint: ${ENV:AZURE_OPENAI_ENDPOINT}
            api_version: 2024-08-01-preview
        parameters:
            max_tokens: 3000
    sample:
        firstName: Nitya
        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.
    
    # user
    {{question}}
    

4. Run The Prompty

  1. Reload chat-0.prompty in the VS Code editor to refresh it.
  2. Run the refreshed prompty (using the play icon or by clicking F5)

    You should see a valid response (like this) in the Visual Studio Code terminal

    Hello Nitya! 😊
    
    I can’t provide details about a specific company’s tents, but generally, tents come in various types including:
    
    - **Dome Tents:** Great for easy setup and stability.
    - **Backpacking Tents:** Lightweight and compact for hiking.
    - **Family Tents:** Spacious with room for multiple people.
    - **Pop-Up Tents:** Quick to pitch, perfect for casual outings.
    
    They vary by material, weather resistance, and features like vestibules or built-in storage. If you’re looking for something specific, let me know! 🏕️✨
    

Note: Generative AI models are stochastic, meaning that the same query will not always generate the same response. Your output may look different - but this validates that the previous error is fixed.


CONGRATULATIONS. You have a functioning prompt asset!