Quick Start
Learn how to install and use PromptL in your project
Overview
PromptL simplifies the process of creating and managing prompts for large language models (LLMs). This quick start guide will show you how to set up PromptL in your project and generate dynamic prompts with minimal effort.
Prerequisites: Ensure you have Node.js installed and access to an LLM provider like OpenAI or Anthropic.
Installation
Install PromptL via npm:
You’ll also need the library for your LLM provider.
Basic Usage
Here’s how to use PromptL to generate a dynamic prompt and interact with an LLM:
Different providers will require a different setup and structure. Check out the Adapters section for more information on how to integrate with your provider.
Example Code
How It Works:
- Prompt Definition: The
prompt
variable defines the PromptL prompt, including configuration and template syntax. - Dynamic Parameters: The
parameters
object passes the valuetopic: 'chickens'
to replace{{ topic }}
in the prompt. - Rendering: The
render
function processes the prompt and generates themessages
array andconfig
object for your LLM provider. - LLM Interaction: The OpenAI client sends the
messages
andconfig
to the model, generating a response.
Advanced Example: Error Handling
For production environments, add error handling to manage unexpected issues:
Next Steps
Once you’ve set up PromptL, explore its advanced features:
- Syntax and Variables: Learn how to define dynamic variables in your prompts.
- Chains and Steps: Break down complex tasks into multi-step prompts.
- Prompt References: Reuse common prompt components across your project.
Summary
PromptL makes it easy to create and manage dynamic prompts for LLMs. By following this guide, you’ve set up PromptL, generated a dynamic prompt, and integrated it with an LLM provider. Now, you’re ready to explore its full potential.