# 🚀 WoosAI Library
**Reduce your OpenAI API costs by up to 88%!**
WoosAI Library is a powerful Python library that optimizes OpenAI API calls through intelligent input compression, output optimization, advanced caching, and real-time statistics tracking.
[](https://badge.fury.io/py/woosailibrary)
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
---
## ✨ Features
### 🎯 Core Features
- **Input Optimization** - Compress user inputs without losing meaning
- **Output Optimization** - Get concise, relevant responses
- **Advanced Caching** - LRU cache with pattern-based deletion
- **Usage Statistics** - Track costs, tokens, and savings in real-time
- **Auto License** - Free license auto-generated on first use
### 💰 Cost Savings
- **Up to 88%** cost reduction on OpenAI API calls
- **Real-time tracking** of cost savings
- **Cache system** eliminates repeated API calls
### 📊 Statistics & Monitoring
- Daily, monthly, and total usage statistics
- Token usage tracking
- Cost comparison (with/without WoosAI)
- Cache hit rate monitoring
### 💾 Advanced Caching
- **LRU Eviction** - Automatic removal of least-used entries
- **TTL Support** - Auto-expire old cache entries
- **Pattern Deletion** - Remove cache by regex pattern
- **Auto Cleanup** - Periodic automatic maintenance
---
## 🚀 Quick Start
### Installation
```bash
pip install woosailibrary
```
### Basic Usage
```python
import os
from woosailibrary import WoosAI
# Set your OpenAI API key
os.environ['OPENAI_API_KEY'] = 'your-openai-api-key'
# Initialize WoosAI (auto-generates free license on first use)
client = WoosAI()
# Make optimized API call
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Explain AI in simple terms"}]
)
print(response.choices[0].message.content)
```
### With Caching
```python
# Enable caching for repeated queries
client = WoosAI(
cache=True, # Enable caching
cache_ttl=24, # Cache expires after 24 hours
max_cache_size=1000, # Store up to 1000 entries
auto_cleanup_interval=100 # Auto cleanup every 100 operations
)
# First call - hits OpenAI API
response1 = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "What is AI?"}]
)
# Second call - returns from cache (FREE!)
response2 = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "What is AI?"}]
)
```
---
## 📊 Statistics & Monitoring
### View Statistics
```python
# Display all statistics
client.display_stats()
# Get specific stats
today = client.get_today_stats()
monthly = client.get_monthly_stats()
total = client.get_total_stats()
print(f"Today's savings: {today['cost_saved']}")
print(f"Monthly savings: {monthly['cost_saved']}")
print(f"Total savings: {total['cost']['saved']}")
```
**Example Output:**
```
============================================================
📊 WoosAI Usage Statistics
============================================================
📅 Today (2025-10-23):
Requests: 15
Cost Saved: $2.50
Tokens Saved: 3,500
📆 This Month (2025-10):
Requests: 450
Cost Saved: $75.00
Projected Monthly: $225.00
🎯 Total (All Time):
Requests: 1,200
Cost Saved: $210.00
Savings: 88.0%
============================================================
```
---
## 💾 Cache Management
### View Cache Statistics
```python
# Display cache statistics
client.display_cache_stats()
# Get cache info
cache_info = client.get_cache_info()
print(f"Cache size: {cache_info['size_usage']}")
```
**Example Output:**
```
============================================================
💾 Advanced Cache Statistics
============================================================
📊 Performance:
Cache Hits: 450
Cache Misses: 150
Hit Rate: 75.0%
LRU Evictions: 50
💰 Savings:
Cost Saved (from cache): $22.50
📦 Storage:
Cached Entries: 850/1000 (85.0%)
Active: 800
Expired: 50
============================================================
```
### Cache Management
```python
# Clear expired cache entries
client.clear_expired_cache()
# Clear cache by pattern (e.g., weather-related queries)
client.clear_cache_by_pattern("weather|날씨")
# Clear cache older than 7 days
client.clear_old_cache(days=7)
# Clear all cache
client.clear_cache()
```
---
## 🎯 Use Cases
### 1. FAQ Chatbot
```python
client = WoosAI(cache=True, cache_ttl=168) # 1 week cache
# Same questions = FREE responses!
for question in faq_questions:
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": question}]
)
```
### 2. Customer Support Bot
```python
client = WoosAI(cache=True, max_cache_size=5000)
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "How do I reset my password?"}]
)
```
---
## 📖 API Reference
### WoosAI Client
```python
client = WoosAI(
api_key=None, # OpenAI API key
license_key=None, # WoosAI license
cache=False, # Enable caching
cache_ttl=24, # Cache TTL in hours
max_cache_size=1000, # Maximum cache entries
auto_cleanup_interval=100 # Auto cleanup frequency
)
```
### Statistics Methods
```python
client.get_today_stats() # Get today's statistics
client.get_monthly_stats() # Get monthly statistics
client.get_total_stats() # Get total statistics
client.display_stats() # Display statistics
```
### Cache Methods
```python
client.get_cache_info() # Get cache info
client.display_cache_stats() # Display cache stats
client.clear_cache() # Clear all cache
client.clear_cache_by_pattern(regex) # Clear by pattern
client.clear_expired_cache() # Clear expired
client.clear_old_cache(days=7) # Clear old entries
```
---
## 🔧 Configuration
### Configuration Files
WoosAI stores data in:
- **Windows:** `C:\Users\<username>\.woosai\`
- **Linux/Mac:** `~/.woosai/`
Files:
- `config.json` - License information
- `stats.json` - Usage statistics
- `cache/responses.json` - Cached responses
---
## 🔗 Links
- **Website:** [https://woos-ai.com](https://woos-ai.com)
- **PyPI:** [https://pypi.org/project/woosailibrary/](https://pypi.org/project/woosailibrary/)
- **Support:** contact@woos-ai.com
---
## 📄 License
MIT License
---
**Made with ❤️ by WoosAI Team**
Raw data
{
"_id": null,
"home_page": "https://github.com/woosai/woosailibrary",
"name": "woosailibrary",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "openai, ai, optimization, cost-reduction, token-optimization, gpt, chatgpt, api, caching, statistics",
"author": "WoosAI Team",
"author_email": "contact@woos-ai.com",
"download_url": "https://files.pythonhosted.org/packages/f6/94/2ed75cb4f087abb52b89df7b9508f30defe08010e2ea2794ba0a0dbb9e07/woosailibrary-1.1.0.tar.gz",
"platform": null,
"description": "# \ud83d\ude80 WoosAI Library\r\n\r\n**Reduce your OpenAI API costs by up to 88%!**\r\n\r\nWoosAI Library is a powerful Python library that optimizes OpenAI API calls through intelligent input compression, output optimization, advanced caching, and real-time statistics tracking.\r\n\r\n[](https://badge.fury.io/py/woosailibrary)\r\n[](https://www.python.org/downloads/)\r\n[](https://opensource.org/licenses/MIT)\r\n\r\n---\r\n\r\n## \u2728 Features\r\n\r\n### \ud83c\udfaf Core Features\r\n- **Input Optimization** - Compress user inputs without losing meaning\r\n- **Output Optimization** - Get concise, relevant responses\r\n- **Advanced Caching** - LRU cache with pattern-based deletion\r\n- **Usage Statistics** - Track costs, tokens, and savings in real-time\r\n- **Auto License** - Free license auto-generated on first use\r\n\r\n### \ud83d\udcb0 Cost Savings\r\n- **Up to 88%** cost reduction on OpenAI API calls\r\n- **Real-time tracking** of cost savings\r\n- **Cache system** eliminates repeated API calls\r\n\r\n### \ud83d\udcca Statistics & Monitoring\r\n- Daily, monthly, and total usage statistics\r\n- Token usage tracking\r\n- Cost comparison (with/without WoosAI)\r\n- Cache hit rate monitoring\r\n\r\n### \ud83d\udcbe Advanced Caching\r\n- **LRU Eviction** - Automatic removal of least-used entries\r\n- **TTL Support** - Auto-expire old cache entries\r\n- **Pattern Deletion** - Remove cache by regex pattern\r\n- **Auto Cleanup** - Periodic automatic maintenance\r\n\r\n---\r\n\r\n## \ud83d\ude80 Quick Start\r\n\r\n### Installation\r\n\r\n```bash\r\npip install woosailibrary\r\n```\r\n\r\n### Basic Usage\r\n\r\n```python\r\nimport os\r\nfrom woosailibrary import WoosAI\r\n\r\n# Set your OpenAI API key\r\nos.environ['OPENAI_API_KEY'] = 'your-openai-api-key'\r\n\r\n# Initialize WoosAI (auto-generates free license on first use)\r\nclient = WoosAI()\r\n\r\n# Make optimized API call\r\nresponse = client.chat.completions.create(\r\n model=\"gpt-4\",\r\n messages=[{\"role\": \"user\", \"content\": \"Explain AI in simple terms\"}]\r\n)\r\n\r\nprint(response.choices[0].message.content)\r\n```\r\n\r\n### With Caching\r\n\r\n```python\r\n# Enable caching for repeated queries\r\nclient = WoosAI(\r\n cache=True, # Enable caching\r\n cache_ttl=24, # Cache expires after 24 hours\r\n max_cache_size=1000, # Store up to 1000 entries\r\n auto_cleanup_interval=100 # Auto cleanup every 100 operations\r\n)\r\n\r\n# First call - hits OpenAI API\r\nresponse1 = client.chat.completions.create(\r\n model=\"gpt-4\",\r\n messages=[{\"role\": \"user\", \"content\": \"What is AI?\"}]\r\n)\r\n\r\n# Second call - returns from cache (FREE!)\r\nresponse2 = client.chat.completions.create(\r\n model=\"gpt-4\",\r\n messages=[{\"role\": \"user\", \"content\": \"What is AI?\"}]\r\n)\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udcca Statistics & Monitoring\r\n\r\n### View Statistics\r\n\r\n```python\r\n# Display all statistics\r\nclient.display_stats()\r\n\r\n# Get specific stats\r\ntoday = client.get_today_stats()\r\nmonthly = client.get_monthly_stats()\r\ntotal = client.get_total_stats()\r\n\r\nprint(f\"Today's savings: {today['cost_saved']}\")\r\nprint(f\"Monthly savings: {monthly['cost_saved']}\")\r\nprint(f\"Total savings: {total['cost']['saved']}\")\r\n```\r\n\r\n**Example Output:**\r\n```\r\n============================================================\r\n\ud83d\udcca WoosAI Usage Statistics\r\n============================================================\r\n\r\n\ud83d\udcc5 Today (2025-10-23):\r\n Requests: 15\r\n Cost Saved: $2.50\r\n Tokens Saved: 3,500\r\n\r\n\ud83d\udcc6 This Month (2025-10):\r\n Requests: 450\r\n Cost Saved: $75.00\r\n Projected Monthly: $225.00\r\n\r\n\ud83c\udfaf Total (All Time):\r\n Requests: 1,200\r\n Cost Saved: $210.00\r\n Savings: 88.0%\r\n\r\n============================================================\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udcbe Cache Management\r\n\r\n### View Cache Statistics\r\n\r\n```python\r\n# Display cache statistics\r\nclient.display_cache_stats()\r\n\r\n# Get cache info\r\ncache_info = client.get_cache_info()\r\nprint(f\"Cache size: {cache_info['size_usage']}\")\r\n```\r\n\r\n**Example Output:**\r\n```\r\n============================================================\r\n\ud83d\udcbe Advanced Cache Statistics\r\n============================================================\r\n\r\n\ud83d\udcca Performance:\r\n Cache Hits: 450\r\n Cache Misses: 150\r\n Hit Rate: 75.0%\r\n LRU Evictions: 50\r\n\r\n\ud83d\udcb0 Savings:\r\n Cost Saved (from cache): $22.50\r\n\r\n\ud83d\udce6 Storage:\r\n Cached Entries: 850/1000 (85.0%)\r\n Active: 800\r\n Expired: 50\r\n\r\n============================================================\r\n```\r\n\r\n### Cache Management\r\n\r\n```python\r\n# Clear expired cache entries\r\nclient.clear_expired_cache()\r\n\r\n# Clear cache by pattern (e.g., weather-related queries)\r\nclient.clear_cache_by_pattern(\"weather|\ub0a0\uc528\")\r\n\r\n# Clear cache older than 7 days\r\nclient.clear_old_cache(days=7)\r\n\r\n# Clear all cache\r\nclient.clear_cache()\r\n```\r\n\r\n---\r\n\r\n## \ud83c\udfaf Use Cases\r\n\r\n### 1. FAQ Chatbot\r\n```python\r\nclient = WoosAI(cache=True, cache_ttl=168) # 1 week cache\r\n\r\n# Same questions = FREE responses!\r\nfor question in faq_questions:\r\n response = client.chat.completions.create(\r\n model=\"gpt-4\",\r\n messages=[{\"role\": \"user\", \"content\": question}]\r\n )\r\n```\r\n\r\n### 2. Customer Support Bot\r\n```python\r\nclient = WoosAI(cache=True, max_cache_size=5000)\r\n\r\nresponse = client.chat.completions.create(\r\n model=\"gpt-4\",\r\n messages=[{\"role\": \"user\", \"content\": \"How do I reset my password?\"}]\r\n)\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udcd6 API Reference\r\n\r\n### WoosAI Client\r\n\r\n```python\r\nclient = WoosAI(\r\n api_key=None, # OpenAI API key\r\n license_key=None, # WoosAI license\r\n cache=False, # Enable caching\r\n cache_ttl=24, # Cache TTL in hours\r\n max_cache_size=1000, # Maximum cache entries\r\n auto_cleanup_interval=100 # Auto cleanup frequency\r\n)\r\n```\r\n\r\n### Statistics Methods\r\n\r\n```python\r\nclient.get_today_stats() # Get today's statistics\r\nclient.get_monthly_stats() # Get monthly statistics\r\nclient.get_total_stats() # Get total statistics\r\nclient.display_stats() # Display statistics\r\n```\r\n\r\n### Cache Methods\r\n\r\n```python\r\nclient.get_cache_info() # Get cache info\r\nclient.display_cache_stats() # Display cache stats\r\nclient.clear_cache() # Clear all cache\r\nclient.clear_cache_by_pattern(regex) # Clear by pattern\r\nclient.clear_expired_cache() # Clear expired\r\nclient.clear_old_cache(days=7) # Clear old entries\r\n```\r\n\r\n---\r\n\r\n## \ud83d\udd27 Configuration\r\n\r\n### Configuration Files\r\n\r\nWoosAI stores data in:\r\n- **Windows:** `C:\\Users\\<username>\\.woosai\\`\r\n- **Linux/Mac:** `~/.woosai/`\r\n\r\nFiles:\r\n- `config.json` - License information\r\n- `stats.json` - Usage statistics\r\n- `cache/responses.json` - Cached responses\r\n\r\n---\r\n\r\n## \ud83d\udd17 Links\r\n\r\n- **Website:** [https://woos-ai.com](https://woos-ai.com)\r\n- **PyPI:** [https://pypi.org/project/woosailibrary/](https://pypi.org/project/woosailibrary/)\r\n- **Support:** contact@woos-ai.com\r\n\r\n---\r\n\r\n## \ud83d\udcc4 License\r\n\r\nMIT License\r\n\r\n---\r\n\r\n**Made with \u2764\ufe0f by WoosAI Team**\r\n",
"bugtrack_url": null,
"license": null,
"summary": "AI Output Token Optimizer - Reduce OpenAI API costs by up to 88%",
"version": "1.1.0",
"project_urls": {
"Bug Reports": "https://github.com/woosai/woosailibrary/issues",
"Documentation": "https://github.com/woosai/woosailibrary#readme",
"Homepage": "https://github.com/woosai/woosailibrary",
"Source": "https://github.com/woosai/woosailibrary",
"Website": "https://woos-ai.com"
},
"split_keywords": [
"openai",
" ai",
" optimization",
" cost-reduction",
" token-optimization",
" gpt",
" chatgpt",
" api",
" caching",
" statistics"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "7f7bde8a76cae3004b4a42c2838151a60ab45d03b7b9cf442441882aefaacadc",
"md5": "553c6256b1ec5a50ba6894c190d2f8b8",
"sha256": "5d3a991e6ebdeef5cd80859019d8f151049e9fd7fa3230992ff607e6a50e4c8b"
},
"downloads": -1,
"filename": "woosailibrary-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "553c6256b1ec5a50ba6894c190d2f8b8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 42939,
"upload_time": "2025-10-23T09:40:03",
"upload_time_iso_8601": "2025-10-23T09:40:03.636496Z",
"url": "https://files.pythonhosted.org/packages/7f/7b/de8a76cae3004b4a42c2838151a60ab45d03b7b9cf442441882aefaacadc/woosailibrary-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f6942ed75cb4f087abb52b89df7b9508f30defe08010e2ea2794ba0a0dbb9e07",
"md5": "26c5b260b7ae6916b2a900a499ee5cb4",
"sha256": "336b6323b42bd4eb6bdee3ec6b685416d69ccb84f2c241a2832e357e05b02377"
},
"downloads": -1,
"filename": "woosailibrary-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "26c5b260b7ae6916b2a900a499ee5cb4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 40039,
"upload_time": "2025-10-23T09:40:05",
"upload_time_iso_8601": "2025-10-23T09:40:05.067562Z",
"url": "https://files.pythonhosted.org/packages/f6/94/2ed75cb4f087abb52b89df7b9508f30defe08010e2ea2794ba0a0dbb9e07/woosailibrary-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-23 09:40:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "woosai",
"github_project": "woosailibrary",
"github_not_found": true,
"lcname": "woosailibrary"
}