All labs · Lab 3 of 5 · 2-3 hours

Single-Agent Prototype

Build a small assistant with clear instructions, a narrow task, and a demo scenario.

Prerequisites

  • Model Deployment lab completed
  • Decided on one user task (e.g., FAQ answering, CV feedback)

Steps

1

Define one task

Write one sentence describing the assistant. Example: 'The Campus Helper answers TIU course schedule questions in English.'

2

Write a system instruction

Keep it short. State the role, the allowed scope, and what to refuse. Save it to a prompts/system.md file.

markdown
# Campus Helper — system instruction

You are Campus Helper for TIU. You only answer questions about course
schedule, room numbers, and registration deadlines. If a question is
outside that scope, reply with: "I only help with course schedule and
registration. Please ask the appropriate office for other topics."
Answers are short — at most two sentences.
3

Wrap the call as a function

Move the chat call into a function that takes a user query and returns a string. This is the contract you will reuse from the UI.

python
from pathlib import Path

SYSTEM = Path("prompts/system.md").read_text()

def ask(user_query: str) -> str:
    response = client.chat.completions.create(
        model=os.environ["AZURE_OPENAI_DEPLOYMENT"],
        messages=[
            {"role": "system", "content": SYSTEM},
            {"role": "user", "content": user_query},
        ],
        max_tokens=200,
    )
    return response.choices[0].message.content
4

Run two test cases — in-scope and out-of-scope

Confirm the assistant answers an in-scope question and politely refuses an out-of-scope one. Save both transcripts as evidence.

5

Connect to a minimal UI

Pick FastAPI + a single HTML page, or Streamlit, or a Jupyter notebook with input(). The UI is not graded heavily — focus on the assistant behavior.

Verification

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

  • In-scope test: assistant returns a relevant short answer
  • Out-of-scope test: assistant returns the refusal sentence
  • System message is loaded from a file, not pasted inline

Azure cost

Each test exchange costs roughly $0.001-$0.003. Iterate with short prompts; save long prompts for the demo run.

Responsible AI

Add a closing line in every response that says 'For official information, contact the registrar's office.' This reduces over-reliance risk.