Best Practices
Tips and examples for writing effective prompts in Latitude.
Writing effective prompts is key to getting the best results from AI models. Here are some best practices and examples specific to working within the Latitude platform.
General Best Practices
-
Be Specific and Clear: Avoid ambiguity. Clearly state the task, desired format, context, and constraints.
- Bad: “Write about Latitude.”
- Good: “Write a 3-paragraph introduction to Latitude for a non-technical audience, highlighting its key benefits for prompt management and evaluation.”
-
Provide Context: Give the model relevant background information it might need.
- Example: If asking for a summary of a meeting, provide the meeting transcript or key discussion points.
-
Define the Persona/Role: Tell the model who it should be.
- Example:
<system>You are a helpful and friendly customer support agent for a SaaS company.</system>
- Example:
-
Specify the Output Format: Use instructions or JSON Schema to guide the format.
- Example: “Provide the answer as a JSON object with keys ‘pros’ and ‘cons’, each containing a list of strings.”
- Example: Use the
schema
configuration for reliable JSON.
-
Use Examples (Few-Shot Prompting): Provide examples of desired input/output pairs within the prompt.
-
Iterate and Test: Use the Playground extensively. Start simple and gradually add complexity. Test with various inputs.
-
Break Down Complex Tasks: Use Chains or Agents for multi-step processes rather than trying to do everything in one giant prompt.
Latitude-Specific Tips
- Leverage PromptL: Use variables (
{{ }}
), conditionals (<if>
), loops (<for>
), and snippets (<prompt path="...">
) for dynamic and reusable prompts. See the PromptL documentation. - Use Configuration Wisely: Tune
temperature
,maxTokens
, etc., in the configuration block for desired output style and length. - Utilize Tools: Don’t make the model guess information it can look up. Provide Tools for accessing external data or functions (e.g.,
latitude/search
for web searches). - Employ Agents for Autonomy: For tasks requiring planning and dynamic tool use, define your prompt as an Agent.
- Manage Versions: Use Version Control to track changes and collaborate safely.
- Evaluate Systematically: Use Evaluations to measure prompt quality and identify areas for improvement.
Example: Customer Support Email Generator
This example demonstrates:
- Persona setting (
<system>
). - Using input parameters (
{{ customer_email }}
,{{ customer_query }}
). - Defining and enabling a custom tool (
get_customer_details
). - Enforcing structured output (
schema
). - Clear instructions within the system message.