Skip to main content

LLM based context aware text summarizer

Project description

azure-llm-summarizer

A lightweight Python library for summarizing text using Azure OpenAI, with built-in token counting for both input and output — no extra dependencies beyond openai.

Installation

pip install text-summarizer-gi

Quick Start

from llm_summarizer import AzureSummarizer

summarizer = AzureSummarizer(
    api_key="<your-azure-api-key>",
    azure_endpoint="https://<your-resource>.openai.azure.com",
    deployment_name="your-model-deployment",   # your deployed model name
)

result = summarizer.summarize(
    text="Your long document or passage goes here...",
    summary_type="medium",    # "short" | "medium" | "detailed"
    tone="neutral",           # "neutral" | "formal" | "casual"
    focus_area="general",     # "general" | "technical insights" | "financial" ...
    output_format="text",     # "text" | "bullets" | "json"
)

print(result.summary)          # the summary
print(result.input_tokens)     # token count of the original passage
print(result.output_tokens)    # token count of the summary
print(result)                  # summary + token counts in one print

Example Output

Generative AI (GenAI) refers to AI systems that create new content by learning
from large datasets, using architectures like LLMs and diffusion models...

[Tokens — Input: 312 | Summary: 47]

API Reference

AzureSummarizer(azure_endpoint, api_key, api_version, deployment_name)

Parameter Type Default Description
azure_endpoint str env AZURE_OPENAI_ENDPOINT Azure resource endpoint
api_key str env AZURE_OPENAI_API_KEY Azure API key
api_version str "2024-02-15-preview" API version
deployment_name str "gi-local-gpt-5-mini" Deployed model name

.summarize(text, summary_type, tone, focus_area, output_format) → SummaryResult

Parameter Options Default
summary_type "short", "medium", "detailed" "medium"
tone "neutral", "formal", "casual" "neutral"
focus_area any string "general"
output_format "text", "bullets", "json" "text"

SummaryResult

Attribute Type Description
summary str The generated summary
input_tokens int Estimated tokens in the original text
output_tokens int Estimated tokens in the summary

Standalone token counter

from llm_summarizer import count_tokens

count_tokens("Hello, world!")  # → 4

Environment Variables

You can skip passing credentials directly and use env vars instead:

export AZURE_OPENAI_ENDPOINT="https://<resource>.openai.azure.com"
export AZURE_OPENAI_API_KEY="<your-key>"

Publishing to PyPI

pip install build twine
python -m build
twine upload dist/*

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

text_summarizer_gi-0.1.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

text_summarizer_gi-0.1.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file text_summarizer_gi-0.1.1.tar.gz.

File metadata

  • Download URL: text_summarizer_gi-0.1.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for text_summarizer_gi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a26e10c1be6e3dcac82147a5653e32abbdd5d497d549b7ee8e44ea7e4e7601e4
MD5 2a909c16515188ba4f26524f37418c18
BLAKE2b-256 e728d42ba796ee2d27e372f5e98b980f90247261c1a114af9f6e9273f08da825

See more details on using hashes here.

File details

Details for the file text_summarizer_gi-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for text_summarizer_gi-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 752e0f3c4f1f45d23e3e759374dd87102a41c9353031b07a95953202140f811a
MD5 1b914c13b20fba439b9fb34a19acf0a8
BLAKE2b-256 296e82c0d7b7f2dd03979875cf8d0a668ec6554b863b244ef63554392135ea51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page