Skip to content

chloepilonv/knowledgegraph-email-agent

 
 

Repository files navigation

Invoice Reconciliation Agent

Paste a vendor claim or accusation — the agent retrieves evidence from multiple sources and drafts a professional email reply.

Built during the Cognee AI-Memory Hackathon.

Landing Page

Generated Email Reply

Qdrant Search Parameters

How It Works

Vendor claim
    |
    v
Qdrant vector search (5 search strategies)
    + Cognee knowledge graph retrieval
    |
    v
Sentiment analysis (zero-shot via Qdrant)
    |
    v
LLM drafts email reply with evidence

Search strategies used:

  1. Semantic search — vector similarity on invoice/transaction chunks
  2. Entity search — knowledge graph entities (products, vendors, SKUs)
  3. RRF Fusion — combines broad + vendor-filtered results via Reciprocal Rank Fusion
  4. Nearest neighbor — similar documents to the top fusion result
  5. Sentiment classification — embeds claim against anchor phrases per sentiment category (angry, frustrated, neutral, urgent)

Stack

  • Qdrant — vector store (6 collections, 14k+ vectors)
  • Cognee — knowledge graph memory + retrieval
  • Ollama — local embeddings (nomic-embed-text, 768d)
  • OpenAI or Distil Labs SLM — LLM reasoning
  • Streamlit — UI (pixel/retro theme)

Setup

Requires a Qdrant instance (cloud or local Docker) with the hackathon snapshot data restored, plus Ollama running locally for embeddings.

# Clone and install
git clone https://github.com/chloepilonv/cognee-reconciliation-agent.git
cd cognee-reconciliation-agent
uv venv && source .venv/bin/activate
uv sync

# Ollama (embeddings)
brew install ollama && ollama serve &
cd models
ollama create nomic-embed-text -f nomic-embed-text/Modelfile
cd ..

# Qdrant (local Docker option)
docker run -d --name qdrant -p 6333:6333 -p 6334:6334 \
  -v qdrant_storage:/qdrant/storage qdrant/qdrant

# Restore knowledge graph + vector data
python setup.py
uv run python restore-snapshots.py

# Environment
cp .env.example .env
# Edit .env: fill in QDRANT_URL, QDRANT_API_KEY, optionally OPENAI_API_KEY

# Run
.venv/bin/python -m streamlit run project4-invoice-tracker/app.py

Config

Variable Required Description
QDRANT_URL yes Qdrant cluster URL
QDRANT_API_KEY yes Qdrant API key
OPENAI_API_KEY no Falls back to local Ollama LLM if not set

Data

After snapshot restore, Qdrant contains:

Collection Records Content
DocumentChunk_text 2,000 Invoice and transaction chunks
Entity_name 8,816 Products, vendors, SKUs
Sentiment_anchors 16 Sentiment classification anchors (auto-created)

Plus 3 supporting collections (EntityType, EdgeType, TextDocument, TextSummary).

Project Structure

project4-invoice-tracker/
  app.py              — Streamlit UI + evidence builder
  qdrant_helpers.py   — all Qdrant interactions (5 search methods + sentiment)
  cognee_helpers.py   — Cognee knowledge graph retriever
  analysis.py         — payment analysis (unpaid/late detection)
  styles.py           — pixel/Minecraft CSS theme
custom_retriever.py   — GraphCompletionRetriever (shared)
prompts/              — system + user prompts for LLM

About

2hrs Hackathon!! Using Cognee for knowledge graph and Qdrant for vector search & embeddings - Built a Reconciliation Agent to generate e-mail with relevant infos to answers vendors claiming unpaid, late, uncomplete, etc. payments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%