Spaces:
Sleeping
title: meeTARA - Empathetic AI Assistant
emoji: ๐
colorFrom: pink
colorTo: purple
sdk: docker
app_file: app.py
pinned: false
license: mit
startup_duration_timeout: 30m
๐ meeTARA - Empathetic AI Assistant for your Life
meeTARA is a revolutionary empathetic AI assistant that combines advanced language models with emotional intelligence to provide caring, domain-specific responses across 16+ specialized categories.
๐ Features
- ๐ง Domain Expertise: Specialized knowledge across healthcare, business, education, creative, technology, and more
- ๐ Emotional Intelligence: Caring, empathetic responses that understand context and emotion
- โก Local Processing: Powered by GGUF models running locally (no external API calls)
- ๐ Privacy-First: All processing happens on-device
- ๐ฏ Smart Routing: Automatically selects the best model based on query complexity and domain
- ๐ค Agent Mode: Tool-use capabilities with web search and calculator (Simple Direct Agent)
๐ค Models
meeTARA uses optimized GGUF models from meeTARA-lab:
- 4B Instruct (Default): Fast, efficient responses for most queries
- 4B Thinking: Deep reasoning for complex problems
- 8B Universal: Fallback for uncategorized domains
- 1.7B Lightweight: Quick responses for simple queries
๐ง Agent Mode (Simple Direct Agent)
meeTARA supports Agent Mode - an intelligent tool-use system that enables your local models to use external tools dynamically. Our Simple Direct Agent approach is lightweight, fast, and perfectly tailored for GGUF models.
How meeTARA Agent Works
The Simple Direct Agent approach:
- ๐ฏ Detection: Uses pattern matching (regex) to detect tool needs from user queries
- โก Execution: Tools execute FIRST (calculator/web search) before model involvement
- ๐ Synthesis: Tool results are fed to the meeTARA model for structured response generation
- ๐จ Formatting: Model automatically formats responses using built-in structured format (๐ฏ, ๐, โก, ๐ก)
Agent Flow Diagram
flowchart TD
Start([User Query]) --> AgentMode{Agent Mode<br/>Enabled?}
AgentMode -->|No| DirectModel[Direct Model Generation]
AgentMode -->|Yes| Detect[Agent Detection Layer<br/>Pattern Matching]
Detect --> LoadConfig[Load Config from<br/>config/agent_config.json]
LoadConfig --> CheckCalc{Calculator<br/>Needed?}
LoadConfig --> CheckWeb{Web Search<br/>Needed?}
CheckCalc -->|Yes| CalcTool[Calculator Tool<br/>calculator expression]
CheckCalc -->|No| NoCalc[Skip Calculator]
CheckWeb -->|Yes| WebTool[Web Search Tool<br/>DuckDuckGo Search]
CheckWeb -->|No| NoWeb[Skip Web Search]
CalcTool --> CalcResult[Tool Result:<br/>"25 * 48 = 1200"]
WebTool --> WebResult[Tool Results:<br/>Latest search data]
NoCalc --> BuildPrompt
NoWeb --> BuildPrompt
CalcResult --> BuildPrompt[Build Enhanced Prompt<br/>Query + Tool Results]
WebResult --> BuildPrompt
BuildPrompt --> Model[MeeTARACore.generate<br/>Enhanced Prompt]
DirectModel --> Model
Model --> GGUF[GGUF Model<br/>Qwen3/Qwen2.5/Phi3]
GGUF --> Structured[Structured Response<br/>๐ฏ Answer<br/>๐ Details<br/>โก Steps<br/>๐ก Note]
Structured --> Response([Final Response])
style Start fill:#e1f5ff
style Detect fill:#fff4e6
style CalcTool fill:#ffe6f2
style WebTool fill:#ffe6f2
style Model fill:#fff4e6
style GGUF fill:#e6ffe6
style Structured fill:#e6ffe6
style Response fill:#d4edda
Available Tools
- ๐ข Calculator Tool: Accurate mathematical calculations using Python
eval()(safe expression evaluation) - ๐ Web Search Tool: DuckDuckGo search for current information, trends, news, stock prices, etc.
Configuration-Driven Detection
Tool detection is fully configurable via config/agent_config.json:
{
"web_search": {
"keywords": ["current", "today", "latest", "trend", "stock market", ...],
"search_patterns": [...],
"max_results": 5
},
"calculator": {
"keywords": ["calculate", "compute", "what is", ...],
"math_patterns": [...]
}
}
Benefits:
- โ Easy Updates: Add/modify keywords without code changes
- โ Version Controlled: Config changes tracked in git
- โ Maintainable: All detection logic in one place
Example Flow
User Query: "What's 25 * 48? Also search for latest AI trends in 2025"
- Detection: Agent detects
calculatorneeded (matches "25 * 48") andweb_searchneeded (matches "latest" + "trends") - Tool Execution:
calculator("25 * 48")โ Returns"25 * 48 = 1200"web_search("latest AI trends in 2025")โ Returns search results from DuckDuckGo
- Enhanced Prompt: Agent builds prompt with query + tool results
- Model Generation: meeTARA model receives enhanced prompt and generates structured response
- Final Response:
๐ฏ Answer: 25 ร 48 = 1200. Based on recent search results... ๐ Details: Latest AI trends in 2025 include... โก Steps: [Calculation steps + key findings] ๐ก Note: [Additional insights]
Benefits
- โ Fast & Lightweight: No heavy orchestration framework - direct tool execution
- โ Optimized Performance: ~80% faster web searches, ~40% faster calculator queries (see Performance Docs)
- โ Configurable: All detection keywords/patterns in config file
- โ Accurate Math: Calculator ensures precise calculations (no hallucinated math)
- โ Current Information: Web search provides up-to-date data beyond training cutoff
- โ Structured Responses: Model automatically formats responses with emoji sections
- โ Fallback Graceful: If tools unavailable or not needed, sends directly to model
Search Providers (AI-Powered Search)
meeTARA Agent supports multiple search providers for web searches:
1. DuckDuckGo (Default - Free, No API Key Required)
- โ Free: No API key needed
- โ No Limits: Unlimited searches
- โ Private: Privacy-focused search
- Use Case: Default for all users, works out of the box
2. Google Custom Search API (Optional - Better Results)
- โ Free Tier: 100 queries/day (no credit card required)
- โ Better Results: More accurate, AI-enhanced search results
- โ Easy Setup: Requires API key (see setup below)
- Use Case: For better search quality when free tier is sufficient
Search Flow:
- Agent detects web search needed (e.g., "current US stock trends")
- Tries Google Custom Search API first (if API key configured)
- Falls back to DuckDuckGo (free) if Google unavailable
- Search results are fed to AI model for intelligent processing and structured response
Setup Google Custom Search API (Optional):
Get Google API Key (free):
- Go to Google Cloud Console
- Create a new project or select existing
- Enable "Custom Search API"
- Create credentials โ API Key
- (Optional) Restrict API key to "Custom Search API" for security
Create Custom Search Engine (free):
- Go to Programmable Search Engine
- Create a new search engine
- Search the entire web (or specific sites)
- Copy the Search Engine ID
Set Environment Variables:
For Local Development (using
.envfile):# Create .env file in project root (already in .gitignore - safe) GOOGLE_CUSTOM_SEARCH_API_KEY=your_api_key_here GOOGLE_CUSTOM_SEARCH_ENGINE_ID=your_engine_id_hereThe app will automatically load
.envfile if it exists (viapython-dotenv).For HuggingFace Spaces (use Secrets, NOT .env files):
- Go to your Space โ Settings โ Secrets
- Add two secrets:
GOOGLE_CUSTOM_SEARCH_API_KEY= your API keyGOOGLE_CUSTOM_SEARCH_ENGINE_ID= your Search Engine ID (from embed codecx=YOUR_ID)
- Secrets are encrypted and never exposed in git
- Restart the Space after adding secrets
Verify Setup:
- Agent will automatically detect environment variables (from
.envlocally or Secrets in HF Spaces) - Logs will show:
โ Google Custom Search API configured (will use for web search) - Web searches will use Google API (better results)
- Agent will automatically detect environment variables (from
Note:
.envfile is in.gitignore- safe from git commits- For HuggingFace Spaces, always use Secrets, not
.envfiles (Secrets are encrypted) - If Google API key is not configured, agent automatically uses DuckDuckGo (free, unlimited)
๐ Security Best Practices
HuggingFace Spaces Secrets are Secure:
- โ Encrypted at rest - Secrets are stored encrypted in HuggingFace's secure vault
- โ Only accessible at runtime - Secrets are injected as environment variables when your Space runs
- โ Never exposed in code or logs - Secrets don't appear in git, code, or public logs
- โ Private to your Space - Only you and Space collaborators can access Secrets
- โ Hackers cannot access - Secrets are not exposed via your Space URL or public API
Google API Key Security (Recommended):
Restrict API Key in Google Cloud Console:
- Go to API Credentials
- Click on your API key โ "Restrict key"
- Application restrictions: Restrict to "HTTP referrers" โ Add your Space URL:
https://YOUR-USERNAME-YOUR-SPACE-NAME.hf.space/*
- API restrictions: Restrict to "Custom Search API" only
- Save restrictions
Monitor Usage:
- Check Google Cloud Console โ "APIs & Services" โ "Dashboard"
- Monitor API usage and costs
- Set up billing alerts (free tier: 100 queries/day)
Search Engine ID Safety:
- The Search Engine ID (
cx=...) is not sensitive - it's just an identifier - It's designed to be public (used in embed codes on websites)
- Cannot be used without the API key - so even if exposed, it's harmless
- No need to hide or restrict it
- The Search Engine ID (
What's Safe vs What to Watch:
- โ Safe: Search Engine ID (public identifier, harmless without API key)
- โ Safe: HuggingFace Spaces Secrets (encrypted, never exposed)
- โ ๏ธ Protect: API Key (restrict in Google Cloud Console)
- โ ๏ธ Never commit:
.envfiles, API keys in code, hardcoded credentials
Bottom Line:
- Your API key in HuggingFace Spaces Secrets is secure - encrypted and private
- Add API key restrictions in Google Cloud Console for extra security
- Search Engine ID is not sensitive (designed to be public)
- No risk of hackers accessing your credentials through the Space URL
๐ฐ Google Custom Search API - Cost Information
Free Tier:
- โ 100 queries per day - FREE (no credit card needed initially, but billing account required)
- โ ๏ธ Billing account required even for free tier (you won't be charged for first 100/day)
Automatic Fallback (When Quota Exceeded):
- ๐ Automatic fallback to DuckDuckGo when Google quota is exceeded (429 or quota-related 403 errors)
- DuckDuckGo is free and unlimited (no API key required)
- Seamless transition - users won't notice interruption
- Logs will indicate:
โ ๏ธ Google Search quota exceeded โ Auto-fallback to DuckDuckGo - No code changes needed - fallback happens automatically
- No paid subscription required - system gracefully handles quota limits
Paid Tier (Optional - Beyond 100 queries/day):
- ๐ต $5 per 1,000 queries (after free tier)
- ๐ Maximum: 10,000 queries per day (requires billing enabled)
- Note: If you don't set up paid billing, the system automatically falls back to DuckDuckGo after 100 queries/day
Cost Examples:
- 100 queries/day (3,000/month): FREE โ (auto-fallback after quota)
- 500 queries/day (15,000/month): ~$70/month (14,000 additional queries ร $5/1,000 = $70) OR use DuckDuckGo (free)
- 1,000 queries/day (30,000/month): ~$145/month (29,000 additional queries ร $5/1,000 = $145) OR use DuckDuckGo (free)
- 10,000 queries/day (300,000/month): ~$1,485/month (299,000 additional queries ร $5/1,000 = $1,485) OR use DuckDuckGo (free)
Comparison with DuckDuckGo:
- DuckDuckGo: โ FREE, unlimited queries (automatic fallback - excellent results!)
- Google Custom Search: Free for 100/day, then $5 per 1,000 queries (optional upgrade)
Recommendation:
- โ For Development/Testing: DuckDuckGo is perfect (free, unlimited, good results)
- ๐ฐ For Production: Use Google API only if you need better results AND can afford $5 per 1,000 queries
- โ Current Setup: Hybrid approach - tries Google first, automatically falls back to DuckDuckGo when quota exceeded (best of both worlds!)
- ๐ฏ Best Practice: Let the system automatically fallback to DuckDuckGo - no paid subscription needed unless you specifically need Google's superior results
Enabling Agent Mode
Agent Mode is always enabled by default. Just select your preferred model from the dropdown and ask questions:
- Math: "Calculate the surface area of a 6ร4ร5 cm rectangular prism"
- Current Events: "What are today's stock market trends?"
- Combined: "What's 2^10 and search for news about quantum computing in 2025"
- Real-time: "Tell me current US stock trends and present day crypto prices"
๐ Sample Test Questions
For comprehensive test questions covering all areas (Math, Web Search, Current Events, Stock Market, Technology, etc.), see docs/testing/test-questions.md.
The test questions file includes:
- ๐งฎ Math & Calculator queries (basic, geometry, advanced)
- ๐ฐ Current Events & News (today's news, specific topics, global news)
- ๐ผ Stock Market & Financial (market trends, specific markets, combined queries)
- ๐ป Technology & AI (AI trends, tech news, emerging technologies)
- ๐ Educational & Research (science, academic topics, general knowledge)
- ๐ Combined Queries (Math + Search in one question)
- ๐ Real-time Information (time-sensitive queries, specific dates/years)
- ๐ฏ Edge Cases (complex multi-part questions, natural language variations)
Quick Start Examples:
- "Calculate 25 * 48" - Tests calculator tool
- "Search for latest AI trends" - Tests web search tool
- "What's 2^10 and also search for current stock market trends" - Tests combined tool usage
๐ Usage
- Click "Initialize" to load meeTARA (first time may take a few minutes to download models)
- Type your message and press Enter or click "Send"
- meeTARA will analyze your query and provide an empathetic, domain-specific response
๐ Domains Supported
- ๐ฅ Healthcare & Medical
- ๐ผ Business & Professional
- ๐ Education & Academic
- ๐จ Creative & Writing
- ๐ป Technology & Programming
- ๐ง Psychology & Wellness
- ๐ Sports & Recreation
- โ๏ธ Legal & Financial
- ๐จ Emergency & Crisis
- โ๏ธ Travel & Tourism
- ๐ญ Industrial & Manufacturing
- ๐ณ Food & Cooking
- ๐ฌ Entertainment & Media
- And more...
โ๏ธ Configuration
Model Configuration (config/agent_config.json)
All model and agent behavior is configurable via the config/agent_config.json file:
System Prompt Configuration
The system prompt (meeTARA's identity and response format) can be customized in config/agent_config.json:
{
"model": {
"system_prompt": {
"enabled": true,
"prompt": "You are meeTARA, an accurate AI assistant.\nIMPORTANT: For math/calculations, always verify your answer before responding.\nRespond in this format:\n๐ฏ **Answer**: Direct answer (must be correct)\n๐ **Details**: Key facts (2-3 bullets)\nโก **Steps**: Show your work/calculation\n๐ก **Note**: Any warnings (1 sentence)\nBe accurate first, concise second."
},
"generation_settings": {
"temperature": 0.2,
"top_k": 40,
"top_p": 0.9,
"repeat_penalty": 1.1
}
}
}
Benefits:
- โ Customizable Personality: Change meeTARA's identity and instructions without code changes
- โ Response Format Control: Modify the structured format (๐ฏ๐โก๐ก) or create your own
- โ Generation Parameters: Adjust temperature, top_p, etc. for different response styles
- โ Easy Updates: Modify config file and restart - no code changes needed
- โ Fallback Safe: If config not available or invalid, uses default hardcoded values
Default Behavior:
- If
config/agent_config.jsonis not available โ Uses hardcoded default system prompt - If system prompt is disabled (
enabled: false) โ Uses default system prompt - If system prompt is empty โ Uses default system prompt
Agent Configuration (config/agent_config.json)
The agent tool detection behavior is fully configurable:
- Web Search Keywords: Add terms like "today", "current", "present day", "stock market", etc.
- Search Patterns: Regex patterns to extract search queries from natural language
- Calculator Keywords: Terms that trigger calculator tool (e.g., "calculate", "compute", "what is")
- Math Patterns: Regex patterns to detect mathematical expressions
- Settings: Default max_tokens, tool timeouts, etc.
Example: Adding a new keyword
{
"web_search": {
"keywords": [
"current",
"today",
"latest",
"your-new-keyword" // Add here
]
}
}
No code changes needed - just edit the JSON file and restart!
๐ง Technical Details
- Framework: Gradio 4.44.1
- Backend: Python with llama-cpp-python
- Models: GGUF quantized models (Qwen3, Qwen2.5, Phi3.5)
- Inference: llama.cpp with optimized parameters
- Agent System: Simple Direct Agent (pattern-based tool detection)
- Config System: Centralized JSON-based configuration via
config/config_loader.py - Tools: DuckDuckGo search (duckduckgo-search), Python calculator (built-in eval)
๐ Documentation
Project Documentation
| Document | Description |
|---|---|
| Architecture: Core vs Agent | Detailed analysis of MeeTARA's two-layer architecture |
| Deployment: HuggingFace Spaces | Guide for deploying to HF Spaces |
| Feature: Domain Prompts | Domain-specific system prompts documentation |
| Feature: Word Problems | How MeeTARA handles different types of word problems |
| Feature: Agent Performance | Performance optimizations and improvements |
| Testing: Test Questions | Comprehensive test questions for all capabilities |
External Links
โ ๏ธ Resource Requirements
- CPU: Recommended 4+ cores
- RAM: 4-8GB (model dependent)
- Storage: ~10GB for all models
- First Load: Models download automatically on first initialization
๐ License
MIT License - See LICENSE file for details
meeTARA - Where AI meets empathy ๐