All labs · Lab 4 of 5 · Half day

Grounded Assistant (RAG mini-lab)

Upload a small document set, retrieve relevant passages, and produce grounded answers with source references.

Prerequisites

  • Single-Agent Prototype lab completed
  • 3-5 small public documents prepared (FAQ.md, course-catalog.pdf, syllabus.docx)

Steps

1

Upload documents to your project

Open Foundry > your project > Data + indexes. Upload the 3-5 documents. Foundry will create a searchable index named like idx-campus-faq.

2

Wire retrieval into the chat call

Use the Foundry chat-with-your-data endpoint or the Python sdk's data_sources parameter to send the index name with every query.

python
response = client.chat.completions.create(
    model=os.environ["AZURE_OPENAI_DEPLOYMENT"],
    messages=[
        {"role": "system", "content": SYSTEM},
        {"role": "user", "content": user_query},
    ],
    extra_body={
        "data_sources": [{
            "type": "azure_search",
            "parameters": {
                "endpoint": os.environ["AZURE_SEARCH_ENDPOINT"],
                "index_name": "idx-campus-faq",
                "authentication": {"type": "api_key", "key": os.environ["AZURE_SEARCH_KEY"]},
            },
        }],
    },
)
3

Show the citation

Foundry returns a citations array. Print citation titles alongside the answer.

4

Evaluate three queries

Pick three real questions a TIU student would ask. Note answer correctness, citation correctness, and refusal correctness for an out-of-scope query.

Verification

When all three (or more) of these are true, you can mark the lab complete and move on.

  • Answer references the right document
  • Out-of-scope query returns the configured refusal
  • Citation titles match the uploaded documents

Azure cost

Small RAG (5 docs, 20 queries) costs roughly 1,500-3,000 KRW. Indexing is one-time; queries are metered per call.

Responsible AI

Only upload public documents. Do not upload student records, grades, or personal contact info. Each citation should be reviewable by a tutor.

Hackathon connection

Sample repo — RAG example