The Personal Assistant We'll Build › Your Assistant's First Words

Michael BrenndoerferJune 7, 20252 min read
AI Agent HandbookAll chapters
Part 1 of 15Introduction to AI Agents
Chapter 2The Personal Assistant We'll Build › Your Assistant's First Words
Reading section 7 of 13 · Your Assistant's First Words · 2 minSection 7 of 13 · 2 min

Book contents

Section 7 of 13 · 2 min read

The Personal Assistant We'll Build › Your Assistant's First WordsOne section · Sections in this chapter7 / 13 ↓

Let's give you a tiny preview. Here's what the very first version of your assistant might look like: just a simple program that can respond to a prompt.

Example (GPT-5)

In[3]:
Code
## Our assistant's humble beginning
## (Don't worry about the details yet; we'll cover this in Chapter 3)

import os
from openai import OpenAI

## Initialize the client with your API key
client = OpenAI(
    api_key=os.getenv("OPENAI_API_KEY")
)  # Set your key as an environment variable


def ask_assistant(user_message):
    # Send a message to the language model and get a response
    response = client.chat.completions.create(
        model="gpt-5",  # The language model we're using
        messages=[
            {
                "role": "system",
                "content": "You are a helpful personal assistant.",
            },  # Sets the assistant's behavior
            {"role": "user", "content": user_message},  # Your question
        ],
    )
    return response.choices[0].message.content


user_input = "What's the capital of France?"
answer = ask_assistant(user_input)
print(answer)
Out[3]:
Console
Paris.

Simple, right? Just 16 lines of actual code. But this is where everything begins.

Let's break down what's happening here. We're using OpenAI's API to access GPT-5, a language model. We send it two types of messages: a system message (which sets the assistant's personality and behavior) and a user message (your actual question). The model processes these, generates a response, and sends it back. In Chapter 3, we'll explore exactly how this works and why each piece matters.

Right now, this assistant can only respond to one question at a time. It has no memory, no tools, no ability to plan or reason deeply. But by the end of the book, you'll have transformed this basic foundation into something far more capable.