A prompt is the input that guides a language model’s next response. In a chatbot, it can be a human directive; in an LLM chain, it is the tokens supplied to start generation. Unlike a fixed menu of replies, a prompt lets a generative chatbot respond to unexpected messages—but it does not make those responses predictable or reliable. section 12.4 section 12.5.2
A prompt template keeps reusable instructions separate from changing input. For a math tutor, a template can describe the conversation, insert a user’s message at `{message}`, and end where the chatbot should respond. `PromptTemplate` declares that variable; an `LLMChain` combines the template with an LLM so the application can call `chain.predict(message=...)` without rebuilding the whole prompt. section 12.5.2
>>> from langchain.prompts import PromptTemplate
>>> from langchain.chains import LLMChain
>>> template = """
... This is a conversation between a math tutor
... chatbot Rori and a user who might be a student
... in Africa or a parent.
...
... Human says: {message}
... Chatbot responds:
... """
>>> prompt = PromptTemplate(
... input_variables = ["message"], #1
... template=template)
>>> chain = LLMChain(
... llm=llm, verbose=True, prompt=prompt #2
... )
The Python listing shows a reusable tutor prompt with a `{message}` slot, passed to `PromptTemplate` and `LLMChain`. section 12.5.2
Wording matters, but it is not a guarantee. A tutor prompt produced a plausible greeting and then generated lines for the student too. A later call asking for the student’s name failed to recall it: ordinary LLM calls do not retain earlier conversation turns. To supply that context, record conversation history and include it as another template variable. section 12.5.2
>>> onboarding_pt = """
This is a conversation between a math tutor chatbot Rori
and a user who might be a student in Africa or a parent.
The chatbot introduces itself and asks if it's talking
to a student or a parent.
If the user is a parent, Rori asks the parent for
permission for their child to use Rori over Whatsapp.
If the user is a student, Rori asks the student to call
their parents.
Only if the parent gives explicit permission, Rori
thanks them and asks to give the phone to the student.
Provide the tutor's next response based on the conversation history.
Provide only one response.
Do not return more than one or two sentences.
{history}
user:{input}
tutor:
"""
This revised template includes a `{history}` slot, onboarding instructions, and an explicit request for only one short response. section 12.5.2
A math answer that needs checking
A number-sequence prompt asked the tutor to compare a student’s answer with the next number. When the student answered “12” after 2, 4, 6, 8, the bot praised the answer as correct while saying the next number was 10. A detailed prompt did not make its evaluation dependable. section 12.5.2
Treat a prompt as one component of a chatbot, not its safety system or memory. Grounding, fine-tuning, guardrails, and checks such as intent recognition can help manage unhelpful or harmful replies; conversation history must be supplied when a reply depends on earlier turns. section 12.4 section 12.5.2

















































