This example demonstrates a multi-agent graph which utilizes an LLM within a query router to determine where to route a user query. Depending on the complexity of the user query, it will route to either a simple model or an advanced model.
The purpose of this repository is to demonstrate a simple graph with multiple agents & a conditional edge. It is by no
means production ready, or capable of handling "real" requests, the prompts for the handle_advanced
and handle_simple
instruct the LLMs to pretend to answer the original query.
A visual representation of the graph
- Install Python (compatible version required, e.g., 3.x)
- Install dependencies:
pip install -r requirements.txt
- Configure your environment:
- Copy the example config file:
cp ./config/config-example.yml ./config/config.yml
- Add your API keys and update model configurations in
config.yml
.
- Copy the example config file:
To run the application:
- Execute the main entry point:
python app.py
- The application uses two hardcoded queries:
- One routed to the advanced model
- Another routed to the simple model
Included in the src
dir is a utility script generate_diagram.py
which can be executed to generate a png visualizing
the graph within this application. This script was used to generate the visualization above.
python generate_diagram.py
- This repository is intended for educational purposes and quick prototyping.
- See class level docstrings within
./core/language_models.py
for limitations with the current language model manager.