Overview

Snippets are reusable pieces of prompt content that you can reference in other prompts. They allow you to modularize your prompts, making them easier to manage and maintain.

How to Use Snippets

To use a snippet in your prompt, you can use the <prompt> tag. Here’s the basic syntax:

<prompt path="snippet_name" />

Replace “snippet_name” with the name of the prompt you want to include.

Creating Snippets

To create a snippet you just need to create a prompt:

  1. Create a new prompt in your project.
  2. Write the content you want to reuse.
  3. Save the prompt with a descriptive name.
  4. You can now reference this prompt as a snippet in other prompts.

Benefits of Using Snippets

  1. Reusability: Write once, use many times.
  2. Consistency: Ensure the same content is used across multiple prompts.
  3. Maintainability: Update the snippet in one place to affect all prompts that use it.
  4. Organization: Break down complex prompts into smaller, manageable pieces.

Example Usage

Here’s an example of how you might use snippets:

greeting prompt
Hello! Welcome to our customer service.
starter message prompt
<prompt path="greeting" />
How can I assist you today?
output
Hello! Welcome to our customer service.
How can I assist you today?

When you use this main prompt, the <prompt> tag will be replaced with the content of the “greeting” snippet.

Nesting Snippets

You can nest snippets within other snippets.

Considerations

  • Be mindful of the total length of your prompt after all snippets are resolved, as there may be model-specific token limits.
  • By using snippets effectively, you can create more maintainable, consistent, and flexible prompts in your Latitude projects.
  • Use meaningful names for your snippets to make them easy to identify.
  • Keep snippets focused on a single purpose or topic.