Metadata-Version: 2.4
Name: fintom8
Version: 0.1.0
Summary: LiteLLM connector for Gemini, Vertex AI, OpenAI, and Azure — chat, stream, and document extract.
Project-URL: Homepage, https://github.com/fintom8/f_templates
Project-URL: Documentation, https://github.com/fintom8/f_templates/tree/main/fintom8
License: MIT
Keywords: azure,gemini,litellm,llm,openai,vertex
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: litellm<2.0.0,>=1.94.0
Requires-Dist: python-dotenv>=1.0.0
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: twine>=5.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# fintom8

LiteLLM connector for **Gemini / Vertex AI / OpenAI / Azure**. Chat, stream, and document extract. Students install with pip and call a few methods — keys stay in `.env`.

```bash
pip install fintom8
```

```python
from fintom8 import LLM

llm = LLM()  # reads .env / environment
print(llm.chat("Summarize this invoice").text)
```

Local development from this repo:

```bash
pip install -e ./fintom8
# or: pip install -e "./fintom8[dev]"
```

## Configuration

Resolution order: **constructor kwargs / `LLMConfig` > environment > defaults**.

Copy [`.env.example`](./.env.example) to `.env` in your project (never commit it).

| Param | Env | Default | When needed |
|-------|-----|---------|-------------|
| `model` | `LLM_MODEL` | `gemini/gemini-3.5-flash` | always |
| `temperature` | `LLM_TEMPERATURE` | `0.0` | optional |
| `num_retries` | — | `3` | optional |
| `api_key` | `GEMINI_API_KEY` / `OPENAI_API_KEY` / `AZURE_API_KEY` (from model prefix) | unset | Gemini / OpenAI / Azure |
| `api_base` | `AZURE_API_BASE` / `OPENAI_API_BASE` | unset | Azure (required) |
| `api_version` | `AZURE_API_VERSION` | `2024-10-21` | Azure |
| `vertex_project` | `VERTEXAI_PROJECT` | unset | Vertex |
| `vertex_location` | `VERTEXAI_LOCATION` | `eu` | Vertex |

```python
from fintom8 import LLM, LLMConfig

llm = LLM()  # env defaults
llm = LLM(model="gpt-4o", api_key="sk-...", temperature=0)
llm = LLM(LLMConfig(
    model="azure/my-deploy",
    api_key="...",
    api_base="https://....openai.azure.com",
    api_version="2024-10-21",
))
```

### Switch provider

| `LLM_MODEL` | Env |
|-------------|-----|
| `gemini/gemini-3.5-flash` | `GEMINI_API_KEY` |
| `vertex_ai/gemini-3.5-flash` | `VERTEXAI_PROJECT` + `VERTEXAI_LOCATION` + ADC (`gcloud auth application-default login`) |
| `gpt-4o` | `OPENAI_API_KEY` |
| `azure/<deployment>` | `AZURE_API_KEY` + `AZURE_API_BASE` + `AZURE_API_VERSION` |

## Usage

```python
from fintom8 import LLM

llm = LLM()

resp = llm.chat("Hello")
resp = llm.chat(
    [{"role": "user", "content": "Extract the invoice total"}],
    response_schema={
        "type": "object",
        "properties": {"total": {"type": "number"}},
        "required": ["total"],
    },
    schema_name="Invoice",
)
print(resp.text, resp.data, resp.usage)

for chunk in llm.stream([{"role": "user", "content": "Write a haiku"}]):
    print(chunk, end="", flush=True)

resp = llm.extract("invoice.pdf", response_schema={...})
```

Async twins for FastAPI / async scripts: `achat`, `astream`, `aextract`.

Structured-output helpers (also used internally): `json_schema_response_format`, `enforce_strict`, `inline_refs`.

Failures raise `Fintom8Error`.

See [`examples/chat.py`](./examples/chat.py) and [`examples/extract.py`](./examples/extract.py).

## Publish (maintainers)

1. Install dev extras and run tests:

   ```bash
   cd fintom8
   pip install -e ".[dev]"
   pytest
   python -c "from fintom8 import LLM"
   ```

2. Build:

   ```bash
   python -m build
   ```

3. Upload to TestPyPI first, then PyPI:

   ```bash
   python -m twine upload --repository testpypi dist/*
   python -m twine upload dist/*
   ```

4. Tag for CI Trusted Publishing (OIDC). Create the PyPI project once and add a GitHub environment `pypi` with Trusted Publisher pointing at `.github/workflows/publish-fintom8.yml`. Then:

   ```bash
   git tag fintom8-v0.1.0
   git push origin fintom8-v0.1.0
   ```
