Intermediate

Building a Custom AI Assistant

Design and build your own AI personal assistant from the ground up. Choose the right model, craft an effective system prompt, define personality traits, and architect the integration layer that connects your assistant to the real world.

Choosing the Right Model

Your model choice depends on your requirements for speed, capability, and cost:

Use CaseRecommended ModelWhy
General assistantClaude Sonnet 4, GPT-4oGood balance of speed, cost, and capability
Complex reasoningClaude Opus 4, o3Best for multi-step planning and analysis
Quick responsesClaude Haiku, GPT-4o-miniFast and cheap for simple queries
Privacy-focusedLlama 3.3 70B (self-hosted)Full data control, no external API calls
MultimodalGPT-4o, Gemini 2.5 ProStrong vision + audio capabilities
Multi-model approach: The best personal assistants use multiple models. Route simple questions to a fast, cheap model and complex requests to a more capable one. This keeps costs low and response times fast while maintaining quality for hard tasks.

Crafting the System Prompt

The system prompt defines your assistant's behavior, personality, and capabilities. A well-crafted system prompt includes:

  • Identity: Who the assistant is, what it does, and what it does not do
  • Personality traits: Communication style, tone, verbosity level, humor
  • User context: Information about the user (preferences, timezone, communication style)
  • Tool instructions: How and when to use available tools and integrations
  • Boundaries: What the assistant should refuse or redirect (safety, privacy, scope)
System Prompt Example
# Personal Assistant System Prompt

You are Alex, a personal AI assistant for [User Name].

## Personality
- Concise and direct, but warm
- Proactive: suggest actions, not just information
- Remember and reference past conversations
- Use the user's preferred name and communication style

## Context
- Timezone: [User's timezone]
- Work schedule: [User's typical hours]
- Communication preference: [Brief/detailed]

## Tools Available
- Calendar: read/write events
- Email: read/draft/send
- Web search: research topics
- Notes: save and retrieve information

## Guidelines
- Always confirm before sending emails or creating events
- Summarize long content unless asked for details
- If uncertain, ask for clarification rather than guessing

Architecture Design

A practical personal assistant architecture has these layers:

  1. Interface Layer

    How users interact: web UI, mobile app, voice interface, messaging platform (Slack, Discord, Telegram), or CLI.

  2. Orchestration Layer

    Manages conversation flow, routes to the right model, handles tool calls, and maintains session state.

  3. LLM Layer

    The AI models that process requests. Can be a single model or multiple models for different task types.

  4. Tool Layer

    Integrations with external services: calendar APIs, email APIs, web search, databases, smart home APIs.

  5. Memory Layer

    Persistent storage for conversation history, user preferences, and knowledge. Covered in detail in Lesson 5.

Building the Core Loop

Python - Core Assistant Loop
import anthropic

client = anthropic.Anthropic()

def run_assistant(user_message, conversation_history, tools):
    # Add user message to history
    conversation_history.append({
        "role": "user",
        "content": user_message
    })

    # Call the LLM with tools
    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        system=system_prompt,
        messages=conversation_history,
        tools=tools,
        max_tokens=4096
    )

    # Handle tool use if needed
    while response.stop_reason == "tool_use":
        tool_results = execute_tools(response)
        conversation_history.append(response)
        conversation_history.append(tool_results)
        response = client.messages.create(...)

    return response.content