Skip to main content

Lightweight helpers for AI prompts, summarization, and formatting.

Project description

csai-helper

Lightweight helpers for AI prompting, summarization, and response formatting. Ships with a pluggable provider interface and optional OpenAI provider.

Installation

From source (editable):

pip install -e .[dev]

For runtime only (from PyPI):

pip install csai-helper

Optional OpenAI support:

pip install "csai-helper[openai]"

Quickstart

from ai_helper import get_response, summarize_text, format_response
from ai_helper.providers.local import LocalProvider

provider = LocalProvider()
print(get_response("Hello, AI!", provider=provider))

text = """Python is a popular programming language created by Guido van Rossum.
It is used for web development, data science, automation, and more."""
print(summarize_text(text, provider=provider, max_words=20))

print(format_response("  Hello\n\nWorld  "))

CLI

ai-helper ask "Tell me a joke"
ai-helper summarize "Long text here..." --max-words 30

Set OPENAI_API_KEY in your environment to use the OpenAI provider:

export OPENAI_API_KEY=sk-...
ai-helper ask "Explain transformers in 2 sentences" --provider openai --model gpt-4o-mini

API

  • get_response(prompt, provider=None, **kwargs) → str
  • summarize_text(text, provider=None, max_words=120, **kwargs) → str
  • format_response(text) → str

Providers implement AIProvider.get_response(prompt, system_prompt=None, **kwargs).

Development

Run formatting and tests:

ruff check .
pytest

Publishing

  1. Build distributions:

    python -m build
    
  2. Upload to PyPI (requires twine):

    python -m pip install --upgrade twine
    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

csai_helper-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

csai_helper-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file csai_helper-0.1.0.tar.gz.

File metadata

  • Download URL: csai_helper-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for csai_helper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 82463321d3f3a549d079bb7237fe9bb820adef8c9f9b904ef60310ff4b9314b2
MD5 14f05be6716f2eca3832464fa86ebda4
BLAKE2b-256 33bbde32da0356c4a6205b09cfec443bb4d25cd45bb4bbf9a239bdcc6d46e014

See more details on using hashes here.

File details

Details for the file csai_helper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: csai_helper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for csai_helper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bae18a5f63d310e3d1b2f9b0d382e881f903eec21743330f71e75b7bfcbadb38
MD5 07415eab17a9e80412166eb9f6f4f416
BLAKE2b-256 8a0563eb9155ff26d256ac73cdc6ba09fa6e4e36c7ebf14a375ba2107d6b3350

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