The component uses a Prompt function to generate the text sent to the LLM. By default, it uses DEFAULT_PROMPT, which instructs the AI to be a concise assistant and only use the provided context and chat history.
If you are implementing a custom backend or extending the component, you can define your own prompt function following the PromptParameters shape. The function receives question, chatMessages (the conversation history), and context (the retrieved RAG data).
type PromptParameters = {
chatMessages?: string;
question: string;
context: string;
};
type Prompt = ({ question, chatMessages, context }: PromptParameters) => string;
// Example of a custom prompt implementation
const myCustomPrompt: Prompt = ({ context, question, chatMessages }) => {
return `System: You are a helpful assistant.\nContext: ${context}\nUser: ${question}`;
};