Metadata-Version: 2.4
Name: asta-summarizer
Version: 0.1.1
Summary: A flexible text summarization service supporting multiple AI providers
Author-email: Your Name <your.email@example.com>
License: MIT
Project-URL: Homepage, https://github.com/yourusername/asta-summarizer
Project-URL: Repository, https://github.com/yourusername/asta-summarizer
Project-URL: Issues, https://github.com/yourusername/asta-summarizer/issues
Keywords: text,summarization,ai,nlp,openai,huggingface
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: huggingface-hub>=0.25.0
Requires-Dist: openai>=1.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: isort>=5.12.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Dynamic: license-file

# Asta Summarizer Service

A flexible text summarization service that supports multiple AI providers including OpenAI-compatible APIs and HuggingFace Inference endpoints
with a consistent tone used for Asta.

## Features

- **Multiple Provider Support**: Works with both OpenAI-compatible APIs and HuggingFace Inference clients
- **Flexible Summarization Types**: Support for different summarization styles (default, thread titles, etc.)
- **Customizable Length**: Configure summary length to meet your needs

## Installation

```bash
pip install asta-summarizer
```

## Quick Start

### Using with OpenAI-compatible API

```python
import asyncio
from asta_summarizer import SummarizerService, SummarizationType

async def main():
    # Initialize with base_url for OpenAI-compatible API
    service = SummarizerService(
        base_url="https://your-api-endpoint.com/v1",
        model="your-model-name",
        api_key="your-api-key"  # or set SUMMARIZER_API_KEY environment variable
    )

    text = "Your long text to summarize..."

    summary = await service.summarize(
        text=text,
        length=100,
        summarization_type=SummarizationType.DEFAULT
    )

    print(summary)

if __name__ == "__main__":
    asyncio.run(main())
```

### Using with HuggingFace Provider

```python
import asyncio
from asta_summarizer import SummarizerService, SummarizationType

async def main():
    # Initialize with provider for HuggingFace Inference
    service = SummarizerService(
        provider="huggingface",  # or other supported providers
        model="your-model-name",
        api_key="your-hf-token"  # or set SUMMARIZER_API_KEY environment variable
    )

    text = "Your long text to summarize..."

    summary = await service.summarize(
        text=text,
        length=200,
        summarization_type=SummarizationType.THREAD_TITLE
    )

    print(summary)

if __name__ == "__main__":
    asyncio.run(main())
```

## Configuration

### Initialization Parameters

- **model** (required): The model name to use for summarization
- **base_url** (optional): Base URL for OpenAI-compatible APIs (mutually exclusive with provider)
- **provider** (optional): Provider name for HuggingFace Inference (mutually exclusive with base_url)
- **api_key** (optional): API key for authentication (defaults to `SUMMARIZER_API_KEY` environment variable)

### Summarization Types

The service supports different summarization styles via the `SummarizationType` enum:

- `SummarizationType.DEFAULT`: Standard summarization. Pass in your own prompt alongside the text to summarize in the `text` field.
- `SummarizationType.THREAD_TITLE`: Optimized for creating thread titles

### Environment Variables

Set your API key as an environment variable:

```bash
export SUMMARIZER_API_KEY="your-api-key-here"
```

## Development

### Installing Dependencies

For development work:

```bash
# Install package in editable mode with development dependencies
pip install -e ".[dev]"
```

Or install dependencies manually:

```bash
# Core dependencies
pip install huggingface-hub>=0.20.0 openai>=1.0.0

# Development dependencies
pip install pytest>=7.0.0 pytest-asyncio>=0.21.0 black>=23.0.0 isort>=5.12.0 mypy>=1.0.0
```

### Code Formatting

```bash
black .
isort .
```

### Type Checking

```bash
mypy asta_summarizer/
```

## Publication

You can publish a new version from your branch before merging to main, or from main after merging.

Edit the `version.txt` file with the new version, then run

```
export AI2_NORA_PYPI_TOKEN=<SECRET IN NORA VAULT>
make publish
```

This will publish the summarizer with the version number contained in `version.txt`

## License

MIT License - see [LICENSE](LICENSE) file for details.
