AumCore-AI / app.py
AumCoreAI's picture
Update app.py
5493110 verified
raw
history blame
28.6 kB
# app.py - ULTIMATE FINAL VERSION - NEVER TOUCH AGAIN
import os
import sys
import uvicorn
import asyncio
import importlib.util
import json
from pathlib import Path
from fastapi import FastAPI, Form, APIRouter
from fastapi.responses import HTMLResponse, JSONResponse
from groq import Groq
# ============================================
# 1. GLOBAL CONFIGURATION & CONSTANTS
# ============================================
class AumCoreConfig:
"""Central configuration for AumCore AI"""
VERSION = "3.0.0-Final"
USERNAME = "AumCore AI"
PORT = 7860
HOST = "0.0.0.0"
# Paths
BASE_DIR = Path(__file__).parent
MODULES_DIR = BASE_DIR / "modules"
CONFIG_DIR = BASE_DIR / "config"
LOGS_DIR = BASE_DIR / "logs"
DATA_DIR = BASE_DIR / "data"
# Create directories if they don't exist
for dir_path in [MODULES_DIR, CONFIG_DIR, LOGS_DIR, DATA_DIR]:
dir_path.mkdir(exist_ok=True)
# ============================================
# 2. MODULE LOADER SYSTEM (CORE INNOVATION)
# ============================================
class ModuleManager:
"""Dynamic module loading system - FUTURE PROOF"""
def __init__(self, app, client):
self.app = app
self.client = client
self.config = AumCoreConfig()
self.loaded_modules = {}
self.module_config = self._load_module_config()
def _load_module_config(self) -> dict:
"""Load module configuration from JSON"""
config_file = self.config.CONFIG_DIR / "modules.json"
default_config = {
"enabled_modules": ["diagnostics", "testing", "orchestrator"],
"auto_start": True,
"module_settings": {
"diagnostics": {"auto_run": True, "interval_minutes": 60},
"testing": {"auto_test": False, "test_on_startup": True},
"orchestrator": {"enabled": True, "background_tasks": True}
}
}
if not config_file.exists():
config_file.write_text(json.dumps(default_config, indent=4))
return default_config
try:
return json.loads(config_file.read_text())
except:
return default_config
def load_all_modules(self):
"""Load all enabled modules dynamically"""
print("=" * 60)
print("πŸš€ AUMCORE AI - MODULAR SYSTEM INITIALIZING")
print("=" * 60)
for module_name in self.module_config["enabled_modules"]:
self.load_module(module_name)
print(f"πŸ“¦ Modules Loaded: {len(self.loaded_modules)}")
print(f"πŸ”§ Active: {list(self.loaded_modules.keys())}")
print("=" * 60)
def load_module(self, module_name: str):
"""Load a single module by name"""
module_path = self.config.MODULES_DIR / f"{module_name}.py"
if not module_path.exists():
print(f"⚠️ Module '{module_name}' not found at {module_path}")
return False
try:
# Dynamic module loading
spec = importlib.util.spec_from_file_location(module_name, module_path)
module = importlib.util.module_from_spec(spec)
sys.modules[module_name] = module
spec.loader.exec_module(module)
# Register module with app
if hasattr(module, 'register_module'):
module.register_module(self.app, self.client, AumCoreConfig.USERNAME)
self.loaded_modules[module_name] = {
"module": module,
"path": module_path,
"status": "loaded"
}
print(f"βœ… Module '{module_name}' loaded successfully")
return True
else:
print(f"⚠️ Module '{module_name}' missing register_module() function")
return False
except Exception as e:
print(f"❌ Failed to load module '{module_name}': {str(e)}")
return False
def get_module(self, module_name: str):
"""Get loaded module instance"""
return self.loaded_modules.get(module_name, {}).get("module")
def get_module_status(self) -> dict:
"""Get status of all modules"""
return {
"total_modules": len(self.loaded_modules),
"loaded_modules": list(self.loaded_modules.keys()),
"config": self.module_config,
"module_details": {
name: info["status"]
for name, info in self.loaded_modules.items()
}
}
# ============================================
# 3. CORE FASTAPI APPLICATION
# ============================================
app = FastAPI(
title="AumCore AI",
description="Advanced Modular AI Assistant System",
version=AumCoreConfig.VERSION
)
# Initialize Groq client
try:
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
GROQ_AVAILABLE = True
except Exception as e:
print(f"⚠️ Groq client initialization failed: {e}")
client = None
GROQ_AVAILABLE = False
# Initialize Module Manager
module_manager = ModuleManager(app, client)
# ============================================
# 4. CORE UI (NEVER CHANGES)
# ============================================
HTML_UI = '''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AumCore AI - Ultimate Version</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&family=Fira+Code:wght@400;500&display=swap');
/* Body Styling */
body {
background-color: #0d1117;
color: #c9d1d9;
font-family: 'Inter', sans-serif;
display: flex;
height: 100vh;
overflow: hidden;
margin: 0;
}
/* Sidebar Styling */
.sidebar {
width: 260px;
background: #010409;
border-right: 1px solid #30363d;
display: flex;
flex-direction: column;
padding: 15px;
flex-shrink: 0;
}
.nav-item {
padding: 12px;
margin-bottom: 5px;
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
gap: 12px;
color: #8b949e;
transition: all 0.2s ease;
}
.nav-item:hover {
background: #161b22;
color: white;
}
.new-chat-btn {
background: #238636;
color: white !important;
font-weight: 600;
margin-bottom: 20px;
}
/* Main Chat Area */
.main-chat {
flex: 1;
display: flex;
flex-direction: column;
background: #0d1117;
position: relative;
}
.chat-box {
flex: 1;
overflow-y: auto;
display: flex;
flex-direction: column;
align-items: center;
padding: 60px 20px 120px 20px;
scroll-behavior: smooth;
}
.message-wrapper {
width: 100%;
max-width: 760px;
display: flex;
flex-direction: column;
margin-bottom: 35px;
animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
/* Message Bubble Styling */
.bubble {
padding: 5px 0;
font-size: 17px;
line-height: 1.8;
width: 100%;
max-width: 760px;
word-wrap: break-word;
white-space: pre-wrap;
}
.user-text {
color: #58a6ff;
font-weight: 600;
letter-spacing: -0.2px;
}
.ai-text {
color: #e6edf3;
}
/* Code Block Styling */
.code-container {
background: #0d1117;
border: 1px solid #30363d;
border-radius: 12px;
margin: 20px 0;
overflow: hidden;
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.code-header {
background: #161b22;
padding: 12px 18px;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #30363d;
}
.code-lang {
color: #79c0ff;
font-family: 'Fira Code', monospace;
font-size: 14px;
font-weight: 600;
display: flex;
align-items: center;
gap: 8px;
}
.code-lang::before {
content: "✦";
color: #7ee787;
font-size: 12px;
}
.copy-btn {
background: #238636;
color: white;
border: none;
padding: 6px 14px;
border-radius: 6px;
cursor: pointer;
font-size: 13px;
font-family: 'Inter', sans-serif;
font-weight: 500;
transition: all 0.2s ease;
display: flex;
align-items: center;
gap: 6px;
}
.copy-btn:hover {
background: #2ea043;
transform: translateY(-1px);
}
.copy-btn:active {
transform: translateY(0);
}
.copy-btn.copied {
background: #7ee787;
color: #0d1117;
}
/* Input Area */
.input-area {
position: absolute;
bottom: 0;
width: calc(100% - 260px);
left: 260px;
background: #0d1117;
padding: 15px 20px;
border-top: 1px solid #30363d;
}
.input-container {
display: flex;
gap: 10px;
max-width: 800px;
margin: 0 auto;
}
#user-input {
flex: 1;
background: #010409;
border: 1px solid #30363d;
border-radius: 8px;
color: #c9d1d9;
padding: 12px;
font-size: 16px;
resize: none;
overflow: hidden;
}
.send-btn {
background: #238636;
color: white;
border: none;
padding: 0 16px;
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
}
/* Typing Indicator */
.typing-indicator {
display: flex;
gap: 4px;
}
.typing-dot {
width: 8px;
height: 8px;
background: #58a6ff;
border-radius: 50%;
animation: blink 1s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100%{opacity:0;} 40%{opacity:1;} }
/* Health Indicator */
.health-indicator {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 6px 12px;
border-radius: 20px;
font-size: 14px;
font-weight: 600;
}
.health-green { background: #238636; color: white; }
.health-yellow { background: #d29922; color: black; }
.health-red { background: #da3633; color: white; }
.health-value { font-family: 'Fira Code', monospace; }
/* Module Status */
.module-status {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
border-radius: 12px;
font-size: 12px;
background: #161b22;
color: #8b949e;
}
.module-active { color: #7ee787; }
.module-inactive { color: #f85149; }
</style>
</head>
<body>
<div class="sidebar">
<button class="nav-item new-chat-btn" onclick="window.location.reload()"><i class="fas fa-plus"></i> New Chat</button>
<div class="nav-item" onclick="checkSystemHealth()"><i class="fas fa-heartbeat"></i> System Health</div>
<div class="nav-item" onclick="showModuleStatus()"><i class="fas fa-cube"></i> Module Status</div>
<div class="nav-item"><i class="fas fa-history"></i> History</div>
<div class="mt-auto">
<div class="nav-item reset-btn" onclick="confirmReset()"><i class="fas fa-trash-alt"></i> Reset Memory</div>
<div class="nav-item" onclick="runDiagnostics()"><i class="fas fa-stethoscope"></i> Run Diagnostics</div>
<div class="nav-item" onclick="runTests()"><i class="fas fa-vial"></i> Run Tests</div>
<div class="nav-item"><i class="fas fa-cog"></i> Settings</div>
</div>
</div>
<div class="main-chat">
<div id="chat-log" class="chat-box"></div>
<div class="input-area">
<div class="input-container">
<textarea id="user-input" rows="1" placeholder="Type your message to AumCore..." autocomplete="off" oninput="resizeInput(this)" onkeydown="handleKey(event)"></textarea>
<button onclick="send()" class="send-btn"><i class="fas fa-paper-plane fa-lg"></i></button>
</div>
</div>
</div>
<script>
// Resize input dynamically
function resizeInput(el){el.style.height='auto';el.style.height=el.scrollHeight+'px';}
// Handle Enter key for send
function handleKey(e){if(e.key==='Enter' && !e.shiftKey){e.preventDefault();send();}}
// Format code blocks
function formatCodeBlocks(text){
let formatted=text.replace(/```python\\s*([\\s\\S]*?)```/g,
`<div class="code-container"><div class="code-header"><div class="code-lang">Python</div><button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button></div><pre><code class="language-python">$1</code></pre></div>`);
formatted=formatted.replace(/```\\s*([\\s\\S]*?)```/g,
`<div class="code-container"><div class="code-header"><div class="code-lang">Code</div><button class="copy-btn" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button></div><pre><code>$1</code></pre></div>`);
return formatted;
}
// Copy code to clipboard
function copyCode(button){
const codeBlock=button.parentElement.nextElementSibling;
const codeText=codeBlock.innerText;
navigator.clipboard.writeText(codeText).then(()=>{
let origHTML=button.innerHTML;
let origClass=button.className;
button.innerHTML='<i class="fas fa-check"></i> Copied!';
button.className='copy-btn copied';
setTimeout(()=>{button.innerHTML=origHTML;button.className=origClass;},2000);
}).catch(err=>{console.error('Copy failed:',err);button.innerHTML='<i class="fas fa-times"></i> Failed';setTimeout(()=>{button.innerHTML='<i class="fas fa-copy"></i> Copy';},2000);});
}
// Reset memory confirmation
async function confirmReset(){
if(confirm("Sanjay bhai, kya aap sach mein saari memory delete karna chahte hain?")){
try{
const res=await fetch('/reset',{method:'POST'});
const data=await res.json();
alert(data.message);
window.location.reload();
}catch(e){alert("Reset failed: "+e.message);}
}
}
// System Health Check
async function checkSystemHealth(){
try{
const res=await fetch('/system/health');
const data=await res.json();
if(data.success){
const health=data.health_score;
let healthClass='health-red';
if(health>=80) healthClass='health-green';
else if(health>=50) healthClass='health-yellow';
alert(`System Health: ${health}/100\\nStatus: ${data.status}\\nMemory: ${data.memory_used}%\\nCPU: ${data.cpu_used}%`);
}else{
alert('Health check failed: '+data.error);
}
}catch(e){
alert('Health check error: '+e.message);
}
}
// Module Status Check
async function showModuleStatus(){
try{
const res=await fetch('/system/modules/status');
const data=await res.json();
if(data.success){
let moduleList='πŸ“¦ Loaded Modules:\\n';
data.modules.forEach(module=>{
moduleList+=`β€’ ${module.name}: ${module.status}\\n`;
});
alert(moduleList);
}
}catch(e){
alert('Module status error: '+e.message);
}
}
// Run Diagnostics
async function runDiagnostics(){
const log=document.getElementById('chat-log');
const typingId='diagnostics-'+Date.now();
log.innerHTML+=`<div class="message-wrapper" id="${typingId}"><div class="typing-indicator"><div class="typing-dot"></div><div class="typing-dot"></div><div class="typing-dot"></div> Running System Diagnostics...</div></div>`;
log.scrollTop=log.scrollHeight;
try{
const res=await fetch('/system/diagnostics/full');
const data=await res.json();
const typingElem=document.getElementById(typingId);
if(typingElem) typingElem.remove();
if(data.success){
const report=data.diagnostics;
const health=report.health_score;
let healthClass='health-red';
if(health>=80) healthClass='health-green';
else if(health>=50) healthClass='health-yellow';
let html=`<div class="message-wrapper">
<div class="bubble ai-text">
<h3>πŸ“Š System Diagnostics Report</h3>
<div class="health-indicator ${healthClass}">
<i class="fas fa-heartbeat"></i>
<span class="health-value">Health: ${health}/100</span>
<span>(${report.status})</span>
</div>
<br>
<strong>System Resources:</strong><br>
β€’ CPU: ${report.sections?.system_resources?.cpu?.usage_percent || 'N/A'}%<br>
β€’ Memory: ${report.sections?.system_resources?.memory?.used_percent || 'N/A'}%<br>
β€’ Disk: ${report.sections?.system_resources?.disk?.used_percent || 'N/A'}%<br>
<br>
<strong>Services:</strong><br>
β€’ Groq API: ${report.sections?.external_services?.groq_api?.status || 'N/A'}<br>
β€’ TiDB: ${report.sections?.external_services?.tidb_database?.status || 'N/A'}<br>
<br>
<small>Report ID: ${report.system_id}</small>
</div>
</div>`;
log.innerHTML+=html;
}else{
log.innerHTML+=`<div class="message-wrapper"><div class="error-message"><i class="fas fa-exclamation-circle"></i> Diagnostics failed: ${data.error}</div></div>`;
}
}catch(e){
const typingElem=document.getElementById(typingId);
if(typingElem) typingElem.remove();
log.innerHTML+=`<div class="message-wrapper"><div class="error-message"><i class="fas fa-exclamation-circle"></i> Diagnostics error: ${e.message}</div></div>`;
}
log.scrollTop=log.scrollHeight;
}
// Run Tests
async function runTests(){
const log=document.getElementById('chat-log');
const typingId='tests-'+Date.now();
log.innerHTML+=`<div class="message-wrapper" id="${typingId}"><div class="typing-indicator"><div class="typing-dot"></div><div class="typing-dot"></div><div class="typing-dot"></div> Running System Tests...</div></div>`;
log.scrollTop=log.scrollHeight;
try{
const res=await fetch('/system/tests/run');
const data=await res.json();
const typingElem=document.getElementById(typingId);
if(typingElem) typingElem.remove();
if(data.success){
const results=data.results;
let html=`<div class="message-wrapper">
<div class="bubble ai-text">
<h3>πŸ§ͺ System Test Results</h3>
<div class="health-indicator ${results.summary.score >= 80 ? 'health-green' : results.summary.score >= 50 ? 'health-yellow' : 'health-red'}">
<i class="fas fa-vial"></i>
<span class="health-value">Score: ${results.summary.score}/100</span>
<span>(${results.summary.status})</span>
</div>
<br>
<strong>Test Summary:</strong><br>
β€’ Total Tests: ${results.summary.total_tests}<br>
β€’ Passed: ${results.summary.passed}<br>
β€’ Failed: ${results.summary.failed}<br>
<br>
<strong>Categories Tested:</strong><br>
${Object.keys(results.tests).map(cat=>`β€’ ${cat}`).join('<br>')}
</div>
</div>`;
log.innerHTML+=html;
}else{
log.innerHTML+=`<div class="message-wrapper"><div class="error-message"><i class="fas fa-exclamation-circle"></i> Tests failed: ${data.error}</div></div>`;
}
}catch(e){
const typingElem=document.getElementById(typingId);
if(typingElem) typingElem.remove();
log.innerHTML+=`<div class="message-wrapper"><div class="error-message"><i class="fas fa-exclamation-circle"></i> Tests error: ${e.message}</div></div>`;
}
log.scrollTop=log.scrollHeight;
}
// Send function
async function send(){
const input=document.getElementById('user-input');
const log=document.getElementById('chat-log');
const text=input.value.trim();
if(!text)return;
// Add user message
log.innerHTML+=`<div class="message-wrapper"><div class="bubble user-text">${text}</div></div>`;
input.value=''; input.style.height='auto';
// Typing indicator
const typingId='typing-'+Date.now();
log.innerHTML+=`<div class="message-wrapper" id="${typingId}"><div class="typing-indicator"><div class="typing-dot"></div><div class="typing-dot"></div><div class="typing-dot"></div></div></div>`;
log.scrollTop=log.scrollHeight;
try{
const res=await fetch('/chat',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'message='+encodeURIComponent(text)});
const data=await res.json();
const typingElem=document.getElementById(typingId); if(typingElem)typingElem.remove();
let formatted=formatCodeBlocks(data.response);
log.innerHTML+=`<div class="message-wrapper"><div class="bubble ai-text">${formatted}</div></div>`;
}catch(e){
const typingElem=document.getElementById(typingId); if(typingElem)typingElem.remove();
log.innerHTML+=`<div class="message-wrapper"><div class="error-message"><i class="fas fa-exclamation-circle"></i> Error connecting to AumCore. Please try again.</div></div>`;
}
log.scrollTop=log.scrollHeight;
}
document.addEventListener('DOMContentLoaded',()=>{const input=document.getElementById('user-input');if(input)input.focus();});
</script>
</body>
</html>
'''
# ============================================
# 5. CORE ENDPOINTS (NEVER CHANGES)
# ============================================
@app.get("/", response_class=HTMLResponse)
async def get_ui():
"""Main UI endpoint"""
return HTML_UI
@app.post("/reset")
async def reset():
"""Reset system memory"""
try:
# Check if memory_db module exists
try:
from core.memory_db import tidb_memory
return {"success": True, "message": "Memory clear ho gayi hai!"}
except ImportError:
return {"success": True, "message": "Reset command accepted (no TiDB configured)"}
except Exception as e:
return {"success": False, "message": f"Reset error: {str(e)}"}
@app.post("/chat")
async def chat(message: str = Form(...)):
"""Main chat endpoint"""
if not GROQ_AVAILABLE:
return {"response": "Error: Groq API not configured. Please check API key."}
try:
from core.language_detector import detect_input_language, get_system_prompt, generate_basic_code
from core.memory_db import tidb_memory
except ImportError as e:
return {"response": f"Error: Required modules not found - {str(e)}"}
lang_mode = detect_input_language(message)
system_prompt = get_system_prompt(lang_mode, AumCoreConfig.USERNAME)
# Check for code generation requests
msg_lower = message.lower()
CODE_KEYWORDS = ["python code", "write code", "generate code", "create script",
"program for", "function for", "mount google drive",
"colab notebook", "script for", "coding task"]
if any(k in msg_lower for k in CODE_KEYWORDS):
code_response = generate_basic_code(message)
try:
tidb_memory.save_chat(message, code_response, lang_mode)
except Exception as e:
print(f"⚠️ TiDB save error: {e}")
return {"response": code_response}
# Get chat history
recent_chats = []
try:
recent_chats = tidb_memory.get_recent_chats(limit=10)
except Exception as e:
print(f"⚠️ TiDB history fetch error: {e}")
# Prepare messages for Groq
api_messages = [{"role": "system", "content": system_prompt}]
for chat_row in recent_chats:
user_input, ai_response, _ = chat_row
api_messages.append({"role": "user", "content": user_input})
api_messages.append({"role": "assistant", "content": ai_response})
api_messages.append({"role": "user", "content": message})
# Call Groq API
try:
completion = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=api_messages,
temperature=0.3,
max_tokens=1000
)
ai_response = completion.choices[0].message.content.strip()
# Save to database
try:
tidb_memory.save_chat(message, ai_response, lang_mode)
except Exception as e:
print(f"⚠️ TiDB save error: {e}")
return {"response": ai_response}
except Exception as e:
error_msg = f"System Error: {str(e)}"
print(f"❌ API Error: {error_msg}")
return {"response": error_msg}
# ============================================
# 6. SYSTEM MANAGEMENT ENDPOINTS
# ============================================
@app.get("/system/health")
async def system_health():
"""Overall system health check"""
health_data = {
"success": True,
"timestamp": asyncio.get_event_loop().time(),
"version": AumCoreConfig.VERSION,
"status": "OPERATIONAL",
"modules_loaded": len(module_manager.loaded_modules),
"groq_available": GROQ_AVAILABLE,
"health_score": 95 # Default high score
}
# Add module-specific health if available
diagnostics_module = module_manager.get_module("diagnostics")
if diagnostics_module and hasattr(diagnostics_module, 'get_health'):
try:
module_health = await diagnostics_module.get_health()
health_data.update(module_health)
except:
pass
return health_data
@app.get("/system/modules/status")
async def modules_status():
"""Get status of all loaded modules"""
return {
"success": True,
"total": len(module_manager.loaded_modules),
"modules": [
{
"name": name,
"status": info["status"],
"active": True
}
for name, info in module_manager.loaded_modules.items()
]
}
@app.get("/system/info")
async def system_info():
"""Get complete system information"""
return {
"success": True,
"system": {
"name": "AumCore AI",
"version": AumCoreConfig.VERSION,
"architecture": "Modular Microservices",
"developer": "Sanjay & AI Assistant"
},
"capabilities": {
"ai_chat": True,
"code_generation": True,
"hindi_english": True,
"memory_storage": True,
"system_monitoring": "diagnostics" in module_manager.loaded_modules,
"automated_testing": "testing" in module_manager.loaded_modules,
"task_orchestration": "orchestrator" in module_manager.loaded_modules
},
"endpoints": [
"/", "/chat", "/reset",
"/system/health", "/system/info", "/system/modules/status"
]
}
# ============================================
# 7. STARTUP AND SHUTDOWN EVENTS
# ============================================
@app.on_event("startup")
async def startup_event():
"""Initialize system on startup"""
print("=" * 60)
print("πŸš€ AUMCORE AI - ULTIMATE FINAL VERSION")
print("=" * 60)
print(f"πŸ“ Version: {AumCoreConfig.VERSION}")
print(f"πŸ‘€ Username: {AumCoreConfig.USERNAME}")
print(f"🌐 Server: http://{AumCoreConfig.HOST}:{AumCoreConfig.PORT}")
print(f"πŸ€– AI Model: llama-3.3-70b-versatile")
print(f"πŸ’Ύ Database: TiDB Cloud")
print(f"🎨 UI Features: Code formatting + Copy button")
# Load all modules
module_manager.load_all_modules()
# Initial health check
print("\nπŸ” Initial System Check:")
print(f" Groq API: {'βœ… Available' if GROQ_AVAILABLE else '❌ Not Available'}")
print(f" Modules: {len(module_manager.loaded_modules)} loaded")
print(f" Directories: All created")
print("=" * 60)
print("βœ… System ready! Waiting for requests...")
print("=" * 60)
@app.on_event("shutdown")
async def shutdown_event():
"""Cleanup on shutdown"""
print("\nπŸ›‘ System shutting down...")
print("βœ… Cleanup completed")
# ============================================
# 8. MAIN EXECUTION
# ============================================
if __name__ == "__main__":
uvicorn.run(
app,
host=AumCoreConfig.HOST,
port=AumCoreConfig.PORT,
log_level="info"
)