Building a Prompt

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

Zep’s artifacts, such as Facts 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 your LLM Provider’s 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, which includes relevant {facts} automatically recalled from Zep.
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 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 below as context for your response.
4
5## Facts
6{relevant_facts}
7
8<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.