Skip to main content

🧘 Calmlib v2.0

A Python library for calm and productive development

Python Version Poetry License

Calmlib is a comprehensive Python utility library designed to make development more productive and less stressful. It provides clean, well-organized modules for common development tasks including LLM interactions, audio processing, logging, user interactions, Telegram bot development, and more.

✨ Features

🤖 LLM Integration (calmlib.llm)

  • Simple, unified interface for multiple LLM providers via LiteLLM
  • Support for both synchronous and asynchronous operations
  • Structured output parsing with Pydantic
  • Built-in validation and error handling

🎵 Audio Processing (calmlib.audio)

  • Audio file manipulation and conversion
  • Whisper integration for speech-to-text
  • Audio utility functions for common operations

📝 Smart Logging (calmlib.logging)

  • Enhanced logging with multiple output formats
  • Structured logging support
  • Easy configuration and setup

💬 User Interactions (calmlib.user_interactions)

  • Interactive CLI prompts and confirmations
  • Multiple input engines (CLI, GUI, etc.)
  • Type-safe user input collection

🤖 Telegram Bot Tools (calmlib.telegram)

  • Telegram bot development utilities
  • Secure bot key management
  • Telethon client integration
  • Service bot templates

🌐 Translation (calmlib.translate)

  • DeepL API integration
  • Simple translation workflows
  • Multi-language support

🛠️ Utilities (calmlib.utils)

  • Path handling and file operations
  • Environment variable discovery
  • Check mode for safe operations
  • DotDict for easy nested data access
  • Enum casting and comparison utilities

🚀 Installation

# Clone the repository
git clone https://github.com/calmmage/calmlib.git
cd calmlib

# Install with poetry
poetry install

# For development with all extras
poetry install --with extras,test,dev

Using pip

pip install git+https://github.com/calmmage/calmlib.git

📖 Quick Start

LLM Queries

import calmlib

# Simple text query
response = calmlib.query_llm_text("Explain quantum computing in simple terms")
print(response)

# Structured output
from pydantic import BaseModel

class Summary(BaseModel):
    title: str
    key_points: list[str]
    sentiment: str

summary = calmlib.query_llm_structured(
    "Summarize this text: ...", 
    response_model=Summary
)
print(f"Title: {summary.title}")

User Interactions

import calmlib

# Ask for user input
name = calmlib.ask_user("What's your name?")
age = calmlib.ask_user("What's your age?", int)

# Multiple choice
choice = calmlib.ask_user_choice(
    "Choose your preferred language:",
    ["Python", "JavaScript", "Rust", "Go"]
)

# Confirmation
if calmlib.ask_user_confirmation("Delete all files?"):
    print("Confirmed!")

Logging Setup

import calmlib

# Setup enhanced logging
logger = calmlib.setup_logger(
    name="my_app",
    mode=calmlib.LogMode.BOTH,  # Console + file
    format=calmlib.LogFormat.DETAILED
)

logger.info("Application started")
logger.error("Something went wrong", extra={"user_id": 123})

Utilities

import calmlib
from pathlib import Path

# Path handling
safe_path = calmlib.fix_path("~/documents/file.txt")

# Environment discovery
api_key = calmlib.find_env_key(["OPENAI_API_KEY", "OPENAI_TOKEN"])

# Check mode (safe operations)
from calmlib.utils.check_mode import check_mode

@check_mode.enabled
def dangerous_operation():
    # This will be skipped in check mode
    delete_important_files()

📂 Module Overview

Core Modules

Module Description Key Features
llm LLM integration and utilities LiteLLM wrapper, structured outputs, async support
audio Audio processing tools Whisper integration, audio manipulation
logging Enhanced logging capabilities Multiple formats, structured logging
user_interactions CLI and user input tools Interactive prompts, type validation
telegram Telegram bot development Bot management, secure key storage
translate Translation services DeepL integration, multi-language support
utils General utilities Path handling, environment discovery, data structures

🏗️ Architecture

Calmlib v2.0 features a clean, modular architecture:

calmlib/
├── llm/           # LLM integration (LiteLLM, structured outputs)
├── audio/         # Audio processing (Whisper, audio utils)  
├── logging/       # Enhanced logging capabilities
├── telegram/      # Telegram bot development tools
├── translate/     # Translation services (DeepL)
├── user_interactions/  # Interactive CLI tools
└── utils/         # Core utilities and helpers

🔧 Configuration

Calmlib uses environment variables for configuration. Create a .env file:

# LLM Configuration
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key

# Translation
DEEPL_AUTH_KEY=your_deepl_key

# Telegram
TELEGRAM_BOT_TOKEN=your_bot_token

🧪 Testing

# Run tests
poetry run pytest

# Run tests with coverage
poetry run pytest --cov=calmlib

# Run specific test module
poetry run pytest tests/test_llm.py

🛠️ Development

Setting up development environment

# Clone the repository
git clone https://github.com/calmmage/calmlib.git
cd calmlib

# Install development dependencies
poetry install --with extras,test,dev

# Setup pre-commit hooks
poetry run pre-commit install

# Run code quality checks
poetry run ruff check .
poetry run black .

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Run the test suite: poetry run pytest
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Built with Poetry for dependency management
  • LLM integration powered by LiteLLM
  • Audio processing using Whisper
  • Telegram integration via Aiogram

Made with ❤️ for productive and calm development

Metadata

Release files for calmlib 2.0.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for calmlib 2.0.17
File Size Uploaded Provenance Actions
calmlib-2.0.17.tar.gz 188.5 kB Without provenance Details for calmlib-2.0.17.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for calmlib 2.0.17
File Interpreter ABI Platform Actions
calmlib-2.0.17-py3-none-any.whl Python 3 none any Details for calmlib-2.0.17-py3-none-any.whl

Total release size: 426.7 kB

Release files / calmlib-2.0.17.tar.gz

Download URL calmlib-2.0.17.tar.gz
Size 188.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e4810d675c98c0308fd2d97f8da6c6d8992fb01d6ddc9536f22a07bf7cac4e06
BLAKE2b-256 checksum
How to use checksums
ed52dacda7cf32e3cba0d4f07a12490d058985f5336711cd3ed533c6b3fd0666
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / calmlib-2.0.17-py3-none-any.whl

Download URL calmlib-2.0.17-py3-none-any.whl
Size 238.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68a16199de1f9e3a58bf22137444af77a8b4d37c6f06a3866fe6382948f10171
BLAKE2b-256 checksum
How to use checksums
4e90679fc279131f7ae575df66d19953d718d92d8ad7f8fc0518e9e1d1cd6818
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for calmlib 2.0.17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page