Metadata-Version: 2.4
Name: transformers-fastapi-kit
Version: 0.1.0
Summary: A clean Hugging Face Transformers inference wrapper with a FastAPI REST server.
Author: Transformers FastAPI Kit Contributors
License: MIT
Project-URL: Homepage, https://pypi.org/project/transformers-fastapi-kit/
Project-URL: Repository, https://github.com/example/transformers-fastapi-kit
Keywords: transformers,huggingface,fastapi,nlp,machine-learning
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: transformers>=4.40.0
Requires-Dist: torch>=2.0.0
Provides-Extra: api
Requires-Dist: fastapi>=0.110.0; extra == "api"
Requires-Dist: uvicorn[standard]>=0.29.0; extra == "api"
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: httpx>=0.27.0; extra == "dev"

# Transformers FastAPI Kit

A small, production-oriented wrapper around [Hugging Face Transformers](https://huggingface.co/docs/transformers) plus a FastAPI REST service for sentiment analysis.

## Install

```bash
pip install transformers-fastapi-kit[api]
```

The first prediction downloads the default model (`distilbert-base-uncased-finetuned-sst-2-english`) from Hugging Face and caches it locally.

## Python usage

```python
from transformers_fastapi_kit import SentimentModel

model = SentimentModel()
print(model.predict("This package is excellent!"))
# {'label': 'POSITIVE', 'score': 0.99...}
```

Use a different model with `SentimentModel(model_name="...")`; pass `device=0` for a CUDA GPU or leave the default `-1` for CPU.

## Run the API

From the repository root:

```bash
pip install -e ".[api]"
uvicorn app.main:app --host 0.0.0.0 --port 8000
```

Interactive Swagger UI: <http://localhost:8000/docs>

```bash
curl -X POST http://localhost:8000/predict \\
  -H 'Content-Type: application/json' \\
  -d '{"text":"I love this API"}'
```

Endpoints: `GET /health`, `POST /predict`, and the generated OpenAPI schema at `/openapi.json`.

## Development

```bash
pip install -e ".[api,dev]"
pytest
python -m build
python -m twine check dist/*
```

## License

MIT
