# 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.
Raw data
{
"_id": null,
"home_page": null,
"name": "asta-summarizer",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "text, summarization, ai, nlp, openai, huggingface",
"author": null,
"author_email": "Your Name <your.email@example.com>",
"download_url": "https://files.pythonhosted.org/packages/75/ea/9645ca0e0fa99dea06fefcada4037fe8305bf1f215cf5322e3113b17c5fb/asta_summarizer-0.1.0.tar.gz",
"platform": null,
"description": "# Asta Summarizer Service\n\nA flexible text summarization service that supports multiple AI providers including OpenAI-compatible APIs and HuggingFace Inference endpoints\nwith a consistent tone used for Asta.\n\n## Features\n\n- **Multiple Provider Support**: Works with both OpenAI-compatible APIs and HuggingFace Inference clients\n- **Flexible Summarization Types**: Support for different summarization styles (default, thread titles, etc.)\n- **Customizable Length**: Configure summary length to meet your needs\n\n## Installation\n\n```bash\npip install asta-summarizer\n```\n\n## Quick Start\n\n### Using with OpenAI-compatible API\n\n```python\nimport asyncio\nfrom asta_summarizer import SummarizerService, SummarizationType\n\nasync def main():\n # Initialize with base_url for OpenAI-compatible API\n service = SummarizerService(\n base_url=\"https://your-api-endpoint.com/v1\",\n model=\"your-model-name\",\n api_key=\"your-api-key\" # or set SUMMARIZER_API_KEY environment variable\n )\n\n text = \"Your long text to summarize...\"\n\n summary = await service.summarize(\n text=text,\n length=100,\n summarization_type=SummarizationType.DEFAULT\n )\n\n print(summary)\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n```\n\n### Using with HuggingFace Provider\n\n```python\nimport asyncio\nfrom asta_summarizer import SummarizerService, SummarizationType\n\nasync def main():\n # Initialize with provider for HuggingFace Inference\n service = SummarizerService(\n provider=\"huggingface\", # or other supported providers\n model=\"your-model-name\",\n api_key=\"your-hf-token\" # or set SUMMARIZER_API_KEY environment variable\n )\n\n text = \"Your long text to summarize...\"\n\n summary = await service.summarize(\n text=text,\n length=200,\n summarization_type=SummarizationType.THREAD_TITLE\n )\n\n print(summary)\n\nif __name__ == \"__main__\":\n asyncio.run(main())\n```\n\n## Configuration\n\n### Initialization Parameters\n\n- **model** (required): The model name to use for summarization\n- **base_url** (optional): Base URL for OpenAI-compatible APIs (mutually exclusive with provider)\n- **provider** (optional): Provider name for HuggingFace Inference (mutually exclusive with base_url)\n- **api_key** (optional): API key for authentication (defaults to `SUMMARIZER_API_KEY` environment variable)\n\n### Summarization Types\n\nThe service supports different summarization styles via the `SummarizationType` enum:\n\n- `SummarizationType.DEFAULT`: Standard summarization. Pass in your own prompt alongside the text to summarize in the `text` field.\n- `SummarizationType.THREAD_TITLE`: Optimized for creating thread titles\n\n### Environment Variables\n\nSet your API key as an environment variable:\n\n```bash\nexport SUMMARIZER_API_KEY=\"your-api-key-here\"\n```\n\n## Development\n\n### Installing Dependencies\n\nFor development work:\n\n```bash\n# Install package in editable mode with development dependencies\npip install -e \".[dev]\"\n```\n\nOr install dependencies manually:\n\n```bash\n# Core dependencies\npip install huggingface-hub>=0.20.0 openai>=1.0.0\n\n# Development dependencies\npip install pytest>=7.0.0 pytest-asyncio>=0.21.0 black>=23.0.0 isort>=5.12.0 mypy>=1.0.0\n```\n\n### Code Formatting\n\n```bash\nblack .\nisort .\n```\n\n### Type Checking\n\n```bash\nmypy asta_summarizer/\n```\n\n## Publication\n\nYou can publish a new version from your branch before merging to main, or from main after merging.\n\nEdit the `version.txt` file with the new version, then run\n\n```\nexport AI2_NORA_PYPI_TOKEN=<SECRET IN NORA VAULT>\nmake publish\n```\n\nThis will publish the summarizer with the version number contained in `version.txt`\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A flexible text summarization service supporting multiple AI providers",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/yourusername/asta-summarizer",
"Issues": "https://github.com/yourusername/asta-summarizer/issues",
"Repository": "https://github.com/yourusername/asta-summarizer"
},
"split_keywords": [
"text",
" summarization",
" ai",
" nlp",
" openai",
" huggingface"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "67b91dedc29e159c337344834d49aa5f40c5751f511f2f7deff33b928ea81f00",
"md5": "638a2e50890bb60d7184a04d42f235f1",
"sha256": "b8ac397ea7e3917f721a2b50a3bf1165d8477f45f3afa709dc9b2f9b3b75f127"
},
"downloads": -1,
"filename": "asta_summarizer-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "638a2e50890bb60d7184a04d42f235f1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6909,
"upload_time": "2025-07-23T20:49:40",
"upload_time_iso_8601": "2025-07-23T20:49:40.863771Z",
"url": "https://files.pythonhosted.org/packages/67/b9/1dedc29e159c337344834d49aa5f40c5751f511f2f7deff33b928ea81f00/asta_summarizer-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "75ea9645ca0e0fa99dea06fefcada4037fe8305bf1f215cf5322e3113b17c5fb",
"md5": "1d334a1068bff69ba4205211fe6d651c",
"sha256": "4211f6aef0612cfa0e10db6468385cf2bf52f06f432337e5cf7298a9fbf7cc21"
},
"downloads": -1,
"filename": "asta_summarizer-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "1d334a1068bff69ba4205211fe6d651c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 7616,
"upload_time": "2025-07-23T20:49:44",
"upload_time_iso_8601": "2025-07-23T20:49:44.549357Z",
"url": "https://files.pythonhosted.org/packages/75/ea/9645ca0e0fa99dea06fefcada4037fe8305bf1f215cf5322e3113b17c5fb/asta_summarizer-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-23 20:49:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "asta-summarizer",
"github_not_found": true,
"lcname": "asta-summarizer"
}