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]"

Google Gemini support (requires GOOGLE_API_KEY):

export GOOGLE_API_KEY=your-key
ai-helper ask "Hi" --provider gemini --model gemini-pro

Quickstart

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

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

gemini = GeminiProvider()
print(get_response("Say hi in 3 words", provider=gemini))

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.1.tar.gz (8.5 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.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: csai_helper-0.1.1.tar.gz
  • Upload date:
  • Size: 8.5 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.1.tar.gz
Algorithm Hash digest
SHA256 699b0d8e3caca11f4d757a59fac1cc564e115d55a92b684a6215e5cc2e9b502d
MD5 c300bc9c26e4afd8317b0aaf28c3de87
BLAKE2b-256 4281e802274e968e1f65efecd9220b4e259b493c9ceb9f4e054c726cecec0ad5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: csai_helper-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b376cbb0d66a3325db830951c6f7376fc2006d0aa118f22dbb6cf289ce59dfb
MD5 c0063217264c8f80e6226841aeb41ca3
BLAKE2b-256 ea21efbf1fa97a3bd47042b8cfc909500d395a33d2d68360acbea4086cc77dc2

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