Skip to main content

How to test local prompts?

Local prompt testing allows you to evaluate custom prompt implementations using the Yields Output function. This approach is ideal when you want to test your own prompt logic, integrate with specific LLM providers, or implement complex prompt workflows.

Basic Local Prompt Testing

Use the Yields Output function to define custom prompt logic that will be executed for each test case:

Advanced Prompt Testing with Context

You can also test prompts that use additional context or implement RAG (Retrieval-Augmented Generation):

Best Practices

  1. Error Handling: Always include proper error handling in your Yields Output function
  2. Token Tracking: Include usage and cost metadata when possible for better insights
  3. Context Management: Use Retrieved Context to Evaluate when evaluating prompts that use RAG systems

Example Repository

For more complex examples including multi-turn conversations and advanced RAG implementations, check out our cookbooks repository for python or typescript.

Next Steps