Getting Started

Building a Prompt

How to build a prompt that incorporates Zep's memory artifacts.

Zep’s artifacts, such as Facts, Summaries, and Chat History, can be included in your prompts to augment the LLM’s understanding of the conversation between the user and assistant. Typically, you’d use a Chat API and structure your prompts as a series of messages: System, User, Assistant, etc.

Prompt structures vary by model. Review your LLM Provider’s documentation for supported Message Types and best practices.
MessageTypeContent
SystemYour system prompt. Include Zep artifacts such as relevant {facts} and the most recent {summary} generated prior to the historical dialog below.
AssistantAn assistant message stored in Zep
UserA user message stored in Zep
AssistantAn assistant message stored in Zep
UserA user message stored in Zep
AssistantAn assistant message stored in Zep
UserThe latest user message

In the above example, we’re injecting Facts relevant to the conversation and a recent Session Summary into the System prompt. The recent Chat History is added to the prompt as individual User and Assistant messages, followed by the most recent message from the User.

In your System message, it can be useful to call the LLM’s attention to the artifacts you’ve provided:

1<your system instructions>
2
3Use the Facts and Summary below as context for your response.
4
5## Facts
6{relevant_facts}
7
8## Summary
9{summary}
10
11<your system instructions>

We can retrieve these artifacts using Zep’s high-level Memory API or, for more control, Zep’s Search API.

Learn more about Zep’s different APIs for retrieving memory artifacts.