Skip to main content
LangChat uses two prompt templates internally:
  1. System prompt — defines the chatbot’s persona, task, and how to use context
  2. Standalone question prompt — reformulates follow-up questions into self-contained queries before searching
Both have sensible defaults. Override either or both.

System prompt

The system prompt is built once per message. It contains three required placeholders:

Default template

Custom template

Pass prompt_template when creating LangChat:
Your template must contain all three placeholders — {context}, {chat_history}, and {question} — or the chain will raise an error.

Domain-specific examples


Standalone question prompt

Before searching Pinecone, LangChat reformulates the user’s message to be self-contained. This handles follow-up questions like:
  • “What about the pricing?” → “What is Acme Corp’s pricing?”
  • “Can you explain that further?” → “Can you explain Acme Corp’s refund policy further?”

Default behavior

The default prompt:
  1. Uses the LLM to rephrase the question
  2. Keeps greetings unchanged (hi, hello, hey)
  3. Always generates questions in English

Custom standalone question prompt

The standalone question prompt uses two placeholders: {chat_history} and {question}.

Prompt tips

Be specific about tone. “Be concise and professional” produces very different results than the default. Tell the model what to do when it doesn’t know. If you don’t specify, it may hallucinate. Add: “If the answer is not in the context, say you don’t know.” Set the output format. If you need structured output: “Always respond with bullet points.” or “Answer in 2-3 sentences maximum.” Keep {context} early. Models attend more strongly to content near the start of the prompt. Test with verbose=True. See exactly what prompt is being sent: