Skip to main content

A package to process CSV text data in batches using OpenAI API

Project description

LLM Batch Processor 🚀

A Python package to process CSV text data in batches using OpenAI's GPT API.

Python License OpenAI API


📌 Features

✅ Processes large CSV files (50K+ rows) in batches of 10 rows
✅ Uses OpenAI GPT-4 API (for now) to generate responses for each row
✅ Saves the results in a new CSV column
✅ CLI support (llm-process) for easy execution
✅ Modular and scalable package design


📂 Project Structure

llm_batch_processor/
│── llm_batch_processor/  # The package
│   │── __init__.py
│   │── config.py         # Configuration settings
│   │── api_client.py     # Handles OpenAI API requests
│   │── processor.py      # Batch processing logic
│── scripts/
│   │── main.py           # CLI entry point
│── data/                 # Place CSV files here
│── setup.py              # Package setup
│── setup.cfg
│── pyproject.toml
│── requirements.txt
│── README.md
│── .gitignore
│── LICENSE

🛠 Installation with repo

1️⃣ Clone the repository

git clone https://github.com/karthikRavichandran/llm_batch_processor.git
cd llm_batch_processor

Or

2️⃣ Install the package

pip install llm-batch-process

3️⃣ Set up OpenAI API Key

Create a .env file in the root directory and add:

OPENAI_API_KEY=your_api_key_here
Project_Id=your_project_id (optional)

or

export OPENAI_API_KEY="your_api_key_here"
export Project_Id="your_project_id" #Optional 

🚀 Usage

1️⃣ Prepare your CSV file

  • Place your input CSV file in the data/ folder.
  • Ensure it has a column containing text (default: "text").

2️⃣ Run the batch processor

llm-process

This will:

  • Read data from data/input.csv
  • Process text in batches of 10 rows
  • Send each batch to OpenAI GPT-4
  • Save responses in data/output.csv under a new column "response"

⚙️ Configuration

Modify config.py for:

BATCH_SIZE = 10  # Number of rows per batch
INPUT_CSV = "data/input.csv"
OUTPUT_CSV = "data/output.csv"
TEXT_COLUMN = "text"
RESPONSE_COLUMN = "response"

🛠 Development

Install dependencies

pip install -r requirements.txt

Run tests

(TODO: Add unit tests)

pytest

📦 Publish to PyPI

1️⃣ Build the package

python setup.py sdist bdist_wheel

2️⃣ Upload to PyPI

twine upload dist/*

3️⃣ Install from PyPI

pip install llm_batch_processor

📜 License

This project is licensed under the MIT License.


💡 Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature-branch)
  3. Commit changes (git commit -m "Added new feature")
  4. Push to branch (git push origin feature-branch)
  5. Create a Pull Request 🚀

📧 Contact

For support or collaboration, reach out via Karthik Ravichandran.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_batch_processor-0.1.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_batch_processor-0.1.3-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file llm_batch_processor-0.1.3.tar.gz.

File metadata

  • Download URL: llm_batch_processor-0.1.3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for llm_batch_processor-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f443473567bdc4f7e09e00bd294fa1828cc6ab74a05e1672cdd647e8512dec6c
MD5 f5e7f0274329e7b6b464c1d7bddcc338
BLAKE2b-256 dbf3e9dc02213da6b2dffaaebcba48ddc85ebe7563fb6d1b1db8b64b568b76d6

See more details on using hashes here.

File details

Details for the file llm_batch_processor-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_batch_processor-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7bbac4df706a525c14a7195a1e36b7fc8b81fe1e83de6f709d1ac4cbff0830c8
MD5 1d4d804c3f8a82721880e4c25b128f85
BLAKE2b-256 90573e32a30155c580db7d1b98a81a6ebe6525c5fd7e2793c8fa66239b98e5b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page