Metadata-Version: 2.4
Name: transformers-fastapi-kit
Version: 0.1.1
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: Documentation, https://transformers-ynoszgzv.manus.space
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.

**Version 0.1.1** now includes a complete tutorial and a ZIP starter bundle inside the installed package.

## 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 project root:

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

The interactive Swagger UI is then available at the API server's `/docs` route. For a public deployment, replace the local address with the public domain assigned to your API service.

```bash
curl -X POST http://127.0.0.1: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`.

## Included tutorial and ZIP bundle

The package includes `transformers_fastapi_kit/resources/TUTORIAL.md` and `transformers_fastapi_kit/resources/transformers-fastapi-kit-starter.zip`.

To locate them after installation:

```python
from importlib.resources import files

resources = files("transformers_fastapi_kit") / "resources"
print(resources / "TUTORIAL.md")
print(resources / "transformers-fastapi-kit-starter.zip")
```

The full public documentation is available at <https://transformers-ynoszgzv.manus.space>.

## Development

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

## License

MIT
