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
pip install asta-summarizer
Quick Start
Using with OpenAI-compatible API
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
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_KEYenvironment 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 thetextfield.SummarizationType.THREAD_TITLE: Optimized for creating thread titles
Environment Variables
Set your API key as an environment variable:
export SUMMARIZER_API_KEY="your-api-key-here"
Development
Installing Dependencies
For development work:
# Install package in editable mode with development dependencies
pip install -e ".[dev]"
Or install dependencies manually:
# 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
black .
isort .
Type Checking
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 file for details.
Metadata
Release files for asta-summarizer 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asta_summarizer-0.1.1.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asta_summarizer-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.6 kB
Release files / asta_summarizer-0.1.1.tar.gz
| Download URL | asta_summarizer-0.1.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa733b05a712df4ecaca3e33961ae00a5af88dd0e82c57bc6cae2681dd066f5e
|
|
BLAKE2b-256 checksum How to use checksums |
3b6b43d8511f19adb3d466abde95904cc8774d0260b592f6b3c66a4511d4c158
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / asta_summarizer-0.1.1-py3-none-any.whl
| Download URL | asta_summarizer-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
275d5d17a3f8cb8511c08f3631e448819ef3ef478668447b17a902e37eeedd6b
|
|
BLAKE2b-256 checksum How to use checksums |
ef85b5c896f6d8766a1e74b4a40be18c873c35e93553fc35e12034ca7dfbe88e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|