Best Practices for Prompts
To get the most out of Libro, you should structure your AI prompts to smoothly consume the injected context.
The System Prompt Injection
Always place the retrieved context at the top of your system prompt, so the AI reads the context before determining its persona.
const contextString = await ctx.getContext("user_123", userMessage);
const systemPrompt = `
You are a helpful AI assistant.
Here is important context about the user from past sessions:
<context>
${contextString}
</context>
Always adhere to the user's preferences mentioned above.
`;
Be Specific with Queries
The better your query matches the desired semantics, the better the retrieval.
- Bad Query: "What does the user want?"
- Good Query: "User's preferences regarding UI design and color themes."