Metadata-Version: 2.4
Name: transformers-fastapi-kit
Version: 0.2.0
Summary: Hugging Face Transformers sentiment and conversational inference with FastAPI.
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,chatbot,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
Requires-Dist: huggingface_hub>=0.24.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

Biblioteca Python com Hugging Face Transformers para análise de sentimento e chatbot conversacional via **Hugging Face Inference API**, acompanhada por um servidor FastAPI.

## Instalação

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

## Chatbot conversacional

A classe `HuggingFaceChatbot` usa a API oficial de inferência da Hugging Face. Cria um token em <https://huggingface.co/settings/tokens> com permissão de inferência e configura-o sem o colocar no código.

Windows PowerShell:

```powershell
$env:HF_TOKEN = "hf_o_teu_token"
```

macOS/Linux:

```bash
export HF_TOKEN="hf_o_teu_token"
```

Uso em Python:

```python
from transformers_fastapi_kit import HuggingFaceChatbot

bot = HuggingFaceChatbot()
print(bot.chat("Olá! Explica o que podes fazer."))
```

Para manter contexto, envia o histórico:

```python
history = [{"role": "user", "content": "Olá"}, {"role": "assistant", "content": "Olá!"}]
reply = bot.chat("Podes ajudar-me com Python?", history=history)
```

O modelo por defeito é `HuggingFaceH4/zephyr-7b-beta`; podes escolher outro modelo de chat compatível com `HuggingFaceChatbot(model_name="...")`.

## API REST

```bash
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
```

Endpoints: `GET /health`, `POST /predict` e `POST /chat`. A documentação Swagger fica em `/docs`.

Pedido de chat:

```bash
curl -X POST http://127.0.0.1:8000/chat \\
  -H "Content-Type: application/json" \\
  -d '{"message":"Olá! Quem és?","history":[]}'
```

## Recursos incluídos

O pacote inclui `transformers_fastapi_kit/resources/TUTORIAL.md` e `transformers_fastapi_kit/resources/transformers-fastapi-kit-starter.zip`.

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

Documentação pública: <https://transformers-ynoszgzv.manus.space>

## Desenvolvimento

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

## Licença

MIT
