Two AI agents for gaming: a voice coach and a game state tracker, plus Redis-based NPC knowledge.
# Install dependencies
uv sync
# Copy and configure environment variables
cp .env.example .env
# Edit .env with your API keysPush-to-talk voice assistant. Hold Right Option, speak, release to get a spoken response.
uv run voice-agent| Action | Key |
|---|---|
| Start recording | Hold Right Option |
| Get response | Release Right Option |
| Quit | Press ESC |
Tracks game state by analyzing screenshots periodically.
uv run game-statePress Ctrl+C to stop.
Open two terminal windows and run each agent:
# Terminal 1
uv run game-state
# Terminal 2
uv run voice-agentOr run both in one terminal (game-state in background):
uv run game-state & uv run voice-agentRedis Server must be running locally:
# macOS
brew install redis
brew services start redis# Populate the Redis database
uv run python redis_setup/setup_redis.py# Run example queries
uv run query-npcs
# Interactive mode
uv run python -i query_npcs.pyfrom query_npcs import semantic_search, filter_search, get_entry
# Semantic search - natural language queries
semantic_search("boss with shields and flowers")
semantic_search("how to cross the sea")
# Filter by metadata
filter_search("@region:{The Continent}")
filter_search("@role:{Merchant}")
filter_search("@race:{Boss}")
# Combined: semantic + filter
semantic_search("secret items", filter_expr="@region:{The Continent}")
# Get specific entry by ID
get_entry("goblu")NPCs in data/npcs.json have:
name,race,role,regionlocations,affiliation,questdescription,lore,dialogueis_hostile,becomes_hostile,drops
Edit data/npcs.json and re-run:
uv run python redis_setup/setup_redis.py- Python 3.13+
- macOS (for Right Option key detection in voice agent)
- OpenAI API key
- ElevenLabs API key (for voice agent)
- Redis (for NPC database)
Your terminal app needs:
- Accessibility permission (System Settings > Privacy & Security > Accessibility)
- Microphone permission (System Settings > Privacy & Security > Microphone)
Create a .env file in the project root:
| Variable | Required By | Description |
|---|---|---|
OPENAI_API_KEY |
Both | OpenAI API key |
ELEVENLABS_API_KEY |
Voice Agent | ElevenLabs API key |
LOGFIRE_TOKEN |
Voice Agent | Logfire token (or run uv run logfire auth) |
The voice agent is instrumented with Pydantic Logfire for tracing and observability.
# Authenticate with Logfire (first time only)
uv run logfire authOr set LOGFIRE_TOKEN in your .env file.
After running the voice agent, view traces at https://logfire.pydantic.dev
Traces include:
- Full voice interaction flow timing
- OpenAI API calls (chat completions, embeddings)
- Redis operations
- ElevenLabs STT/TTS calls
- Semantic cache hits/misses
- Screenshot capture timing
game_state_agent/ # Game state tracking agent
main.py # Entry point
analyzer.py # LLM screenshot analysis
capture.py # Screen capture
state_manager.py # State tracking
voice_agent/ # Voice coach agent
main.py # Entry point / orchestrator
src/
ptt.py # Push-to-talk handler
audio.py # Recording & playback
screenshot.py # Screen capture
stt.py # Speech-to-text
tts.py # Text-to-speech
coach.py # LLM coach
redis_setup/ # Redis vector database setup
data/npcs.json # NPC seed data
setup_redis.py # Populates Redis with embeddings
query_npcs.py # Query utilities
