Skip to content

kashewknutt/autonomous-procurement-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Autonomous Procurement Agent

πŸ“Œ Description

An AI-powered multi-step procurement agent that autonomously negotiates with suppliers via email or chat. It optimizes decisions using internal price policies, REST API integrations, and autonomous reasoning strategies. The agent handles multiple stages of procurement:

  • Search for suppliers
  • Negotiate quotes
  • Embed and compare offers
  • Handle exceptions
  • Update internal databases

This project aims to replicate real-world enterprise agent use cases and will be open-sourced for community contribution and feedback.


πŸš€ Features

  • AI-powered negotiation and follow-up drafting
  • REST API call orchestration and optimization
  • Exception detection and escalation
  • Supplier response embedding and similarity matching
  • Quote storage and ranking in a vector DB
  • Stateless + stateful memory (ReAct / LangChain memory)
  • Cost-aware policy optimization

🧠 Tech Stack

Component Technology
Agent Framework LangChain / AutoGPT
Prompt Logic ReAct, Memory Chains, Prompt Engineering
Embeddings FAISS / Chroma (free)
Backend FastAPI / Flask + PostgreSQL
Hosting DB Local Postgres (free PostgreSQL + API)

Setup

To setup this repo locally

#Clone the repo
git clone https://github.com/kashewknutt/autonomous-procurement-agent.git
cd autonomous-procurement-agent

# Setup a virtual env
python -m venv temp
temp\Scripts\activate

# Install the required packages
pip install -r requirements.txt

# Install spacy model
python -m spacy download en_core_web_sm

# Setup postgres locally and create a redis account
# Create .env and .env variables
# GITHUB_API_TOKEN=""
# DATABASE_URL=""
# REDIS_URL=""

# Start the server
uvicorn app.main:app --reload

# Go ahead! Visit http://localhost:8000/docs to test the server

πŸ› οΈ Local PostgreSQL Setup (Windows)

To run the app locally without Docker, you need a local PostgreSQL instance that matches the following DATABASE_URL format:

postgresql+psycopg2://postgres:postgres@localhost:5432/procurement

Follow these steps to install and configure PostgreSQL on Windows:


1. Download and Install PostgreSQL

  • Visit: https://www.postgresql.org/download/windows/
  • Download the PostgreSQL Installer via EDB and run it.
  • During setup:
    • Choose a version (default is fine)
    • Set password to: postgres (or update .env to match your password)
    • Keep the default port: 5432
    • Install additional tools like pgAdmin (optional but helpful)

2. Create the procurement Database

After installation:

  1. Open pgAdmin or use the SQL Shell (psql).
  2. Run the following SQL commands:
CREATE DATABASE procurement;

If using psql:

psql -U postgres
# Enter password: postgres
postgres=# CREATE DATABASE procurement;

3. Update .env

Make sure your .env file contains:

DATABASE_URL="postgresql+psycopg2://postgres:postgres@localhost:5432/procurement"

Note: Replace localhost with 127.0.0.1 if localhost gives any issues.


4. Install Python Dependencies

pip install -r requirements.txt

5. Initialize the Database

Ensure your app has code to initialize tables (e.g. Base.metadata.create_all(bind=engine)), then run:

python -m app.main

Or, if your project provides a specific init script:

python app/db/init_db.py

You’re now connected to a local PostgreSQL instance running on Windows. Your FastAPI app should work with the database on localhost:5432.


🧭 Strategy

  1. MVP First: Email bot β†’ quote embedder β†’ quote comparator β†’ DB writer.
  2. Agentic Loop: Integrate LangChain agent to make decisions with tools.
  3. Scale Vector Search: Use FAISS/Chroma locally or Supabase’s pgvector.
  4. Open-Source Friendly: All tools must run locally or on free-tier services.
  5. Extensibility: Modular functions, clear API design, config files for tools.

πŸ› οΈ Process Plan

Phase 1: Bootstrap

  • Set up GitHub repo with MIT license
  • Scaffold project with FastAPI + Docker + FAISS
  • Configure Gmail API or SMTP (sandbox email)
  • Add REST API endpoints for testing (quotes, suppliers, etc.)

Phase 2: Agent Framework Integration

  • Integrate LangChain agent loop
  • Build memory (ConversationBufferMemory or RedisMemory)
  • Add tools for: REST API calls, vector DB search, policy check
  • Define ReAct-style prompts

Phase 3: Embedding & Comparison

  • Use sentence-transformers to embed supplier quotes
  • Store vectors using FAISS or ChromaDB
  • Add similarity threshold matching logic

Phase 4: Quote Database

  • Create a PostgreSQL DB schema for quotes and suppliers
  • Build CRUD APIs for quote history

βœ… Checklist

Setup

  • GitHub Repo Initialized
  • Python project scaffolded (FastAPI + poetry/pipenv)
  • .env config file for secrets

AI/Agent

  • LangChain Agent Setup
  • Tools created
  • Memory chain enabled

Embedding & DB

  • SentenceTransformer integration
  • FAISS/Chroma vector DB
  • PostgreSQL tables for quotes and suppliers

πŸ“‚ Project Structure (Suggested)

autonomous-procurement-agent/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ agents/
β”‚   β”œβ”€β”€ embeddings/
β”‚   β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ db/
β”‚   └── utils/
β”œβ”€β”€ tests/
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
└── README.md

πŸ’‘ Future Ideas

  • Slack / Teams bot integration
  • Frontend dashboard (React + Tailwind)
  • Custom vector-based supplier ranking
  • LLM fine-tuning with procurement datasets
  • LLM cost tracking and logging

🀝 Contributing

This project will be open-source. Contributions welcome!

  • Fork the repo
  • Create a feature branch
  • Submit a PR
  • Write tests if possible

🧳 Resources

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages