Beginner
Build a RAG prompt with numbered sources
Write build_rag_prompt(question, sources) that returns one string with these lines, in order: an instruction line, then one line per source in the form [1] text, [2] text and so on, then the last line Question: <question>.
sources is a list of strings. If it is empty, use a single line No sources found. instead of the numbered lines. The instruction line can say anything, but it must contain the word cite. Join the lines with "\n". (Topic 16.9.)
What Check tests
- Numbers the sources from 1
- Ends with the question line
- Uses a fallback line when there are no sources
- The instruction mentions citing
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.