semvec/pypi-packages huggingface dataset:
modernbert-doc-cls 0.1.0
A document classification library using ModernBERT
Requires Python: >=3.8

# ModernBERT Document Classification

A robust document classification library leveraging **ModernBERT** and **Docling** for state-of-the-art text extraction and classification.

## Features

- **Advanced Extraction**: Uses `docling` and `langchain` to parse complex PDFs, images, and text files with OCR and layout analysis.
- **ModernBERT**: Finetuned on your data for high-performance classification.
- **End-to-End Pipeline**: From raw files to trained model and inference.
- **Metrics & Visualization**: Automated generation of Confusion Matrices, Classification Reports (Precision, Recall, F1).
- **CLI Support**: Easy-to-use command-line interface.

## Installation

```bash
pip install .
```

*Note: Requires `torch`, `docling`, and `tesseract-ocr`/`poppler-utils` (for PDF/Image processing).*

## Usage

### 1. Data Preparation
Organize your data in a folder (e.g., `data_root` which is the default in config) where each subfolder represents a class.

```
data_root/
  ├── invoice/
  │   ├── file1.pdf
  │   └── file2.png
  └── resume/
      ├── file3.txt
      └── file4.pdf
```

### 2. Training (One-Step)
Run the training command. If `dataset.csv` does not exist, the library will automatically extract text from files in `data_dir` (defined in `configs/train_config.yaml`) before training.

```bash
python3 -m modernbert_doc_cls.cli train --config configs/train_config.yaml
```

*Note: You can still run `modernbert-cls extract` manually if preferred.*
Create a configuration file (e.g., `configs/train_config.yaml`):

```yaml
data_path: "dataset.csv"
model_id: "answerdotai/ModernBERT-base"
results_dir: "results"

training_args:
  train_batch_size: 4
  eval_batch_size: 4
  learning_rate: 2e-5
  num_train_epochs: 3
  save_strategy: "epoch"
  eval_strategy: "epoch"
  logging_strategy: "steps"
  logging_steps: 10
  save_total_limit: 2
  metric_for_best_model: "f1"
```

Run training:

```bash
python3 -m modernbert_doc_cls.cli train --config configs/train_config.yaml
```

The model and metrics will be saved in `results/`.



### 4. Inference

#### CLI Usage
Predict the class of a new document.

```bash

python3 -m modernbert_doc_cls.cli predict \
  --model_path results/model \
  --encoder_path results/label_encoder.pkl \
  --file path/to/document.pdf
```

#### Python API Usage
You can also use the library directly in your Python scripts:

```python
from modernbert_doc_cls.inference import DocumentClassifier

# Initialize the classifier
classifier = DocumentClassifier(
    model_path="results/model",
    encoder_path="results/label_encoder.pkl"
)

# Predict
label, confidence = classifier.predict("data_root/class2/invoice.pdf")
print(f"Predicted: {label} ({confidence:.4f})")
```

## License

MIT License
acto 0.6.3
Automate Common Tasks On-demand
Requires Python: >=3.6

# acto
Automate Common Tasks On-demand.

![](https://img.shields.io/pypi/v/acto?label=acto&color=blue&cacheSeconds=60)

## Install

```sh
pip install acto --upgrade
```

## Usage

Run example:

```sh
python -m acto.times
python -m acto.tests
```
anyio 4.12.1
High-level concurrency and networking framework on top of asyncio or Trio
Requires Python: >=3.9

.. image:: https://github.com/agronholm/anyio/actions/workflows/test.yml/badge.svg
  :target: https://github.com/agronholm/anyio/actions/workflows/test.yml
  :alt: Build Status
.. image:: https://coveralls.io/repos/github/agronholm/anyio/badge.svg?branch=master
  :target: https://coveralls.io/github/agronholm/anyio?branch=master
  :alt: Code Coverage
.. image:: https://readthedocs.org/projects/anyio/badge/?version=latest
  :target: https://anyio.readthedocs.io/en/latest/?badge=latest
  :alt: Documentation
.. image:: https://badges.gitter.im/gitterHQ/gitter.svg
  :target: https://gitter.im/python-trio/AnyIO
  :alt: Gitter chat

AnyIO is an asynchronous networking and concurrency library that works on top of either asyncio_ or
Trio_. It implements Trio-like `structured concurrency`_ (SC) on top of asyncio and works in harmony
with the native SC of Trio itself.

Applications and libraries written against AnyIO's API will run unmodified on either asyncio_ or
Trio_. AnyIO can also be adopted into a library or application incrementally – bit by bit, no full
refactoring necessary. It will blend in with the native libraries of your chosen backend.

To find out why you might want to use AnyIO's APIs instead of asyncio's, you can read about it
`here <https://anyio.readthedocs.io/en/stable/why.html>`_.

Documentation
-------------

View full documentation at: https://anyio.readthedocs.io/

Features
--------

AnyIO offers the following functionality:

* Task groups (nurseries_ in trio terminology)
* High-level networking (TCP, UDP and UNIX sockets)

  * `Happy eyeballs`_ algorithm for TCP connections (more robust than that of asyncio on Python
    3.8)
  * async/await style UDP sockets (unlike asyncio where you still have to use Transports and
    Protocols)

* A versatile API for byte streams and object streams
* Inter-task synchronization and communication (locks, conditions, events, semaphores, object
  streams)
* Worker threads
* Subprocesses
* Subinterpreter support for code parallelization (on Python 3.13 and later)
* Asynchronous file I/O (using worker threads)
* Signal handling
* Asynchronous version of the functools_ module

AnyIO also comes with its own pytest_ plugin which also supports asynchronous fixtures.
It even works with the popular Hypothesis_ library.

.. _asyncio: https://docs.python.org/3/library/asyncio.html
.. _Trio: https://github.com/python-trio/trio
.. _structured concurrency: https://en.wikipedia.org/wiki/Structured_concurrency
.. _nurseries: https://trio.readthedocs.io/en/stable/reference-core.html#nurseries-and-spawning
.. _Happy eyeballs: https://en.wikipedia.org/wiki/Happy_Eyeballs
.. _pytest: https://docs.pytest.org/en/latest/
.. _functools: https://docs.python.org/3/library/functools.html
.. _Hypothesis: https://hypothesis.works/
promptguard-sdk 1.2.0
Drop-in security for AI applications - AI Firewall SDK
Requires Python: >=3.8
Keywords: ai, ai-firewall, ai-security, anthropic, llm, llm-security, openai, pii-detection, prompt-injection, security

# PromptGuard Python SDK

Drop-in security for AI applications. No code changes required.

## Installation

```bash
pip install promptguard-sdk
```

## Quick Start

```python
from promptguard import PromptGuard

# Initialize client
pg = PromptGuard(api_key="pg_xxx")

# Use exactly like OpenAI client
response = pg.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response["choices"][0]["message"]["content"])
```

## Drop-in Replacement

If you're already using OpenAI's Python client, just change the import:

```python
# Before
from openai import OpenAI
client = OpenAI()

# After
from promptguard import PromptGuard
client = PromptGuard(api_key="pg_xxx")

# Your existing code works unchanged!
```

## Features

### Security Scanning

```python
# Scan content for threats
result = pg.security.scan("Ignore previous instructions...")

if result["blocked"]:
    print(f"Threat detected: {result['reason']}")
```

### PII Redaction

```python
# Redact PII before sending to LLM
result = pg.security.redact(
    "My email is john@example.com and SSN is 123-45-6789"
)

print(result["redacted_content"])
# Output: "My email is [EMAIL] and SSN is [SSN]"
```

context = memories["formatted_context"]
```

## Async Support

```python
from promptguard import PromptGuardAsync

async with PromptGuardAsync(api_key="pg_xxx") as pg:
    response = await pg.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Hello!"}]
    )
```

## Configuration

```python
from promptguard import PromptGuard, Config

config = Config(
    api_key="pg_xxx",
    base_url="https://api.promptguard.co/api/v1/proxy",
    enable_caching=True,
    enable_security_scan=True,
    timeout=30.0,
)

pg = PromptGuard(config=config)
```

## Environment Variables

```bash
export PROMPTGUARD_API_KEY="pg_xxx"
export PROMPTGUARD_BASE_URL="https://api.promptguard.co/api/v1/proxy"
```

Then just:

```python
from promptguard import PromptGuard

pg = PromptGuard()  # Uses env vars automatically
```

## Error Handling

```python
from promptguard import PromptGuard, PromptGuardError

try:
    response = pg.chat.completions.create(...)
except PromptGuardError as e:
    if e.code == "BLOCKED":
        print(f"Request blocked: {e.message}")
    elif e.code == "RATE_LIMITED":
        print("Rate limited, try again later")
    else:
        raise
```

## License

MIT