templateai 1.0.0
templateai it's a library for first Template-based AI in the world
License: MIT
Requires Python: >=3.8
Keywords: ai, chatbot, intent-classification, nlp, template

# TemplateAI

**The world's first template-based AI library** — lightweight, fast, and runs on any hardware.

[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)

---

## 🚀 Why TemplateAI?

Modern AI models are **heavy, slow, and resource-hungry**. TemplateAI offers a different approach:

- ⚡ **Lightning fast** — responds in milliseconds
- 💾 **Lightweight** — only 120MB (vs. 14GB+ for ChatGPT-level models)
- 🖥️ **Runs anywhere** — works on CPU, no GPU required
- 🎯 **Zero hallucinations** — for supported tasks (math, constants, conversions)
- 🔒 **Safe** — no `eval()`, no code injection risks

Perfect for chatbots, calculators, converters, and simple AI assistants that need to be **fast and reliable**.

---

## 🧠 How It Works

TemplateAI combines three components:

### 1. **Classifier** (Intent Recognition)
Uses a fine-tuned BERT model to understand what the user wants:
- Greetings, goodbyes, small talk
- Math calculations
- Temperature conversions
- Mathematical constants

**94%+ accuracy** on intent classification.

### 2. **Template Generator** (For Conversations)
Generates natural, varied responses using templates:
```
[GREETING], [QUESTION]

GREETING: ["Hey", "Hi", "Hello"]
QUESTION: ["how are you?", "what's up?"]
```
**Produces hundreds of unique responses** from simple templates.

### 3. **Handlers** (For Tasks)
Special functions for specific tasks:
- **Calculator** — safe math evaluation (no `eval()`)
- **Constants** — π, e, φ, √2 with precise values
- **Temperature** — Celsius ↔ Fahrenheit conversion

---

## 📦 Installation

```bash
pip install templateai
```

That's it! No complicated setup, no GPU drivers, no docker containers.

---

## ⚡ Quick Start

```python
import templateai

# Initialize AI
ai = templateai.TemplateAI()

# Get responses
print(ai.process_input("Hello!"))
# Output: "Hey, how are you?"

print(ai.process_input("What's 25 + 17?"))
# Output: "Answer: 42"

print(ai.process_input("What is pi?"))
# Output: "π (pi) = 3.14159265359"

print(ai.process_input("Convert 100 F to C"))
# Output: "100.0°F = 37.78°C"
```

**That's all you need to know!** One function: `process_input()`. Simple.

---

## 🎯 What Can It Do?

| Feature | Example Input | Output |
|---------|---------------|--------|
| **Conversations** | "Hi!" | "Hey, how are you?" |
| **Math** | "What's 15 * 8?" | "Answer: 120" |
| **Constants** | "What is the golden ratio?" | "φ (golden ratio) = 1.61803398875" |
| **Temperature** | "Convert 25°C to Fahrenheit" | "25.0°C = 77.00°F" |

More features coming soon!

---

## 🛠️ Requirements

- Python 3.8+
- ~300MB RAM
- Any CPU (no GPU needed!)

**Dependencies** (installed automatically):
- `torch` (CPU version)
- `transformers`

---

## 📊 Performance

| Metric | Value |
|--------|-------|
| **Model size** | 120 MB |
| **RAM usage** | ~300 MB |
| **Response time** | 50-100ms |
| **Intent accuracy** | 94.34% |
| **GPU required?** | ❌ No |

---

## 🤝 Contributing

Want to add new features? Found a bug? Contributions are welcome!

1. Fork the repo
2. Create your feature branch
3. Submit a pull request

---

## 📄 License

MIT License — use it however you want!

---

## 🌟 Why "Template-Based"?

Traditional AI models generate text **word by word**, which can lead to:
- ❌ Hallucinations (making up facts)
- ❌ Slow generation
- ❌ High resource usage

TemplateAI uses **pre-written templates** and **specialized handlers** for reliability and speed. Think of it as a smart dispatcher rather than a text generator.

**Perfect for cases where you need specific, predictable, fast responses.**

---

## Notes
TemplateAI is still a bit rough around the edges because it just came out. It'll only get smarter in the future!