Spaces:
Running
Running
Plan-a-Party Multi-Agent System - Project Summary
๐ฏ Project Overview
A complete multi-agent party planning system built with LangChain and Gradio, featuring 4 specialized subagents coordinated by an orchestrator agent. The system uses an interactive conversational interface where users plan parties through natural language dialogue, with all agents sharing state through a centralized PartyContext model.
๐ Complete File Structure
plan-a-party/
โโโ app.py # Main Gradio entrypoint
โโโ requirements.txt # Python dependencies
โโโ README.md # Main documentation
โโโ PROJECT_SUMMARY.md # This file (detailed architecture)
โโโ .env.example # Environment variables template
โโโ .gitignore # Git ignore rules
โโโ invitations/ # Generated invitation card images
โ โโโ invitation_*.png # Theme-based invitation cards
โโโ src/
โโโ __init__.py
โโโ config.py # Configuration management (model IDs, etc.)
โโโ party_context.py # Shared state (Pydantic models)
โโโ agents/
โ โโโ __init__.py
โ โโโ orchestrator.py # Main orchestrator agent (conversational flow)
โ โโโ theme_planning_agent.py # Subagent 1: Themes & invitations
โ โโโ guest_invite_email_agent.py # Subagent 2: Email sending via Resend MCP
โ โโโ venue_search_agent.py # Subagent 3: Bright Data SERP venue search
โ โโโ theme_decor_favor_shop_agent.py # Subagent 4: Shopping with Amazon MCP
โโโ tools/
โ โโโ __init__.py
โ โโโ csv_guest_parser.py # CSV parsing utility for guest lists
โโโ mcp/
โ โโโ __init__.py
โ โโโ mcp_clients.py # MCP clients (Amazon, Fewsats, Resend, BrightData)
โโโ ui/
โโโ __init__.py
โโโ gradio_ui.py # Gradio interface (interactive chat UI)
๐ค Agent Architecture
Orchestrator Agent
- File:
src/agents/orchestrator.py - Role: Coordinates all subagents using conversational flow management
- Key Features:
- Multi-turn Dialogue: Progressively collects event details (budget, location, date)
- Natural Language Understanding: Extracts information from user messages
- Automatic Theme Generation: Triggers theme generation once party description is provided
- Theme Selection Detection: Recognizes theme selection from natural language
- Tool Routing: Routes requests to appropriate subagents based on context
- State Management: Updates
PartyContextthroughout the conversation - LLM-based Decision Making: Uses Hugging Face LLM to decide next actions
Key Functions:
orchestrator_chat(user_message, chat_history)- Main conversational handlerextract_event_details_from_message(message)- Extracts budget, location, dateextract_theme_selection_from_message(message)- Detects theme selectiondecide_next_action(user_message, context)- LLM-based routing- Wrapper functions for each subagent tool
Subagent 1: Theme Planning Agent
- File:
src/agents/theme_planning_agent.py - Capabilities:
- Generates 3 creative party theme options using LLM
- Creates invitation text with event details (date, location, budget)
- Generates 4x4 invitation card images using FLUX.1-dev
- Embeds event metadata in invitation images
- Tools:
generate_party_themes(party_description)- Generates 3 theme optionsgenerate_invitation_for_theme(selected_theme_name)- Creates invitation card
- Models Used:
- meta-llama/Llama-3.3-70B-Instruct - Text generation
- FLUX.1-dev - Image generation
Subagent 2: Guest Invite Email Agent
- File:
src/agents/guest_invite_email_agent.py - Capabilities:
- Parses guest lists from CSV files
- Composes personalized invitation emails using LLM
- Sends emails via Resend MCP (Zapier integration)
- Attaches invitation card images to emails
- Tools:
compose_invitation_email()- Generates email subject and bodysend_guest_invites_via_resend()- Sends emails to all guests
- MCP Integration: Resend MCP via Zapier Gmail API
Subagent 3: Venue Search Agent
- File:
src/agents/venue_search_agent.py - Capabilities:
- Searches for party venues using Bright Data MCP SERP search
- Filters by location, budget, and guest count
- Extracts venue details (name, URL, rating, price, address, phone)
- Formats results for display in chat
- Tools:
search_party_venues(location, query, max_results, budget, guest_count)- Searches venues
- MCP Integration: Bright Data MCP for SERP search
- Query Building: Constructs natural-language queries with filters
Subagent 4: Theme Decor/Favor Shop Agent
- File:
src/agents/theme_decor_favor_shop_agent.py - Capabilities:
- Generates theme-based shopping lists (decor + favors) using LLM
- Optimizes Amazon search queries from item names
- Integrates with Amazon MCP for product search
- Builds shopping carts with product links and pricing
- Supports Fewsats MCP for payment processing (future)
- Tools:
generate_shopping_list_for_theme(theme_name)- Generates shopping listshop_on_amazon(selected_items, ...)- Builds Amazon cart
- MCP Integration:
- Amazon MCP (optional, requires Node.js build)
- Fewsats MCP (for payment processing)
- Query Optimization:
build_amazon_query_from_item_name()- Cleans item names for better Amazon searches- Strips descriptions, normalizes case, adds "party" keyword when appropriate
๐ ๏ธ Supporting Components
Shared Context (PartyContext)
- File:
src/party_context.py - Purpose: Centralized state management using Pydantic models
- Key Fields:
event_budget,event_location,event_date- Event metadatatheme_options,selected_theme_name- Theme managementinvitation_text,invitation_image_path- Invitation dataguest_names,guest_emails,emails_sent- Guest list managementvenue_results,search_location- Venue search resultscart_items,decor_items,favor_items- Shopping dataselected_items,order_status,order_id- Order management
MCP Clients
- File:
src/mcp/mcp_clients.py - Architecture:
MCPConnectionManager- Manages connections to all MCP servers- Individual client classes for each service
- Clients:
- AmazonMCPClient - Product search and cart building (optional, requires build)
- FewsatsMCPClient - Payment processing with X402/L402 protocols
- ResendMCPClient - Email sending via Zapier
- BrightDataMCPClient - SERP search for venues
- Graceful Degradation: Checks for server availability before use
Tools
- CSV Parser (
src/tools/csv_guest_parser.py): Handles guest list uploads - Query Builder (
src/agents/theme_decor_favor_shop_agent.py): Optimizes Amazon searches
๐จ User Interface
Gradio UI Features
- File:
src/ui/gradio_ui.py - Design: Single-page conversational interface (not tab-based)
- Key Components:
- Interactive Chat - Main conversation area with chatbot
- Cart Preview - Real-time shopping cart display
- Generate Invitation Card Button - Appears when all info is ready
- Guest List Upload - CSV file upload with status display
- Shopping Checkboxes - Item selection for decor and favors
- Quick Hints - Suggested workflow guide
UI Flow
- User types party description in chat
- System asks for budget, location, date
- System generates themes and displays in chat
- User selects theme via natural language
- "Generate Invitation Card" button becomes visible
- User clicks button to generate invitation
- User can upload guest list and send invitations
- User can search for venues via chat
- User can shop for decor/favors via chat
State Management
- Uses
gr.Statefor chat history - Updates
PartyContextthroughout conversation - Dynamic UI updates based on context state
- Button visibility controlled by collected information
๐ง Technology Stack
- LangChain - Agent framework and tool orchestration
- Gradio - Interactive web UI framework
- Hugging Face:
- Mistral-7B-Instruct-v0.3 - Text generation for all agents
- FLUX.1-dev - Image generation for invitation cards
- Inference API - Model access
- MCP (Model Context Protocol):
- Bright Data MCP - SERP search for venue discovery
- Zapier MCP - Email sending via Zapier
- Amazon MCP - Product search and cart building (optional)
- Fewsats MCP - Payment processing (X402/L402)
- Pydantic - Data validation and shared context models
- Pandas - CSV processing
- langchain-mcp-adapters - MCP integration library
๐ Deployment
Local Development
python app.py
App runs at http://localhost:7860
Hugging Face Spaces
- Push repository to Hugging Face Spaces
- Set environment variables in Space settings:
HUGGINGFACEHUB_API_TOKENHF_TOKENBRIGHTDATA_TOKEN(optional)ZAPIER_GMAIL_API_KEY(optional)FEWSATS_API_KEY(optional)
- Space auto-deploys
Amazon MCP Setup (Optional)
cd amazon-mcp
npm install
npm run build
cd ..
๐ Complete Workflow
1. Initial Conversation
- User: "I want to plan a birthday party for my 6 year old kid"
- System: Stores party description, asks for budget, location, date
2. Event Details Collection
- User: "Budget is under $500, in San Jose CA on June 10, 2025"
- System: Extracts and stores event metadata
3. Theme Generation
- System: Automatically calls
generate_party_themes - System: Displays 3 theme options in chat
4. Theme Selection
- User: "I like the first one" or "Let's go with the Minecraft theme"
- System: Detects selection, updates
selected_theme_name
5. Invitation Generation
- System: "Generate Invitation Card" button becomes visible
- User: Clicks button
- System: Calls
generate_invitation_for_theme - System: Creates invitation text and image, displays in UI
6. Venue Search
- User: "Search for venues" or "Find venues near me"
- System: Calls
search_party_venueswith stored location - System: Displays formatted venue results in chat
7. Guest List Management
- User: Uploads CSV file
- System: Parses CSV, stores guest names and emails
- System: Displays status
8. Email Sending
- User: "Send the invitations" or "Send emails"
- System: Calls
compose_invitation_emailandsend_guest_invites_via_resend - System: Sends emails with invitation card attachments
9. Shopping
- User: "What decor items do you recommend?" or "Show me shopping options"
- System: Calls
generate_shopping_list_for_theme - System: Displays items in checkboxes
- User: Selects items, clicks "Save selected items"
- User: "Build my Amazon cart" or "Shop on Amazon"
- System: Calls
shop_on_amazonwith selected items - System: Builds cart, displays products with links and prices
โ Implementation Status
- Folder structure created
- All 4 subagents implemented
- Orchestrator agent with conversational flow
- Gradio UI with interactive chat
- Shared context management (PartyContext)
- MCP integration (Bright Data, Resend, Amazon, Fewsats)
- CSV parsing for guest lists
- Theme generation with FLUX.1-dev
- Email sending via Resend MCP
- Venue search via Bright Data SERP
- Amazon shopping with query optimization
- Natural language theme selection
- Event metadata collection
- Dynamic UI updates
- Graceful degradation for optional MCP servers
- Documentation (README, PROJECT_SUMMARY)
๐ฎ Future Enhancements
- Order tracking and status updates
- Multi-language support
- Theme customization options
- Calendar integration for date selection
- Budget tracking and alerts
- Guest RSVP management
- Venue booking integration
- Real-time order placement with Fewsats
- Image customization options
- Multiple invitation card styles
๐ Key Design Decisions
Conversational Interface
- Chose chat-based UI over tab-based for better user experience
- Natural language interaction feels more intuitive
- Progressive information gathering through dialogue
Shared Context
- Centralized state management prevents data duplication
- Pydantic models ensure type safety
- Global instance allows easy access across agents
MCP Integration
- Graceful degradation ensures app works even if optional services unavailable
- Clear error messages guide users on setup
- Modular design allows easy addition of new MCP servers
Query Optimization
- Amazon search queries optimized from item names
- Improves product matching accuracy
- Reduces failed searches
Open Source Models
- All models are open-source (Mistral-7B, FLUX.1-dev)
- No proprietary dependencies
- Accessible via Hugging Face Inference API
๐ Security & Privacy
- All API keys stored as environment variables
- No hardcoded credentials
- Guest data only stored in session (not persisted)
- Email sending requires explicit user action
- Amazon shopping is demo mode (no real orders)
๐ Performance Considerations
- LLM calls have timeouts to prevent hanging
- MCP calls are async for better performance
- Image generation cached in
invitations/directory - Chat history managed efficiently with Gradio State
- Query optimization reduces failed Amazon searches
๐ Known Limitations
- Amazon MCP requires Node.js build (optional)
- Email sending requires Zapier Gmail API key
- Venue search requires Bright Data token
- Image generation can be slow (depends on FLUX.1-dev API)
- Chat history not persisted across sessions
๐ Additional Resources
- See
README.mdfor quick start guide - See
src/deployment/for deployment documentation - See individual agent files for detailed implementation
Built for Hugging Face MCP Hackathon ๐