The heart of AI-901 — Domain 2, 55–60% of the exam
| Role | Job |
|---|---|
| system | persona · rules · grounding · format · guardrails |
| user | the actual request (+ image/audio) |
| assistant | prior replies (context) |
Techniques: clear instructions · few-shot · grounding · output format · chain-of-thought.
flowchart LR SY["system: rules + grounding"] --> M US["user: the request"] --> M AS["assistant: prior turns"] --> M M["Deployed model (deployment name)"] --> OUT["response.choices[0].message.content"]
Chat models are stateless per call — your app resends history.
from openai import AzureOpenAI
client = AzureOpenAI(azure_endpoint=EP, api_key=KEY,
api_version="2024-10-21")
r = client.chat.completions.create(
model="gpt-4o-mini", # deployment name
messages=[
{"role":"system","content":"You are a concise study coach."},
{"role":"user","content":"Three tips for exam nerves?"}],
temperature=0.7, max_tokens=300)
print(r.choices[0].message.content)
3 things to call a model: endpoint · credential · deployment name.
complex multi-step logic/math
cheap, fast, high-volume simple
image/audio input
create visuals
search / similarity / RAG
capability · cost · latency · context window
…that can plan and take actions, not just reply once.
Tools: code interpreter · file search / knowledge · function calling · grounding/search
Agent vs chat: agent acts with tools; chat = text-in/text-out
sequenceDiagram participant App participant Agent participant Thread participant Tool App->>Agent: 1 create_agent(model, instructions, tools) App->>Thread: 2 create_thread() App->>Thread: 3 add user message App->>Agent: 4 create_and_process_run(thread, agent) Agent->>Tool: (may call a tool) Tool-->>Agent: result Agent-->>Thread: assistant message App->>Thread: 5 read messages
agent = project.agents.create_agent(
model="gpt-4o-mini", name="study-buddy",
instructions="You are an AI-901 tutor. Use the notes.")
thread = project.agents.create_thread()
project.agents.create_message(thread_id=thread.id,
role="user", content="Explain grounding in one line.")
project.agents.create_and_process_run(
thread_id=thread.id, agent_id=agent.id)
for m in project.agents.list_messages(thread_id=thread.id):
print(m.role, ":", m.content)
retrieve your data (embeddings + search) → add to prompt → fewer hallucinations
content filters (hate/violence/…) · prompt shields vs injection · evaluations
Run the Python client; change the system message + temperature.
Portal: agent + file-search over a PDF; then run it from the SDK.
Then: Practice Test 2 (live workshop).
Next → Day 6: Revision + 50-Q mock