This home assistant is an AI-powered system designed to automate and manage household planning tasks. It integrates Notion, Google Calendar, Google Sheets to handle scheduling, email, shopping lists, TODO-lists, note-taking and meal planning - all through a natural language interface.
The app is built with a simple multi-agent setup using LangGraph. Below is a walkthrough of how to get it up and running as well as how to extend and customize it with new agents and tools.
We use different external services to manage various aspects of household planning:
Notion
- shopping list
- mind base: todo-list, ideas and general notetaking
- multiple calendars
- a google sheet with recipes + ingredients
- a google sheet with names and emails
The app consists of the following agents:
- supervisor : receives user queries and routs to relevant sub-agents
- calendar agent: handles Google calendar interactions
- notion agent: handles Notion interactions
- email agent: handles Gmail interactions
- meal planner agent: creates meal plans based on the recipes list, interacts with user to get feedback and iterate until user is happy
- contact agent: handles Google sheets interactions
- "Add apples, oranges and tea to the shopping list"
- "Get all calendar events for the coming week and summarize the week for me"
- "Make a 2-week meal plan, add the meals as full-day events to the family calendar, starting March 1st, and add all ingredients to the shopping list"
The app can be plugged into any communication method (e.g. a chatbot, voice assistant, or web app). In our setup, we interact with it through Telegram voice messages (though this interface is not covered in this README - reach out if you're interested to know more!).
python 3.11 or higher
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt`
Make a new .env
file OR replace .env.example
, fill in your credentials and add-specific details:
- not necessary to specify in general, but very useful for tracing and troubleshooting
- necessary if launching local LangGraph server to use LangGraph Studio Web UI (see options to run below)
- Check the instructions for how to get a Notion API Key here
- IDs of individual pages are visible in the URL in the browser (the format seems to vary a bit, it should be a 32-character string)
-
Google calendar IDs can be obtained from the calendar settings on Google
-
Google sheet IDs can be obtained from the URL, field GOOGLE_SHEET_ID in the following format: https://docs.google.com/spreadsheets/d/GOOGLE_SHEET_ID/edit#gid=SHEET_ID
NOTE: Currently, a simple recipes "data base" setup using Google sheets is implemented. To have the meal planner agent access your own list of recipes, add a sheet called
recipes_db
to your main google sheetRECIPES_GOOGLE_SHEET
. The sheet should have 2 columns, titledname, ingredients
.
Please see the additional README.md
in /helper_scripts/README.md
- Modify the initial message to send as input data to the graph in main.py
python main.py
NOTE: The human-in-the-loop functionality of the meal planner agent uses interrupts, and this is a bit tricky to use when interacting with the graph through
graph.stream
inmain.py
. You can get some pointers e.g. here if you want to try, but it's recommended to run graphs with this agent via LangGraph Studio Web UI, which takes care of the interrupts and resumes for you.
Following https://langchain-ai.github.io/langgraph/tutorials/langgraph-platform/local-server/
- Make a langsmith account
pip install --upgrade "langgraph-cli[inmem]"
cd langgraph_home_assistant/
langgraph dev
Following https://langchain-ai.github.io/langgraph/how-tos/deploy-self-hosted/#environment-variables
pip install -U langgraph-cli
langgraph build -t my-image
- Set up redis
- Set up postgres
docker run \ --env-file .env \ -p 8123:8000 \ -e REDIS_URI="foo" \ -e DATABASE_URI="bar" \ -e LANGSMITH_API_KEY="baz" \ my-image
The file app_config.yaml
contains the config for all agents, except the supervisor which is defined in agents/supervisor.py
.
Agent prompts and LLM models can be updated in these. Currently, the agents are built using ChatOpenAI, meaning models including "gpt-3.5-turbo", "gpt-4o-mini","gpt-4o", etc can be specified.
- Write the code for the tool in the corresponding agent's file in
tools/
- Add the tool function to
tools/tools_registry.py
- Add the tool's description to the agent's config, section tools, using the same syntax as existing entries
If adding an agent based on the LangGraph prebuilt component ReAct agent
- Add the agent definition to
app_config.yaml
(this will build the agent using the functionality inutils/react_agent_factory.py
) - Update prompt, model and add tools as described in sections above
- Update
agents_config.yaml
to include the new agent
- Add custom agent definition file to
agents/
(e.g. like the supervisor agent inagents/supervisor.py
) - Add an import of the agent node to
main.py
- Add the agent node to the graph in
main.py