Home

Awesome

<div align="center"> <img src="docs/DepsRAG.png" alt="Logo" width="450" align="center"> </div> <br><br>

DepsRAG

DepsRAG is a chatbot that answers users' questions about software dependencies after representing them as a Knowledge Graph (KG). DepsRAG offers the following features:

DepsRAG Architecture

DepsRAG comprises the following agents to accomplish its process:

  1. AssistantAgent. This agent orchestrates the work between the agents. It also breaks down complex questions into simple steps and then aggregates all responses to answer the user's query. This agent utilizes the following tool:
    • UserInteractionTool: manages the interaction between the chatbot and user.
  2. DependencyGraphAgent. This agent handles the interactions the with graph database that represents the dependencies.
    • ConstructKGTool: builds the dependency graph for a given pkg version, using the API at DepsDev.
    • GraphSchemaTool: gets schema of Neo4j knowledge-graph.
    • CypherQueryTool: generates Cypher queries to get information from Neo4j knowledge-graph (Cypher is the query language for Neo4j).
    • VisualizeGraph: visualizes the entire dependency graph.
  3. CriticAgent. This agent provides feedback upon the final answer provided by the AssistantAgent.
    • FeedbackTool: provides the feedback message.
  4. SearchAgent.
    • WebSearchTool: to find package version and type information. It also can answer other questions from the web about other aspects after obtaining the intended information from the dependency graph For example:
      • does the dependency use the latest version for this package version?
      • can I upgrade this package in the dependency graph?
    • VulnerabilityTool: searches OSV vulnerability DB based on the package name, version, and ecosystem.

DepsRAG Workflow

The workflow of DepsRAG as follows:

For package X, version, Y, in ecosystem Z, following are examples of questions:

The following illustration shows the steps that DepsRAG will take to answer this question:

For Chainlit, PyPI, version 1.1.200, which packages have the most dependencies relying on them (i.e., which nodes have the highest in-degree in the graph), and what is the risk associated with a vulnerability in those packages?

<div align="center"> <img src="docs/depsrag_steps.png" alt="Logo" width="700" align="center"> </div> <br><br>

:fire: Updates/Releases

<details> <summary> <b>Click to expand</b></summary> </details>

:gear: Installation and Setup

DepsRAG requires Python 3.11+. We recommend using a virtual environment.

# clone the repo and cd into repo root
git clone https://github.com/Mohannadcse/DepsRAG.git
cd DepsRAG

# create a virtual env under project root, .venv directory
python3 -m venv .venv

# activate the virtual env
. .venv/bin/activate

# install dependencies from pyproject.toml:
# This installs DepsRAG
poetry install 

Set up environment variables (API keys, etc)

DepsRAG requires a set of environment variables to operate. In the root of the repo, copy the .env-template file to a new file .env to set the values of these environment variables.

cp .env-template .env

Following is a description of these environment variables:

docker run --rm \
    --name neo4j \
    -p 7474:7474 -p 7687:7687 \
    -e NEO4J_AUTH=neo4j/password \
    neo4j:latest

Upon creating the cloud account successfully, neo4j will create a text file contains account settings. Please provide the following Neo4j environment variables:

NEO4J_USERNAME=typically neo4j
NEO4J_PASSWORD=your-neo4j-password
NEO4J_URI=uri-to-access-neo4j-dayabase OR bolt://neo4j:7687 if you use Neo4j Docker image
NEO4J_DATABASE=typically neo4j

:whale: Docker Instructions

We provide a containerized version of DepsRAG, where you can run DepsRAG using Chainlit in UI mode or CLI mode.
All you need to do is set up environment variables in the .env (as shown in .env-template) file after clonning DepsRAG repository. We created ths script run_depsrag_docker.sh. So everything will be working in an automated manner. Once you run this script, it will ask you to select the mode for running DepsRAG. Then you can interact with DepsRAG chatbot.

git clone https://github.com/Mohannadcse/DepsRAG.
cd DepsRAG
docker compose build
chmod +x run_depsrag_docker.sh
./run_depsrag_docker.sh

The script run_depsrag_docker.sh spins up two containers: Neo4j and DepsRAG app. After finishing the interaction with DepsRAG chatbot, you can run the command docker compose down to shut down the containers.

Running DepsRAG

DepsRAG supports two modes: CLI and UI (using chainlit).

Run DepsRAG in the CLI mode using this command:

python3 dependencyrag/depsrag_multiagent.py
 -m <LLM-Name>

The flag -m provides the option to overwrite the default LLM (gpt-4o) used by DepsRAG. If you want to use Azure, set the flag -m azure, while for other LLMs, please check Langroid documentation (Open/Local LLMs and other non-OpenAI proprietary LLMs).

Here is a recording shows the CLI mode in action: Demo

Run DepsRAG in the UI mode using this command:

chainlit run dependencyrag/chainlit/chainlit_dependency_chatbot.py

NOTE: the dependency graph is constructed based on DepsDev API. Therefore, the Chatbot will not be able to construct the dependency graph if this API doesn't provide dependency metadata infromation.

DepsRAG Paper Citation

You can find the paper that describes the details of DepsRAG HERE

@inproceedings{depsrag,
  title={DepsRAG: Towards Agentic Reasoning and Planning for Software Dependency Management},
  author={Mohannad Alhanahnah and Yazan Boshmaf},
  booktitle={NeurIPS'24 Workshop on Open-World Agents},
  year={2024}
}