A7medAyman/Agentic-Procurement-Assistant
0
Agentic Procurement Assistant
A modular, agent-based system that automates product research, extraction, and procurement report generation using AI and web automation.
Table of Contents
- Overview
- Architecture & Workflow
- Workflow Diagram
- File Structure Diagram
- Technologies Used
- Detailed File Explanations
- Dockerfile
- main.py
- unit_test/
- routers/
- helpers/
- agents/
- controllers/
- Agentic Procurement Assistant API
- Endpoint
- Input Parameters
- Response
- Quickstart
- Contact
Overview
Agentic Procurement Assistant leverages a crew of AI agents to automate the procurement process:
- Recommends search queries for products.
- Searches e-commerce platforms.
- Scrapes product details.
- Generates a professional procurement report (HTML).
Architecture & Workflow
Workflow Diagram
flowchart TD
A[User API Request] --> B[Search Queries Recommendation Agent]
B --> C[Search Engine Agent]
C --> D[Web Scraping Agent]
D --> E[Procurement Report Author Agent]
E --> F[HTML/JSON Output]File Structure Diagram
graph TD
A[src]
A1[main.py] --> A
A2[routers/] --> A
A3[controllers/] --> A
A4[agents/] --> A
A5[helpers/] --> A
A6[agent_output/] --> A
A7[unit_test/] --> A
B[notebooks/]
C[Dockerfile]
D[.env]
E[requirements.txt]Technologies Used
- crewai
- tavily-python
- scrapegraph-py
- fastapi
- uvicorn[standard]
- python-multipart
- pydantic
- python-dotenv
- pytest
Detailed File Explanations
Dockerfile
- Purpose: Containerizes the application for consistent deployment and execution.
- What it does:
- Sets up a Python environment.
- Installs dependencies from
requirements.txt. - Copies the application code into the container.
- Sets environment variables and exposes the necessary port.
- Defines the default command to run the FastAPI server.
- Tools Used: Docker, Python, Uvicorn.
main.py
- Purpose: Entry point for the FastAPI application.
- What it does:
- Initializes the FastAPI app.
- Includes routers (API endpoints).
- Starts the application server.
- Tools Used: FastAPI, Uvicorn.
unit_test/
- Purpose: Contains automated tests to ensure code correctness.
- What it does:
test_procurement_report.py: Tests the procurement report generation logic, including agent orchestration.- Tools Used: Pytest, FastAPI TestClient.
routers/
- Purpose: Defines API endpoints and request/response handling.
- What it does:
CrewRouter.py: Implements the/api/get_procurement_reviewendpoint.- Calls the controller to run the agent workflow, and returns the output file.
- Tools Used: FastAPI APIRouter, Pydantic.
helpers/
- Purpose: Provides utility functions and configuration management.
- What it does:
config.py: Loads environment variables and configuration settings (e.g., API keys, file paths) for use throughout the app.- Tools Used: Python
os, dotenv.
agents/
- Purpose: Defines the agents, their tasks, tools, and output schemas.
- What it does:
config/agents.yaml: YAML file specifying agent role, goal, and backstory.config/tasks.yaml: YAML file defining the sequence and dependencies of tasks.output_schema.py: Pydantic models that define the structure of agent outputs (e.g., search results, product details).tools.py: Integrates external tools (Tavily for search, Scrapegraph for scraping) and provides a unified interface for agents to use them.- Tools Used: CrewAI, Pydantic, Tavily, Scrapegraph, YAML.
controllers/
- Purpose: Orchestrates the workflow of agents and manages the overall process.
- What it does:
CrewControllers.py: Loads agent and task configurations, initializes agents, runs them in the correct order, collects outputs, and generates the final procurement report (HTML/JSON).- Tools Used: CrewAI, Python, file I/O.
Agentic Procurement Assistant API
Hosted at:
https://A7medAyman-Agentic-Procurement-Assistant.hf.space/api/get_procurement_review
Endpoint
Method: POST URL: /api/get_procurement_review Content-Type: multipart/form-data
Input Parameters
Response
- File:
procurement_report.html - Content: A professional HTML report with product tables, price comparisons, and recommendations.
- test output
**note:** if you get this message as a response
{"message": "An error occurred while running the crew litellm.APIConnectionError: Cohere_chatException - {\"id\":\"5cb1c64b-e3a1-4ff9-a06c-b8f436733d25\",\"message\":\"You are using a Trial key, which is limited to 10 API calls / minute. You can continue to use the Trial key for free or upgrade to a Production key with higher rate limits at 'https://dashboard.cohere.com/api-keys'. Contact us on 'https://discord.gg/XW44jPfYJu' or email us at support@cohere.com with any questions\"}."This indicates that the free trial key from Cohere has hit its usage limit :(. ---
Quickstart
- Clone the repository:
git clone git@github.com:AhmedAyman77/Agentic-Procurement-Assistant.git
cd Agentic-Procurement-Assistant- active your conda env
conda activate your_env_name- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
cp src/.env.example src/.env Edit src/.env and fill in your API keys.
- Run the FastAPI server:
cd src
uvicorn main:app --reload --host 0.0.0.0 --port 5000- Access the API docs:
$BROWSER http://localhost:5000/docsContact
For questions or support, please contact: Email: devahmedaymn@gmail.com LinkIn: Link
