Repository navigation
Prompts and Lessons
Source: app/services/generator.py. There are three system prompts, one per task. All share a persona and strict grounding rules.
- The assistant is Pepper, a nutrition education assistant for food safety, nutrition and sustainable food practices. The prompts embed the name of the institution that runs the robot.
- It is not a doctor or dietitian and must not diagnose, prescribe or give personalised clinical advice.
- Answer only from the supplied context. If the context is not enough, say so. Never invent nutritional values, health claims or safety guidance.
- Be warm and clear, suitable for children and adults, and use Kenyan food examples where the context has them.
These are instructions to a model, not enforced guarantees. See Grounding Verification for how closely answers follow the sources, and Known Issues and Limitations.
Retrieved chunks are numbered and passed as:
[1] Source: <file name> | Authority: <publisher>
<chunk text>
[2] Source: ...
The model is asked to cite with [1], [2] inline. instrument_response() later counts markers matching [n] or [n, m] and records the number of unique indices. It does not check that a cited number exists.
- 3 to 5 short paragraphs, ending with a practical takeaway.
- Small talk (no context) uses the same persona and tells the user it has no verified source for the message, instead of making factual claims.
- Exactly 4 or 5 beats. Each has a type, spoken text, a gesture and tablet content. The allowed values are in API Reference.
-
speechis plain text for text-to-speech: no symbols or markdown. - The output is JSON.
_sanitize_beats()repairs fields the model gets wrong, andsourcesfalls back to the source names of the retrieved chunks. - On a JSON or model error the generator returns a one-beat fallback lesson.
-
lesson_text: plain flowing paragraphs, no headings or bullets; the prompt asks for 10 to 14 paragraphs of 80 to 120 words, about 2,500 to 3,000 words in total. -
quiz_hints: the prompt asks for 8 to 12 key terms or short phrases taken from the text. - These sizes are targets in the prompt, not enforced. Whether a full-length lesson always fits in
max_tokenshas not been measured; a typical measured output was 9,000-14,000 characters. - The optional
descriptionis inserted as "ADDITIONAL GUIDANCE FROM THE USER". It is user-supplied text placed in the prompt, so it is a prompt-injection surface. The grounding rules still apply, but they are not a security boundary.
Change the constants at the top of generator.py. Keep the instruction to return JSON in the lesson prompts, or parse_json_object() will fail. After a prompt change, re-run the manual checks in Evaluation; the unit tests do not cover prompt quality.
Documentation last verified against the code on 2026-11-05. Evaluation figures are historical, see Evaluation. Educational tool, not medical advice.
Use it
How it works
- Architecture
- Retrieval Pipeline
- LLM Layer
- Prompts and Lessons
- Grounding Verification
- Knowledge Base
- Data and Logging
Quality
Develop