This repository contains code for Agentic RAG that helps users choose garments from their wardrobe to create a complete outfit according to their requests, leveraging both knowledge of an LLM itself and its ability to use tools to retrieve the necessary information.
This project was developed to gain hands-on experience in building Agentic RAG using modern AI frameworks and state-of-the-art Vision and Large Language Models, and to demonstrate its application to solve a real-world problem.
-
Vector Store: The user places all images of garments they plan to use in a special folder. They then create a vector store representing their wardrobe and containing indexed descriptions of these images. These descriptions are generated by a Vision Language Model (VLM) according to the provided instruction (Image-Text-to-Text task).
-
User Information: The user provides brief information about themselves, which is saved in store.
-
Initial User Message: The user asks a question, such as "What should I wear today?"
-
Agent: The agent begins working according to its graph:
The Large Language Model (LLM) analyzes the question and decides whether and which tools to use. The final answer is displayed to the user along with images of the garments, if any were selected.
-
New User Message (Optional): If desired, the user can continue the conversation, as the agent remembers the conversation.
To create the user's wardrobe, 100 images were selected from the Clothing dataset (full, high resolution): images_compressed so that the subsample contained garments of different types. A list of the images used can be found in the data/used_images.txt file.
- Language: Python 3.12
- Core Frameworks:
- Model Provider: Hugging Face
- VLM (local): HuggingFaceTB/SmolVLM-256M-Instruct
- Text Embedding Model (local): sentence-transformers/all-mpnet-base-v2
- LLM (via API): Qwen/Qwen3-235B-A22B-Instruct-2507 or Qwen/Qwen3-4B-Thinking-2507
- Vector Store: Chroma
- Tools:
- Garment Description Retriever (local): the vector store as the retriever.
- Weather Forecast (via API): OpenWeatherMap
- Web Search (via API): Tavily
- Other Key Platforms and Libraries:
- Google Colab: Developing the notebook in a browser-based Jupyter Notebook environment.
- Gradio: Interacting with the agent via the UI application.
- LangSmith: Tracing the agent behavior.
.
├── agent/
| ├── components/
| | ├── __init__.py
| | ├── context_memory.py # Agent graph context schema, state, store, and checkpointer
| | ├── nodes_edges.py # LLM, graph node and conditional edge functions
| | ├── prompts.py # Prompts for the VLM and LLM
| | ├── tools.py # Tool functions
| | └── vector_store.py # VLM, Text Embedding Model, image description generation, and vector store
| ├── utils/
| | ├── __init__.py
| | └── utils.py # Helper functions
| ├── __init__.py
| ├── graph.py # Agentic RAG graph built using LangGraph
| └── requirements.txt # Graph dependencies
├── data/
| ├── garment_images # Images of garments whose descriptions are used to create the vector store
| ├── wardrobe_db/ # Persist directory for the vector store
| | ├── *** # UUID collection name
| | └── chroma.sqlite3 # Vector DB itself representing a user's wardrobe
| └── used_images.txt # Images that were used in this project
├── demo/
| ├── app.py # Gradio UI app for step-by-step data preparation and agent interaction
| └── requirements.txt # UI application dependencies
├── notebooks/
| └── Agentic_RAG_Graph_(What_Should_I_Wear).ipynb # Jupyter Notebook for running in Google Colab
├── static/
| └── agent_graph.png # Agent graph visualization
├── tests
├── .env # Environment variables
├── .env.example # Example .env file
├── .flake8
├── .gitignore
├── .pre-commit-config.yaml
├── .pytest.ini
├── dev-requirements.txt # Project dependencies
├── langgraph.json # LangGraph application configurations
├── LICENSE
└── README.md
Follow these steps to set up and run the demo project:
- Python 3.12
- Images of garments in the
data/garment_imagesfolder - An API token for Hugging Face Hub
- An API key for OpenWeatherMap
- An API key for Tavily
- (Optional) An API key for LangSmith
You can interact with the agent in three ways:
To explore the code in detail:
- Copy the
datafolder and the notebookAgentic_RAG_Graph_(What_Should_I_Wear).ipynbto Google Drive. - Open the notebook in Google Colab and fill in Colab Secrets with your API keys and tokens (their names correspond to environment variables).
- Run the notebook.
To walk through the Agentic RAG process:
- Clone the repository, create and activate a virtual environment, and install the required dependencies from
demo/requirements.txt. - Create a
.envfile similar to the.env.examplewith your API keys and tokens. - Execute the
demo/app.pyfile directly to launch the app. - Follow the app's steps through the entire process, from creating a vector store of your wardrobe and providing information about yourself to chatting with your assistant.
Note: Generating image descriptions, and therefore creating the vector store, takes time! You can skip first step in the app if you already have one.
To create the vector store and run the predefined agent:
- Clone the repository, create and activate a virtual environment, and install the required dependencies from
agent/requirements.txt. - Create a
.envfile similar to the.env.examplewith your API keys and tokens. - Execute the
agent/components/vector_store.pyfile directly to create a vector store of your wardrobe. Note: Generating image descriptions, and therefore creating the vector store, takes time! You can skip this step if you already have one. - Execute the
agent/graph.pyfile directly to run the agent graph with the user message already defined.
