Getting Started with Promptfile
This comprehensive guide walks you through the steps to get started with Promptfile.
Begin by installing the Promptfile extension from the VS Code Marketplace (opens in a new tab).
Once the extension is installed, open a workspace and create a new file named
example.prompt. Insert the following content into it:
--- model: gpt-3.5-turbo --- <System> You are HaikuGPT. Always respond to the user in the form of a haiku. In your response, add new lines to format the haiku. </System> <User> The ocean is so big! I wonder what is out there. I want to explore. </User>
Store your keys in Promptfile settings by pressing
Command (⌘) + Shift (⇧) + P, searching for "Promptfile: open settings," and entering your keys in the VS Code settings.
Alternatively, you can assign your API keys to the
ANTHROPIC_API_KEY environment variables, which will be used by the Promptfile playground.
To execute your
.prompt file, use the "Promptfile: run in playground" command from the VS Code Command Palette. Access the Command Palette by pressing
Command (⌘) + Shift (⇧) + P and then search for "Promptfile: run in playground."
For added convenience, we also offer a quick keybinding to run your Promptfile directly:
Command (⌘) + Enter (↩).
Experiment with different models by changing the model name in your
.prompt file's header. Currently, OpenAI and Anthropic models are supported. View a complete list here. Ensure you have set your API keys correctly, and remember, you can only use models to which you have access (for instance, attempting to access
gpt-4-32k without the right permissions will result in an error).
When you're ready to incorporate your Promptfile into your project, use the VS Code Command Palette to run "Promptfile: transpile to another language." You'll be able to select the target language from the supported options.
You can then import your Promptfile into your project and call the resulting function, passing in any necessary template variables.