3.1 Create a New Prompty¶
The GitHub Codespaces environment is preconfigured with Prompty tooling to help us create, convert, and run, Prompty assets. Let's start by creating an empty sandbox/ folder to start our ideation from scratch.
1. Create Sandbox Folder¶
- Open the VS Code terminal in GitHub Codespaces.
- Run this command to create a new empty sandbox folder:
mkdir sandbox
- Change to the directory in the terminal.
cd sandbox
2. Create New Prompty¶
As described earlier Prompty is an asset format (.prompty
) that contains the prompt template (content) and model configuration metadata (frontmatter) in a single language-agnostic file! The Prompty runtime (built into VS Code) executes the asset by rendering the template (using the sample data) and invoking the configured model with this enhanced prompt - allowing you to test and iterate rapidly to ideate your application. Explore Prompty documentation for more details.
- Open the VS Code "File Explorer" view and locate the
sandbox/
folder -
Click on it to get a dropdown menu - look for the
New Prompty
option shown -
Click on it - this creates a
basic.prompty
file and opens it in VS Code
3. Explore Prompty Asset¶
-
View the
basic.prompty
asset in your VS Code Editor.(Click to expand) The starter Prompty asset looks like this:
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}}
-
You will observe the following:
- The asset uses a YAML format with frontmatter (top) and content (bottom)
- The frontmatter has app metadata, model parameters, and sample data
- The template has a system message, user question, context and instructions
Note how the asset captures all the elements typically found in a model playground, for prompt engineering. All we need is a runtime to execute the prompt by invoking the model.
4. Run The Prompty¶
The Prompty extension provides a built-in runtime we can use for this purpose. Let's try it!
- Open the
basic.prompty
file in the VS Code editor. - Click the play icon seen at top-right corner (or press F5).
-
You will be prompted to sign into Azure as shown. Click
Allow
. -
Complete the auth flow. This allows Prompty to invoke the Azure-deployed model.
-
Prompty executes the request and displays response in the VS Code Terminal.
NOTE: This step will fail with an error. Don't worry, that's expected.
Your Visual Studio Code terminal will switch to the "Output" tab and display this message:
❌ |
Error: 404 The API deployment for this resource does not exist.
We'll debug this error - and start our first iteration of this ideation process, next!
CONGRATULATIONS. You created and ran your first Prompty!