Skip to main content

A simple AI toolkit for text processing using OpenAI and Gemini APIs

Project description

AIWand 🪄

A simple and elegant Python package for AI-powered text processing using OpenAI and Google Gemini APIs.

PyPI version Python versions License

✨ Features

  • Smart Provider Selection - Automatically uses OpenAI or Gemini based on available keys
  • Text Summarization - Create concise, detailed, or bullet-point summaries
  • AI Chat - Have conversations with context history
  • Text Generation - Generate content from prompts
  • Helper Utilities - Random number and UUID generation
  • Zero Configuration - Works with just environment variables
  • CLI Interface - Optional command line usage

🚀 Quick Start

Installation

pip install aiwand

Configuration

Set your API keys as environment variables:

# Option 1: OpenAI only
export OPENAI_API_KEY="your-openai-key"

# Option 2: Gemini only  
export GEMINI_API_KEY="your-gemini-key"

# Option 3: Both (set preference)
export OPENAI_API_KEY="your-openai-key"
export GEMINI_API_KEY="your-gemini-key"
export AI_DEFAULT_PROVIDER="openai"  # or "gemini"

Or create a .env file in your project:

OPENAI_API_KEY=your-openai-key
GEMINI_API_KEY=your-gemini-key
AI_DEFAULT_PROVIDER=openai

Basic Usage

import aiwand

# Summarize text
summary = aiwand.summarize("Your long text here...")

# Chat with AI  
response = aiwand.chat("What is machine learning?")

# Generate text
story = aiwand.generate_text("Write a poem about coding")

# Generate random number and UUID
random_num = aiwand.generate_random_number(8)  # 8-digit number
unique_id = aiwand.generate_uuid()  # UUID4

Advanced Usage

import aiwand

# Customized summarization
summary = aiwand.summarize(
    text="Your long text...",
    style="bullet-points",  # "concise", "detailed", "bullet-points"
    max_length=50,
    model="gpt-4"  # Optional: specify model
)

# Chat with conversation history
conversation = []
response1 = aiwand.chat("Hello!", conversation_history=conversation)
conversation.append({"role": "user", "content": "Hello!"})
conversation.append({"role": "assistant", "content": response1})

response2 = aiwand.chat("What did I just say?", conversation_history=conversation)

# Generate text with custom parameters
text = aiwand.generate_text(
    prompt="Write a technical explanation",
    max_tokens=300,
    temperature=0.3  # Lower = more focused, Higher = more creative
)

# Helper utilities for testing and development
test_id = aiwand.generate_random_number(6)  # 6-digit number
session_id = aiwand.generate_uuid()  # UUID4
user_code = aiwand.generate_random_number(4)  # 4-digit code
transaction_uuid = aiwand.generate_uuid(uppercase=True)  # Uppercase UUID

Configuration Management

import aiwand

# Show current configuration
aiwand.show_current_config()

# Interactive setup (optional)
aiwand.setup_user_preferences()

Error Handling

import aiwand

try:
    summary = aiwand.summarize("Some text")
except aiwand.AIError as e:
    print(f"AI service error: {e}")
except ValueError as e:
    print(f"Input error: {e}")

🔧 CLI Usage (Optional)

# Direct prompts (easiest way!)
aiwand "Ten fun names for a pet pelican"
aiwand "Explain quantum computing in simple terms" 

# Specific commands
aiwand summarize "Your text here" --style bullet-points
aiwand chat "What is machine learning?"
aiwand generate "Write a story about AI"

# Helper utilities
aiwand helper random --length 8        # Generate 8-digit random number
aiwand helper uuid --uppercase         # Generate uppercase UUID

# Setup preferences
aiwand setup
aiwand config

📚 Documentation

🛠️ Contributing

We welcome contributions from both AI assistants and human developers! Please see our comprehensive contributing guide:

Whether you're an AI assistant helping users or a human developer, these guides ensure consistency and quality across all contributions.

🤝 Connect

📝 License

MIT License - see LICENSE file for details.


Made with ❤️ by Aman Kumar

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

aiwand-0.4.3.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

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

aiwand-0.4.3-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file aiwand-0.4.3.tar.gz.

File metadata

  • Download URL: aiwand-0.4.3.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for aiwand-0.4.3.tar.gz
Algorithm Hash digest
SHA256 0ab06f161ed2b5858f5bb1a5537e3798d0f53a4faa298c7c839d0e7179cab16f
MD5 6ffaa2a6b2bae797dc3a382e32cefb69
BLAKE2b-256 28a0c215f3e5eb1178dfbebb22a3a75b67a0a4f37973b2b21e5b09df1d428dec

See more details on using hashes here.

File details

Details for the file aiwand-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: aiwand-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for aiwand-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 45c8c6295c15f2092d87e2f291cda59fda7a7ab9927250cf8da0f5ceec1a9745
MD5 8252092f413db57afa0ce85c47145325
BLAKE2b-256 affcccb13cd0140270d8ed94b98e18bc1fd28c262113a7d080ac8f6510630a5c

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