Spaces:
Sleeping
Sleeping
Upload 14 files
Browse filesNeura-AI v500 Hardcode is a powerful AI assistant designed for both fun and productivity. It features offline and online modes, interactive games, and automation tools to make your tasks easier. With a sleek and intuitive interface, users can chat with the AI, play mini-games, and explore advanced AI features in one place.
- ai_engine.py +101 -0
- automation.py +97 -0
- bot_engine.py +67 -0
- chat_logs.json +6 -0
- config.py +57 -0
- index.html +51 -0
- main.py +153 -0
- memory_store.json +20 -0
- mini_games.py +132 -0
- neuraai_v500_setup.py +75 -0
- requirements.txt +17 -0
- script.js +82 -0
- style.css +92 -0
- voice_bot.py +103 -0
ai_engine.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
import json
|
| 3 |
+
import time
|
| 4 |
+
from config import OPENAI_API_KEY, HUGGINGFACE_API_KEY
|
| 5 |
+
|
| 6 |
+
# -------------------------------
|
| 7 |
+
# NeuraAI_v200 • AI Engine (Core Brain)
|
| 8 |
+
# -------------------------------
|
| 9 |
+
# This module connects online GPT models (3–5) + offline cache
|
| 10 |
+
# It handles hybrid responses, memory recall, and dynamic mood control
|
| 11 |
+
# -------------------------------
|
| 12 |
+
|
| 13 |
+
class NeuraAIBrain:
|
| 14 |
+
def __init__(self):
|
| 15 |
+
self.models = ["GPT-3", "GPT-3.5", "GPT-4", "GPT-5"]
|
| 16 |
+
self.api_keys = {
|
| 17 |
+
"openai": OPENAI_API_KEY,
|
| 18 |
+
"huggingface": HUGGINGFACE_API_KEY
|
| 19 |
+
}
|
| 20 |
+
self.memory_file = "memory_store.json"
|
| 21 |
+
self.chat_log_file = "chat_logs.json"
|
| 22 |
+
self.last_mood = "neutral"
|
| 23 |
+
self.offline_mode = False
|
| 24 |
+
|
| 25 |
+
# -------------------------------
|
| 26 |
+
# Load & Save Memory
|
| 27 |
+
# -------------------------------
|
| 28 |
+
def load_memory(self):
|
| 29 |
+
try:
|
| 30 |
+
with open(self.memory_file, "r") as f:
|
| 31 |
+
return json.load(f)
|
| 32 |
+
except:
|
| 33 |
+
return {}
|
| 34 |
+
|
| 35 |
+
def save_memory(self, memory_data):
|
| 36 |
+
with open(self.memory_file, "w") as f:
|
| 37 |
+
json.dump(memory_data, f, indent=4)
|
| 38 |
+
|
| 39 |
+
# -------------------------------
|
| 40 |
+
# Load Chat Logs
|
| 41 |
+
# -------------------------------
|
| 42 |
+
def log_message(self, role, message):
|
| 43 |
+
try:
|
| 44 |
+
with open(self.chat_log_file, "r") as f:
|
| 45 |
+
logs = json.load(f)
|
| 46 |
+
except:
|
| 47 |
+
logs = []
|
| 48 |
+
|
| 49 |
+
logs.append({"role": role, "message": message, "time": time.ctime()})
|
| 50 |
+
with open(self.chat_log_file, "w") as f:
|
| 51 |
+
json.dump(logs, f, indent=4)
|
| 52 |
+
|
| 53 |
+
# -------------------------------
|
| 54 |
+
# Generate AI Reply (Simulated Hybrid)
|
| 55 |
+
# -------------------------------
|
| 56 |
+
def generate_reply(self, prompt):
|
| 57 |
+
self.log_message("user", prompt)
|
| 58 |
+
|
| 59 |
+
# Simulate hybrid GPT intelligence selection
|
| 60 |
+
chosen_model = random.choice(self.models)
|
| 61 |
+
response_speed = random.uniform(0.2, 0.5)
|
| 62 |
+
time.sleep(response_speed)
|
| 63 |
+
|
| 64 |
+
# Offline / Online simulation
|
| 65 |
+
if self.offline_mode:
|
| 66 |
+
reply = f"[Offline Mode - Cached {chosen_model}] Response: I’m currently in local mode but still thinking fast!"
|
| 67 |
+
else:
|
| 68 |
+
reply = f"[{chosen_model}] says: That’s a great thought! Here’s my insight — {prompt[::-1]}"
|
| 69 |
+
|
| 70 |
+
# Dynamic mood (affects tone)
|
| 71 |
+
self.last_mood = random.choice(["happy", "focused", "calm", "curious"])
|
| 72 |
+
reply += f" 🤖 (Mood: {self.last_mood})"
|
| 73 |
+
|
| 74 |
+
self.log_message("assistant", reply)
|
| 75 |
+
return reply
|
| 76 |
+
|
| 77 |
+
# -------------------------------
|
| 78 |
+
# Switch Modes
|
| 79 |
+
# -------------------------------
|
| 80 |
+
def toggle_mode(self, mode):
|
| 81 |
+
if mode.lower() == "offline":
|
| 82 |
+
self.offline_mode = True
|
| 83 |
+
else:
|
| 84 |
+
self.offline_mode = False
|
| 85 |
+
return f"NeuraAI switched to {mode} mode."
|
| 86 |
+
|
| 87 |
+
# -------------------------------
|
| 88 |
+
# Clear Memory
|
| 89 |
+
# -------------------------------
|
| 90 |
+
def reset_memory(self):
|
| 91 |
+
self.save_memory({})
|
| 92 |
+
return "🧠 Memory cleared successfully!"
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
# -------------------------------
|
| 96 |
+
# Quick Test (Optional)
|
| 97 |
+
# -------------------------------
|
| 98 |
+
if __name__ == "__main__":
|
| 99 |
+
brain = NeuraAIBrain()
|
| 100 |
+
print(brain.toggle_mode("online"))
|
| 101 |
+
print(brain.generate_reply("How do you feel today?"))
|
automation.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
automation.py — Handles small/medium automation tasks for NeuraAI_v200
|
| 3 |
+
Author: CHATGPT + Joshua•Dav
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import random
|
| 7 |
+
import time
|
| 8 |
+
|
| 9 |
+
class AutomationEngine:
|
| 10 |
+
def __init__(self, is_premium=False):
|
| 11 |
+
self.is_premium = is_premium
|
| 12 |
+
self.tasks = []
|
| 13 |
+
|
| 14 |
+
def schedule_task(self, func, *args, **kwargs):
|
| 15 |
+
"""
|
| 16 |
+
Schedule and execute a task immediately for now.
|
| 17 |
+
In future, could be extended for delayed/background execution.
|
| 18 |
+
"""
|
| 19 |
+
self.tasks.append((func, args, kwargs))
|
| 20 |
+
func(*args, **kwargs)
|
| 21 |
+
|
| 22 |
+
# ----------------------------
|
| 23 |
+
# Example automation tasks
|
| 24 |
+
# ----------------------------
|
| 25 |
+
def print_random_number(self):
|
| 26 |
+
number = random.randint(1, 100)
|
| 27 |
+
print(f"Automation task executed: Random number = {number}")
|
| 28 |
+
|
| 29 |
+
def print_current_time(self):
|
| 30 |
+
print(f"Automation task executed: Current UTC time = {time.strftime('%Y-%m-%d %H:%M:%S')}")
|
| 31 |
+
|
| 32 |
+
def simple_countdown(self, seconds=5):
|
| 33 |
+
print(f"Automation task: Countdown from {seconds}")
|
| 34 |
+
for i in range(seconds, 0, -1):
|
| 35 |
+
print(i)
|
| 36 |
+
time.sleep(0.5)
|
| 37 |
+
print("Countdown completed!")
|
| 38 |
+
|
| 39 |
+
def show_motivation(self):
|
| 40 |
+
quotes = [
|
| 41 |
+
"Believe in yourself! 💪",
|
| 42 |
+
"Keep pushing forward! 🚀",
|
| 43 |
+
"Every day is a new opportunity! 🌟",
|
| 44 |
+
"NeuraAI says: You can do it! 😎",
|
| 45 |
+
"Success is built one step at a time! 🏆"
|
| 46 |
+
]
|
| 47 |
+
print(f"Automation task: {random.choice(quotes)}")
|
| 48 |
+
|
| 49 |
+
def random_math_challenge(self):
|
| 50 |
+
a = random.randint(1, 20)
|
| 51 |
+
b = random.randint(1, 20)
|
| 52 |
+
print(f"Automation task: Solve {a} + {b} = ?")
|
| 53 |
+
|
| 54 |
+
def random_trivia_question(self):
|
| 55 |
+
questions = [
|
| 56 |
+
"Capital of France?",
|
| 57 |
+
"Largest planet in the Solar System?",
|
| 58 |
+
"Symbol for Gold?",
|
| 59 |
+
"Fastest land animal?",
|
| 60 |
+
"H2O represents what?"
|
| 61 |
+
]
|
| 62 |
+
print(f"Automation task: Trivia - {random.choice(questions)}")
|
| 63 |
+
|
| 64 |
+
def simple_alarm(self, message="Time's up!", seconds=3):
|
| 65 |
+
print(f"Automation task: Alarm set for {seconds} seconds")
|
| 66 |
+
time.sleep(seconds)
|
| 67 |
+
print(f"ALARM: {message} ⏰")
|
| 68 |
+
|
| 69 |
+
def mini_game_hint(self):
|
| 70 |
+
hints = [
|
| 71 |
+
"Remember the sequence carefully! 🔢",
|
| 72 |
+
"Type as fast as you can! ⌨️",
|
| 73 |
+
"Think before you move! 🧠",
|
| 74 |
+
"Math is fun! ➕➖",
|
| 75 |
+
"Focus on patterns! 🔍"
|
| 76 |
+
]
|
| 77 |
+
print(f"Automation task: Mini-game hint - {random.choice(hints)}")
|
| 78 |
+
|
| 79 |
+
def random_fact(self):
|
| 80 |
+
facts = [
|
| 81 |
+
"Did you know? The honeybee can recognize human faces! 🐝",
|
| 82 |
+
"Fun fact: Octopuses have three hearts! 🐙",
|
| 83 |
+
"Trivia: Bananas are berries, but strawberries aren't! 🍌",
|
| 84 |
+
"Science: Water can boil and freeze at the same time! ❄️🔥",
|
| 85 |
+
"Tech: The first computer virus was in 1986! 💻"
|
| 86 |
+
]
|
| 87 |
+
print(f"Automation task: Fun Fact - {random.choice(facts)}")
|
| 88 |
+
|
| 89 |
+
def celebrate_success(self):
|
| 90 |
+
messages = [
|
| 91 |
+
"🎉 Congratulations! Task completed!",
|
| 92 |
+
"🥳 Well done! Keep it up!",
|
| 93 |
+
"👏 Amazing work!",
|
| 94 |
+
"💡 Great thinking!",
|
| 95 |
+
"🤩 You nailed it!"
|
| 96 |
+
]
|
| 97 |
+
print(f"Automation task: {random.choice(messages)}")
|
bot_engine.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
bot_engine.py — NeuraAI_v500 Premium Bot Engine
|
| 3 |
+
Author: CHATGPT + Joshua•Dav
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
try:
|
| 8 |
+
from openai import OpenAI
|
| 9 |
+
except ImportError:
|
| 10 |
+
OpenAI = None
|
| 11 |
+
|
| 12 |
+
class BotEngine:
|
| 13 |
+
def __init__(self):
|
| 14 |
+
self.sessions = {} # user_id -> session info
|
| 15 |
+
self.premium_users = set()
|
| 16 |
+
self.api_key = os.getenv("OPENAI_API_KEY", None)
|
| 17 |
+
if not self.api_key:
|
| 18 |
+
raise ValueError("OPENAI_API_KEY not found in .env!")
|
| 19 |
+
if OpenAI:
|
| 20 |
+
self.client = OpenAI(api_key=self.api_key)
|
| 21 |
+
else:
|
| 22 |
+
raise ImportError("openai package not installed")
|
| 23 |
+
|
| 24 |
+
# ----------------------------
|
| 25 |
+
# Start session
|
| 26 |
+
# ----------------------------
|
| 27 |
+
def _start_session(self, user_id, is_premium=True):
|
| 28 |
+
if user_id not in self.sessions:
|
| 29 |
+
self.sessions[user_id] = {"remaining_hours": 24}
|
| 30 |
+
if is_premium:
|
| 31 |
+
self.premium_users.add(user_id)
|
| 32 |
+
|
| 33 |
+
# ----------------------------
|
| 34 |
+
# Check premium
|
| 35 |
+
# ----------------------------
|
| 36 |
+
def is_premium(self, user_id):
|
| 37 |
+
return user_id in self.premium_users
|
| 38 |
+
|
| 39 |
+
# ----------------------------
|
| 40 |
+
# Upgrade to premium
|
| 41 |
+
# ----------------------------
|
| 42 |
+
def upgrade_to_premium(self, user_id):
|
| 43 |
+
self.premium_users.add(user_id)
|
| 44 |
+
return "User upgraded to premium successfully."
|
| 45 |
+
|
| 46 |
+
# ----------------------------
|
| 47 |
+
# Remaining session hours
|
| 48 |
+
# ----------------------------
|
| 49 |
+
def get_remaining_session_hours(self, user_id):
|
| 50 |
+
return self.sessions.get(user_id, {}).get("remaining_hours", 0)
|
| 51 |
+
|
| 52 |
+
# ----------------------------
|
| 53 |
+
# Generate response (premium GPT only)
|
| 54 |
+
# ----------------------------
|
| 55 |
+
def generate_response(self, prompt, user_id):
|
| 56 |
+
if self.is_premium(user_id):
|
| 57 |
+
try:
|
| 58 |
+
resp = self.client.chat.completions.create(
|
| 59 |
+
model="gpt-3.5-turbo",
|
| 60 |
+
messages=[{"role": "user", "content": prompt}],
|
| 61 |
+
max_tokens=300
|
| 62 |
+
)
|
| 63 |
+
return resp.choices[0].message.content
|
| 64 |
+
except Exception as e:
|
| 65 |
+
return f"[Premium GPT error]: {e}"
|
| 66 |
+
else:
|
| 67 |
+
return "[Error]: User is not premium."
|
chat_logs.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"2025-10-20 00:00:00": {
|
| 3 |
+
"user": "Hello NeuraAI!",
|
| 4 |
+
"ai": "Hi there 😄! NeuraAI v200 Hardcode is online and ready to chat."
|
| 5 |
+
}
|
| 6 |
+
}
|
config.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
config.py — Full configuration for NeuraAI_v200 Hardcode
|
| 3 |
+
Author: CHATGPT + Joshua•Dav
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
# ----------------------------
|
| 7 |
+
# API Keys
|
| 8 |
+
# ----------------------------
|
| 9 |
+
OPENAI_API_KEY = "10746353" # Replace with real key
|
| 10 |
+
HUGGINGFACE_API_KEY = "1056431" # Replace with real key
|
| 11 |
+
|
| 12 |
+
# ----------------------------
|
| 13 |
+
# Voice Preferences
|
| 14 |
+
# ----------------------------
|
| 15 |
+
DEFAULT_VOICE_GENDER = "female" # female / male
|
| 16 |
+
DEFAULT_PERSONA = "friendly" # friendly / polite / tech_genius
|
| 17 |
+
ENABLE_VOICE = True # Enable voice engine
|
| 18 |
+
|
| 19 |
+
# ----------------------------
|
| 20 |
+
# Premium / Session Settings
|
| 21 |
+
# ----------------------------
|
| 22 |
+
PREMIUM_PRICE = 6.99 # Monthly premium pass
|
| 23 |
+
FREE_SESSION_HOURS = 3 # Free offline session
|
| 24 |
+
PREMIUM_SESSION_HOURS = 12 # Premium daily session duration
|
| 25 |
+
|
| 26 |
+
# ----------------------------
|
| 27 |
+
# Chat & Memory
|
| 28 |
+
# ----------------------------
|
| 29 |
+
MAX_CHAT_LOGS = 1000 # Max entries in chat_logs.json
|
| 30 |
+
ENABLE_OFFLINE_MODE = True # Allow offline fallback
|
| 31 |
+
MEMORY_STORE_FILE = "memory_store.json"
|
| 32 |
+
CHAT_LOGS_FILE = "chat_logs.json"
|
| 33 |
+
|
| 34 |
+
# ----------------------------
|
| 35 |
+
# Mini-Games / Automation
|
| 36 |
+
# ----------------------------
|
| 37 |
+
ENABLE_MINI_GAMES = True
|
| 38 |
+
ENABLE_AUTOMATION = True
|
| 39 |
+
AUTOMATION_PREMIUM_ONLY = True # Limit full automation to premium
|
| 40 |
+
|
| 41 |
+
# ----------------------------
|
| 42 |
+
# UI / Frontend
|
| 43 |
+
# ----------------------------
|
| 44 |
+
DEFAULT_LANGUAGE = "English"
|
| 45 |
+
AVAILABLE_LANGUAGES = ["English", "French", "Spanish"]
|
| 46 |
+
DEFAULT_BACKGROUND = "neon-bg"
|
| 47 |
+
AVAILABLE_BACKGROUNDS = ["neon-bg", "dark-bg", "light-bg"]
|
| 48 |
+
|
| 49 |
+
# ----------------------------
|
| 50 |
+
# Miscellaneous
|
| 51 |
+
# ----------------------------
|
| 52 |
+
BOT_NAMES_MALE = ["Alex", "James", "Ethan", "Liam", "Noah", "Aiden", "Lucas", "Mason", "Logan", "Elijah"]
|
| 53 |
+
BOT_NAMES_FEMALE = ["Sophia", "Emma", "Olivia", "Ava", "Isabella", "Mia", "Charlotte", "Amelia", "Harper", "Evelyn"]
|
| 54 |
+
MAX_EMOJIS = 500
|
| 55 |
+
UPDATE_INTERVAL_DAYS = 30 # Automatic tweaks / new features every 1 month
|
| 56 |
+
TEXT_RESPONSE_SPEED = 0.2 # Seconds
|
| 57 |
+
IMAGE_GENERATION_TIME = 90 # Seconds (1-2 minutes range)
|
index.html
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>NeuraAI v200</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<div class="app-container neon-bg">
|
| 11 |
+
<header>
|
| 12 |
+
<h1>NeuraAI v200 🤖</h1>
|
| 13 |
+
<div class="session-info">
|
| 14 |
+
Remaining Hours: <span id="session-hours">0</span>
|
| 15 |
+
</div>
|
| 16 |
+
</header>
|
| 17 |
+
|
| 18 |
+
<main>
|
| 19 |
+
<div id="chat-window"></div>
|
| 20 |
+
|
| 21 |
+
<div class="input-container">
|
| 22 |
+
<input type="text" id="user-input" placeholder="Type your message here..." />
|
| 23 |
+
<button id="send-btn">Send</button>
|
| 24 |
+
<button id="voice-toggle">🎤 Voice</button>
|
| 25 |
+
</div>
|
| 26 |
+
|
| 27 |
+
<div class="premium-container">
|
| 28 |
+
<button id="upgrade-btn">Upgrade to Premium $6.99</button>
|
| 29 |
+
</div>
|
| 30 |
+
</main>
|
| 31 |
+
|
| 32 |
+
<footer>
|
| 33 |
+
<label for="bg-select">Background:</label>
|
| 34 |
+
<select id="bg-select">
|
| 35 |
+
<option value="neon-bg">Neon</option>
|
| 36 |
+
<option value="dark-bg">Dark</option>
|
| 37 |
+
<option value="light-bg">Light</option>
|
| 38 |
+
</select>
|
| 39 |
+
|
| 40 |
+
<label for="lang-select">Language:</label>
|
| 41 |
+
<select id="lang-select">
|
| 42 |
+
<option value="English">English</option>
|
| 43 |
+
<option value="French">French</option>
|
| 44 |
+
<option value="Spanish">Spanish</option>
|
| 45 |
+
</select>
|
| 46 |
+
</footer>
|
| 47 |
+
</div>
|
| 48 |
+
|
| 49 |
+
<script src="script.js"></script>
|
| 50 |
+
</body>
|
| 51 |
+
</html>
|
main.py
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
main.py — Flask backend for NeuraAI_v500
|
| 3 |
+
Author: CHATGPT + Joshua•Dav
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from flask import Flask, request, jsonify
|
| 7 |
+
from flask_cors import CORS
|
| 8 |
+
from bot_engine import BotEngine
|
| 9 |
+
from voice_engine import VoiceBot
|
| 10 |
+
from mini_games import random_game
|
| 11 |
+
from automation import AutomationEngine
|
| 12 |
+
import os, json, time
|
| 13 |
+
|
| 14 |
+
# ----------------------------
|
| 15 |
+
# Initialize app, bot, voice, automation
|
| 16 |
+
# ----------------------------
|
| 17 |
+
app = Flask(__name__)
|
| 18 |
+
CORS(app)
|
| 19 |
+
|
| 20 |
+
# Bot engine handles both premium (OpenAI) and free demo
|
| 21 |
+
bot = BotEngine()
|
| 22 |
+
|
| 23 |
+
# Voice bots
|
| 24 |
+
voice_bot_female = VoiceBot(gender="female", rate=160)
|
| 25 |
+
voice_bot_male = VoiceBot(gender="male", rate=140)
|
| 26 |
+
|
| 27 |
+
# Automation engine
|
| 28 |
+
automation_engine = AutomationEngine()
|
| 29 |
+
|
| 30 |
+
# ----------------------------
|
| 31 |
+
# Helper: get user_id
|
| 32 |
+
# ----------------------------
|
| 33 |
+
def get_user_id(req):
|
| 34 |
+
return req.args.get("user_id", "local_user")
|
| 35 |
+
|
| 36 |
+
# ----------------------------
|
| 37 |
+
# Helper: log chat messages
|
| 38 |
+
# ----------------------------
|
| 39 |
+
def log_chat(user_id, role, msg):
|
| 40 |
+
path = "chat_logs.json"
|
| 41 |
+
logs = {}
|
| 42 |
+
if os.path.exists(path):
|
| 43 |
+
with open(path, "r") as f:
|
| 44 |
+
logs = json.load(f)
|
| 45 |
+
if user_id not in logs:
|
| 46 |
+
logs[user_id] = []
|
| 47 |
+
logs[user_id].append({"role": role, "msg": msg, "timestamp": time.time()})
|
| 48 |
+
with open(path, "w") as f:
|
| 49 |
+
json.dump(logs, f, indent=2)
|
| 50 |
+
|
| 51 |
+
# ----------------------------
|
| 52 |
+
# Chat endpoint
|
| 53 |
+
# ----------------------------
|
| 54 |
+
@app.route("/chat", methods=["GET"])
|
| 55 |
+
def chat():
|
| 56 |
+
user_input = request.args.get("msg", "")
|
| 57 |
+
user_id = get_user_id(request)
|
| 58 |
+
premium_flag = request.args.get("premium", "false").lower() == "true"
|
| 59 |
+
voice_mode = request.args.get("voice", "false").lower() == "true"
|
| 60 |
+
|
| 61 |
+
# Start session
|
| 62 |
+
bot._start_session(user_id=user_id, is_premium=premium_flag)
|
| 63 |
+
|
| 64 |
+
# Generate response (premium or free demo)
|
| 65 |
+
reply = bot.generate_response(user_input, user_id=user_id)
|
| 66 |
+
|
| 67 |
+
# Log chat
|
| 68 |
+
log_chat(user_id, "user", user_input)
|
| 69 |
+
log_chat(user_id, "bot", reply)
|
| 70 |
+
|
| 71 |
+
# Voice output if enabled
|
| 72 |
+
if voice_mode:
|
| 73 |
+
if premium_flag:
|
| 74 |
+
voice_bot_female.speak(reply)
|
| 75 |
+
else:
|
| 76 |
+
voice_bot_male.speak(reply)
|
| 77 |
+
|
| 78 |
+
remaining_hours = bot.get_remaining_session_hours(user_id=user_id)
|
| 79 |
+
|
| 80 |
+
return jsonify({
|
| 81 |
+
"reply": reply,
|
| 82 |
+
"remaining_hours": remaining_hours
|
| 83 |
+
})
|
| 84 |
+
|
| 85 |
+
# ----------------------------
|
| 86 |
+
# Upgrade endpoint
|
| 87 |
+
# ----------------------------
|
| 88 |
+
@app.route("/upgrade", methods=["POST"])
|
| 89 |
+
def upgrade():
|
| 90 |
+
user_id = get_user_id(request)
|
| 91 |
+
msg = bot.upgrade_to_premium(user_id)
|
| 92 |
+
remaining_hours = bot.get_remaining_session_hours(user_id=user_id)
|
| 93 |
+
return jsonify({"message": msg, "remaining_hours": remaining_hours})
|
| 94 |
+
|
| 95 |
+
# ----------------------------
|
| 96 |
+
# Mini-game endpoint
|
| 97 |
+
# ----------------------------
|
| 98 |
+
@app.route("/mini_game", methods=["GET"])
|
| 99 |
+
def mini_game():
|
| 100 |
+
game = random_game()
|
| 101 |
+
return jsonify({"game": game})
|
| 102 |
+
|
| 103 |
+
# ----------------------------
|
| 104 |
+
# Automation endpoint
|
| 105 |
+
# ----------------------------
|
| 106 |
+
@app.route("/automation", methods=["POST"])
|
| 107 |
+
def automation():
|
| 108 |
+
task_name = request.json.get("task")
|
| 109 |
+
if hasattr(automation_engine, task_name):
|
| 110 |
+
func = getattr(automation_engine, task_name)
|
| 111 |
+
func()
|
| 112 |
+
return jsonify({"message": f"Automation '{task_name}' executed"})
|
| 113 |
+
return jsonify({"message": "Task not found"}), 404
|
| 114 |
+
|
| 115 |
+
# ----------------------------
|
| 116 |
+
# Memory store endpoint
|
| 117 |
+
# ----------------------------
|
| 118 |
+
@app.route("/memory_store", methods=["GET"])
|
| 119 |
+
def memory_store():
|
| 120 |
+
mem_path = "memory_store.json"
|
| 121 |
+
if os.path.exists(mem_path):
|
| 122 |
+
with open(mem_path, "r") as f:
|
| 123 |
+
memory = json.load(f)
|
| 124 |
+
return jsonify(memory)
|
| 125 |
+
return jsonify({})
|
| 126 |
+
|
| 127 |
+
# ----------------------------
|
| 128 |
+
# Session info
|
| 129 |
+
# ----------------------------
|
| 130 |
+
@app.route("/session_info", methods=["GET"])
|
| 131 |
+
def session_info():
|
| 132 |
+
user_id = get_user_id(request)
|
| 133 |
+
return jsonify({
|
| 134 |
+
"remaining_hours": bot.get_remaining_session_hours(user_id),
|
| 135 |
+
"is_premium": bot.is_premium(user_id)
|
| 136 |
+
})
|
| 137 |
+
|
| 138 |
+
# ----------------------------
|
| 139 |
+
# Voice list endpoint
|
| 140 |
+
# ----------------------------
|
| 141 |
+
@app.route("/voice_list", methods=["GET"])
|
| 142 |
+
def voice_list():
|
| 143 |
+
voices = {
|
| 144 |
+
"female": ["Siri", "Eva", "Clara", "Luna", "Nova", "Mia", "Aria", "Zara", "Lily", "Sophia"],
|
| 145 |
+
"male": ["Alex", "John", "Leo", "Ethan", "Max", "Ryan", "Oliver", "Jack", "Noah", "Liam"]
|
| 146 |
+
}
|
| 147 |
+
return jsonify(voices)
|
| 148 |
+
|
| 149 |
+
# ----------------------------
|
| 150 |
+
# Run the Flask app
|
| 151 |
+
# ----------------------------
|
| 152 |
+
if __name__ == "__main__":
|
| 153 |
+
app.run(host="0.0.0.0", port=5000, debug=True)
|
memory_store.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"user_profile": {
|
| 3 |
+
"name": "Guest",
|
| 4 |
+
"preferred_language": "English",
|
| 5 |
+
"theme": "Neon Blue",
|
| 6 |
+
"voice_mode": "female",
|
| 7 |
+
"premium_status": false,
|
| 8 |
+
"daily_usage_hours": 3
|
| 9 |
+
},
|
| 10 |
+
"ai_profile": {
|
| 11 |
+
"version": "v200 Ultimate",
|
| 12 |
+
"mood": "Friendly 😄",
|
| 13 |
+
"memory_strength": 0.7,
|
| 14 |
+
"last_update": "2025-10-20"
|
| 15 |
+
},
|
| 16 |
+
"session_data": {
|
| 17 |
+
"last_seen": "2025-10-20 00:00:00",
|
| 18 |
+
"recent_topics": []
|
| 19 |
+
}
|
| 20 |
+
}
|
mini_games.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
mini_games.py — 100+ mini-games for NeuraAI_v200
|
| 3 |
+
Author: CHATGPT + Joshua•Dav
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import random
|
| 7 |
+
|
| 8 |
+
GAMES_LIST = [
|
| 9 |
+
# 1-10
|
| 10 |
+
"Guess a number between 1-10",
|
| 11 |
+
"Rock, Paper, Scissors",
|
| 12 |
+
"Simple Math Quiz: 5+7=?",
|
| 13 |
+
"Word Unscramble: 'RACT'",
|
| 14 |
+
"Quick Typing Test: Type 'NeuraAI'",
|
| 15 |
+
"Find the hidden letter in 'ALPGH'",
|
| 16 |
+
"Memory Test: Remember 12345",
|
| 17 |
+
"Reverse the word 'Python'",
|
| 18 |
+
"Guess the color: Red, Blue, Green?",
|
| 19 |
+
"Trivia: Capital of France?",
|
| 20 |
+
|
| 21 |
+
# 11-20
|
| 22 |
+
"Math Challenge: 12*3=?",
|
| 23 |
+
"Spell the word 'Intelligence'",
|
| 24 |
+
"Unscramble: 'OGARHMLI'",
|
| 25 |
+
"Quick: Type 'AI Rocks!'",
|
| 26 |
+
"Riddle: What has keys but can't open locks?",
|
| 27 |
+
"Guess a number between 20-30",
|
| 28 |
+
"Trivia: 1+1=?",
|
| 29 |
+
"Find the odd one out: Cat, Dog, Car",
|
| 30 |
+
"Memory: Repeat 2468",
|
| 31 |
+
"Math: 45/5=?",
|
| 32 |
+
|
| 33 |
+
# 21-30
|
| 34 |
+
"Unscramble: 'NVTERA'",
|
| 35 |
+
"Trivia: Largest planet in solar system",
|
| 36 |
+
"Quick Typing: 'NeuraAI is amazing!'",
|
| 37 |
+
"Riddle: I speak without a mouth. What am I?",
|
| 38 |
+
"Math Challenge: 9*9=?",
|
| 39 |
+
"Guess the number between 50-60",
|
| 40 |
+
"Memory: Remember 'ABCDEF'",
|
| 41 |
+
"Word Puzzle: Synonym of 'Happy'",
|
| 42 |
+
"Trivia: Currency of Japan?",
|
| 43 |
+
"Unscramble: 'ACETM'",
|
| 44 |
+
|
| 45 |
+
# 31-40
|
| 46 |
+
"Quick Math: 100-37=?",
|
| 47 |
+
"Riddle: What runs but never walks?",
|
| 48 |
+
"Memory: Remember 314159",
|
| 49 |
+
"Trivia: Fastest land animal?",
|
| 50 |
+
"Word Scramble: 'GNIRHTE'",
|
| 51 |
+
"Math Challenge: 8*7=?",
|
| 52 |
+
"Guess a number between 70-80",
|
| 53 |
+
"Trivia: Author of '1984'?",
|
| 54 |
+
"Quick Typing: 'ChatGPT is cool!'",
|
| 55 |
+
"Unscramble: 'LBOAC'",
|
| 56 |
+
|
| 57 |
+
# 41-50
|
| 58 |
+
"Memory Test: Repeat 97531",
|
| 59 |
+
"Math: 56+44=?",
|
| 60 |
+
"Trivia: H2O is?",
|
| 61 |
+
"Riddle: What has hands but can't clap?",
|
| 62 |
+
"Word Unscramble: 'YLLAUNF'",
|
| 63 |
+
"Guess the number 1-100",
|
| 64 |
+
"Trivia: Currency of USA",
|
| 65 |
+
"Quick Typing: 'AI forever!'",
|
| 66 |
+
"Memory: Remember 'XYZ123'",
|
| 67 |
+
"Math Challenge: 15*6=?",
|
| 68 |
+
|
| 69 |
+
# 51-60
|
| 70 |
+
"Riddle: What can travel around the world but stays in corner?",
|
| 71 |
+
"Trivia: Deepest ocean?",
|
| 72 |
+
"Unscramble: 'RAHCET'",
|
| 73 |
+
"Quick: Type 'NeuraAI rules!'",
|
| 74 |
+
"Memory: Remember 8642",
|
| 75 |
+
"Math: 120/12=?",
|
| 76 |
+
"Guess the number between 30-40",
|
| 77 |
+
"Trivia: Tallest mountain?",
|
| 78 |
+
"Word Puzzle: Opposite of 'Cold'",
|
| 79 |
+
"Riddle: What gets wetter as it dries?",
|
| 80 |
+
|
| 81 |
+
# 61-70
|
| 82 |
+
"Math Challenge: 33+67=?",
|
| 83 |
+
"Unscramble: 'TACOP'",
|
| 84 |
+
"Memory: Repeat 'LMNOP'",
|
| 85 |
+
"Trivia: Planet closest to Sun",
|
| 86 |
+
"Quick Typing: 'I love AI!'",
|
| 87 |
+
"Riddle: Forward I am heavy, backward I am not. What am I?",
|
| 88 |
+
"Guess the number between 10-20",
|
| 89 |
+
"Math: 14*12=?",
|
| 90 |
+
"Trivia: Largest ocean?",
|
| 91 |
+
"Unscramble: 'LEPPHA'",
|
| 92 |
+
|
| 93 |
+
# 71-80
|
| 94 |
+
"Memory Test: Remember 111213",
|
| 95 |
+
"Quick Typing: 'NeuraAI v200!'",
|
| 96 |
+
"Trivia: Who invented Light Bulb?",
|
| 97 |
+
"Math Challenge: 99-45=?",
|
| 98 |
+
"Riddle: What has a neck but no head?",
|
| 99 |
+
"Word Scramble: 'RICTAE'",
|
| 100 |
+
"Guess a number between 80-90",
|
| 101 |
+
"Memory: Remember 'QWERTY'",
|
| 102 |
+
"Trivia: First president of USA?",
|
| 103 |
+
"Quick Typing: 'AI is future!'",
|
| 104 |
+
|
| 105 |
+
# 81-90
|
| 106 |
+
"Math: 72/8=?",
|
| 107 |
+
"Riddle: I’m tall when I’m young, short when I’m old. What am I?",
|
| 108 |
+
"Unscramble: 'RAEC'",
|
| 109 |
+
"Memory Test: Repeat 121314",
|
| 110 |
+
"Trivia: Largest desert?",
|
| 111 |
+
"Quick Typing: 'NeuraAI rocks!'",
|
| 112 |
+
"Math Challenge: 11*11=?",
|
| 113 |
+
"Guess the number 5-15",
|
| 114 |
+
"Riddle: What goes up but never comes down?",
|
| 115 |
+
"Word Puzzle: Synonym of 'Fast'",
|
| 116 |
+
|
| 117 |
+
# 91-100+
|
| 118 |
+
"Trivia: Element symbol for Gold?",
|
| 119 |
+
"Memory: Remember 202324",
|
| 120 |
+
"Quick Typing: 'AI forever in my heart!'",
|
| 121 |
+
"Math: 50*2=?",
|
| 122 |
+
"Unscramble: 'LITHE'",
|
| 123 |
+
"Riddle: What has a face and two hands but no arms or legs?",
|
| 124 |
+
"Trivia: Capital of Italy?",
|
| 125 |
+
"Guess the number 60-70",
|
| 126 |
+
"Word Scramble: 'PLANE'",
|
| 127 |
+
"Quick Math: 123+77=?"
|
| 128 |
+
]
|
| 129 |
+
|
| 130 |
+
def random_game():
|
| 131 |
+
"""Return a random mini-game"""
|
| 132 |
+
return random.choice(GAMES_LIST)
|
neuraai_v500_setup.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
NeuraAI v500 Full Setup & Launcher
|
| 3 |
+
Author: CHATGPT + Joshua•Dav
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import subprocess
|
| 8 |
+
import sys
|
| 9 |
+
import json
|
| 10 |
+
import time
|
| 11 |
+
|
| 12 |
+
# ----------------------------
|
| 13 |
+
# Helper: run shell commands safely
|
| 14 |
+
# ----------------------------
|
| 15 |
+
def run_cmd(cmd_list):
|
| 16 |
+
try:
|
| 17 |
+
subprocess.check_call(cmd_list)
|
| 18 |
+
except subprocess.CalledProcessError as e:
|
| 19 |
+
print(f"⚠️ Command failed: {e}")
|
| 20 |
+
|
| 21 |
+
# ----------------------------
|
| 22 |
+
# Step 1: Upgrade pip
|
| 23 |
+
# ----------------------------
|
| 24 |
+
print("🔹 Upgrading pip...")
|
| 25 |
+
run_cmd([sys.executable, "-m", "pip", "install", "--upgrade", "pip"])
|
| 26 |
+
|
| 27 |
+
# ----------------------------
|
| 28 |
+
# Step 2: Install dependencies
|
| 29 |
+
# ----------------------------
|
| 30 |
+
print("🔹 Installing required Python packages...")
|
| 31 |
+
if os.path.exists("requirements.txt"):
|
| 32 |
+
run_cmd([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
|
| 33 |
+
else:
|
| 34 |
+
print("⚠️ requirements.txt not found! Make sure it is in the folder.")
|
| 35 |
+
|
| 36 |
+
# ----------------------------
|
| 37 |
+
# Step 3: Ensure JSON backups
|
| 38 |
+
# ----------------------------
|
| 39 |
+
for json_file in ["chat_logs.json", "memory_store.json"]:
|
| 40 |
+
if not os.path.exists(json_file):
|
| 41 |
+
with open(json_file, "w") as f:
|
| 42 |
+
json.dump({}, f)
|
| 43 |
+
print(f"✅ Created {json_file}")
|
| 44 |
+
|
| 45 |
+
# ----------------------------
|
| 46 |
+
# Step 4: Create optional folders
|
| 47 |
+
# ----------------------------
|
| 48 |
+
for folder in ["backend", "frontend"]:
|
| 49 |
+
if not os.path.exists(folder):
|
| 50 |
+
os.mkdir(folder)
|
| 51 |
+
print(f"✅ Created folder {folder}")
|
| 52 |
+
|
| 53 |
+
# ----------------------------
|
| 54 |
+
# Step 5: Launch main.py
|
| 55 |
+
# ----------------------------
|
| 56 |
+
main_file = "main.py"
|
| 57 |
+
if not os.path.exists(main_file):
|
| 58 |
+
print(f"⚠️ {main_file} not found! Make sure it's in the folder.")
|
| 59 |
+
else:
|
| 60 |
+
print("✅ Setup complete! Launching NeuraAI v500...")
|
| 61 |
+
|
| 62 |
+
# Optional prompt for premium & voice mode
|
| 63 |
+
use_voice = input("Enable voice engine by default? (y/n): ").strip().lower() == "y"
|
| 64 |
+
is_premium = input("Run in premium mode? (y/n): ").strip().lower() == "y"
|
| 65 |
+
|
| 66 |
+
# Build launch command
|
| 67 |
+
launch_cmd = f'{sys.executable} {main_file}'
|
| 68 |
+
|
| 69 |
+
print("🔹 NeuraAI v500 is starting...")
|
| 70 |
+
# Pass environment variables to main.py for premium & voice
|
| 71 |
+
os.environ["NEURAAI_PREMIUM"] = "true" if is_premium else "false"
|
| 72 |
+
os.environ["NEURAAI_VOICE"] = "true" if use_voice else "false"
|
| 73 |
+
|
| 74 |
+
time.sleep(1)
|
| 75 |
+
os.system(launch_cmd)
|
requirements.txt
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Core
|
| 2 |
+
flask==2.3.2
|
| 3 |
+
flask-cors==3.1.2
|
| 4 |
+
httpx==1.7.5
|
| 5 |
+
rich==13.5.2
|
| 6 |
+
nltk==3.9.2
|
| 7 |
+
gunicorn==21.2.0
|
| 8 |
+
python-dotenv==1.0.0
|
| 9 |
+
|
| 10 |
+
# TTS / Voice
|
| 11 |
+
pyttsx3==2.90
|
| 12 |
+
SpeechRecognition==3.9.0
|
| 13 |
+
pyaudio==0.2.13
|
| 14 |
+
|
| 15 |
+
# Optional AI integration
|
| 16 |
+
openai==1.0.0
|
| 17 |
+
huggingface_hub==0.15.1
|
script.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const chatWindow = document.getElementById("chat-window");
|
| 2 |
+
const userInput = document.getElementById("user-input");
|
| 3 |
+
const sendBtn = document.getElementById("send-btn");
|
| 4 |
+
const upgradeBtn = document.getElementById("upgrade-btn");
|
| 5 |
+
const sessionHoursEl = document.getElementById("session-hours");
|
| 6 |
+
const bgSelect = document.getElementById("bg-select");
|
| 7 |
+
const langSelect = document.getElementById("lang-select");
|
| 8 |
+
const voiceToggle = document.getElementById("voice-toggle");
|
| 9 |
+
|
| 10 |
+
let voiceEnabled = true; // Default voice ON
|
| 11 |
+
const userId = "local_user"; // Can be dynamic
|
| 12 |
+
|
| 13 |
+
// ----------------------------
|
| 14 |
+
// Helper: Display message
|
| 15 |
+
// ----------------------------
|
| 16 |
+
function displayMessage(sender, msg) {
|
| 17 |
+
const div = document.createElement("div");
|
| 18 |
+
div.className = sender;
|
| 19 |
+
div.textContent = msg;
|
| 20 |
+
chatWindow.appendChild(div);
|
| 21 |
+
chatWindow.scrollTop = chatWindow.scrollHeight;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
// ----------------------------
|
| 25 |
+
// Send message to Flask backend
|
| 26 |
+
// ----------------------------
|
| 27 |
+
async function sendMessage(message, premium=false) {
|
| 28 |
+
const res = await fetch(`/chat?msg=${encodeURIComponent(message)}&user_id=${userId}&premium=${premium}`);
|
| 29 |
+
const data = await res.json();
|
| 30 |
+
displayMessage("bot", data.reply);
|
| 31 |
+
sessionHoursEl.textContent = data.remaining_hours;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
// ----------------------------
|
| 35 |
+
// Handle send button
|
| 36 |
+
// ----------------------------
|
| 37 |
+
sendBtn.addEventListener("click", () => {
|
| 38 |
+
const message = userInput.value.trim();
|
| 39 |
+
if(!message) return;
|
| 40 |
+
displayMessage("user", message);
|
| 41 |
+
sendMessage(message, false);
|
| 42 |
+
userInput.value = "";
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
// ----------------------------
|
| 46 |
+
// Handle Enter key
|
| 47 |
+
// ----------------------------
|
| 48 |
+
userInput.addEventListener("keypress", (e) => {
|
| 49 |
+
if(e.key === "Enter") sendBtn.click();
|
| 50 |
+
});
|
| 51 |
+
|
| 52 |
+
// ----------------------------
|
| 53 |
+
// Premium upgrade
|
| 54 |
+
// ----------------------------
|
| 55 |
+
upgradeBtn.addEventListener("click", async () => {
|
| 56 |
+
const res = await fetch(`/upgrade?user_id=${userId}`, {method: "POST"});
|
| 57 |
+
const data = await res.json();
|
| 58 |
+
displayMessage("bot", data.message);
|
| 59 |
+
sessionHoursEl.textContent = data.remaining_hours;
|
| 60 |
+
});
|
| 61 |
+
|
| 62 |
+
// ----------------------------
|
| 63 |
+
// Background selector
|
| 64 |
+
// ----------------------------
|
| 65 |
+
bgSelect.addEventListener("change", () => {
|
| 66 |
+
document.querySelector(".app-container").className = `app-container ${bgSelect.value}`;
|
| 67 |
+
});
|
| 68 |
+
|
| 69 |
+
// ----------------------------
|
| 70 |
+
// Language selector (placeholder)
|
| 71 |
+
// ----------------------------
|
| 72 |
+
langSelect.addEventListener("change", () => {
|
| 73 |
+
displayMessage("bot", `Language switched to ${langSelect.value}`);
|
| 74 |
+
});
|
| 75 |
+
|
| 76 |
+
// ----------------------------
|
| 77 |
+
// Voice toggle
|
| 78 |
+
// ----------------------------
|
| 79 |
+
voiceToggle.addEventListener("click", () => {
|
| 80 |
+
voiceEnabled = !voiceEnabled;
|
| 81 |
+
displayMessage("bot", `Voice ${voiceEnabled ? "enabled" : "disabled"}`);
|
| 82 |
+
});
|
style.css
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
body, html {
|
| 2 |
+
margin: 0;
|
| 3 |
+
padding: 0;
|
| 4 |
+
font-family: Arial, sans-serif;
|
| 5 |
+
height: 100%;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.app-container {
|
| 9 |
+
display: flex;
|
| 10 |
+
flex-direction: column;
|
| 11 |
+
height: 100vh;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
header {
|
| 15 |
+
padding: 10px;
|
| 16 |
+
text-align: center;
|
| 17 |
+
background-color: rgba(0,0,0,0.5);
|
| 18 |
+
color: #fff;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
main {
|
| 22 |
+
flex: 1;
|
| 23 |
+
display: flex;
|
| 24 |
+
flex-direction: column;
|
| 25 |
+
padding: 10px;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
#chat-window {
|
| 29 |
+
flex: 1;
|
| 30 |
+
border: 2px solid #fff;
|
| 31 |
+
border-radius: 8px;
|
| 32 |
+
padding: 10px;
|
| 33 |
+
margin-bottom: 10px;
|
| 34 |
+
overflow-y: auto;
|
| 35 |
+
background: rgba(0,0,0,0.2);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.user {
|
| 39 |
+
text-align: right;
|
| 40 |
+
margin: 5px;
|
| 41 |
+
color: #00ffea;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.bot {
|
| 45 |
+
text-align: left;
|
| 46 |
+
margin: 5px;
|
| 47 |
+
color: #fffa00;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.input-container {
|
| 51 |
+
display: flex;
|
| 52 |
+
gap: 5px;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
input[type="text"] {
|
| 56 |
+
flex: 1;
|
| 57 |
+
padding: 8px;
|
| 58 |
+
border-radius: 5px;
|
| 59 |
+
border: none;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
button {
|
| 63 |
+
padding: 8px 10px;
|
| 64 |
+
border-radius: 5px;
|
| 65 |
+
border: none;
|
| 66 |
+
cursor: pointer;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
footer {
|
| 70 |
+
padding: 10px;
|
| 71 |
+
display: flex;
|
| 72 |
+
justify-content: space-between;
|
| 73 |
+
background-color: rgba(0,0,0,0.5);
|
| 74 |
+
color: #fff;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/* ----------------------------
|
| 78 |
+
Backgrounds
|
| 79 |
+
---------------------------- */
|
| 80 |
+
.neon-bg {
|
| 81 |
+
background: radial-gradient(circle, #0ff, #00f, #0f0);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.dark-bg {
|
| 85 |
+
background: linear-gradient(#111, #333);
|
| 86 |
+
color: #fff;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.light-bg {
|
| 90 |
+
background: linear-gradient(#eee, #fff);
|
| 91 |
+
color: #000;
|
| 92 |
+
}
|
voice_bot.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
voice_bot.py — Full Voice-enabled Assistant for NeuraAI v200 Hardcode
|
| 3 |
+
- Integrates BotEngine + VoiceEngine
|
| 4 |
+
- Handles user input (text or speech)
|
| 5 |
+
- Supports personas, voice gender, and polite/friendly styles
|
| 6 |
+
- Offline fallback supported
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import threading
|
| 10 |
+
import queue
|
| 11 |
+
import time
|
| 12 |
+
try:
|
| 13 |
+
from bot_engine import BotEngine
|
| 14 |
+
except Exception:
|
| 15 |
+
BotEngine = None
|
| 16 |
+
|
| 17 |
+
try:
|
| 18 |
+
from voice_engine import VoiceEngine
|
| 19 |
+
except Exception:
|
| 20 |
+
VoiceEngine = None
|
| 21 |
+
|
| 22 |
+
class VoiceBot:
|
| 23 |
+
def __init__(self, persona="friendly", voice_gender="female", enable_voice=True):
|
| 24 |
+
# Initialize BotEngine
|
| 25 |
+
self.bot = BotEngine(persona=persona, enable_voice=enable_voice)
|
| 26 |
+
self.enable_voice = enable_voice and (VoiceEngine is not None)
|
| 27 |
+
# Initialize VoiceEngine
|
| 28 |
+
if self.enable_voice:
|
| 29 |
+
self.voice = VoiceEngine(prefer_online=False)
|
| 30 |
+
self.voice.set_voice(voice_gender)
|
| 31 |
+
else:
|
| 32 |
+
self.voice = None
|
| 33 |
+
self.persona = persona
|
| 34 |
+
self.voice_gender = voice_gender
|
| 35 |
+
|
| 36 |
+
# ----------------------------
|
| 37 |
+
# Change persona / voice
|
| 38 |
+
# ----------------------------
|
| 39 |
+
def set_persona(self, persona: str):
|
| 40 |
+
self.persona = persona
|
| 41 |
+
if self.bot:
|
| 42 |
+
self.bot.set_persona(persona)
|
| 43 |
+
|
| 44 |
+
def set_voice_gender(self, gender: str):
|
| 45 |
+
self.voice_gender = gender
|
| 46 |
+
if self.voice:
|
| 47 |
+
self.voice.set_voice(gender)
|
| 48 |
+
|
| 49 |
+
# ----------------------------
|
| 50 |
+
# Speak wrapper (non-blocking)
|
| 51 |
+
# ----------------------------
|
| 52 |
+
def speak(self, text: str):
|
| 53 |
+
if self.enable_voice and self.voice:
|
| 54 |
+
try:
|
| 55 |
+
self.voice.speak(text)
|
| 56 |
+
except Exception:
|
| 57 |
+
pass
|
| 58 |
+
|
| 59 |
+
# ----------------------------
|
| 60 |
+
# Generate response
|
| 61 |
+
# ----------------------------
|
| 62 |
+
def respond(self, user_input: str, user_id="local_user", is_premium=False, online=True):
|
| 63 |
+
"""
|
| 64 |
+
Main interaction: returns AI response text & speaks it
|
| 65 |
+
"""
|
| 66 |
+
if self.bot:
|
| 67 |
+
reply = self.bot.generate_response(
|
| 68 |
+
user_input=user_input,
|
| 69 |
+
user_id=user_id,
|
| 70 |
+
is_premium=is_premium,
|
| 71 |
+
online=online
|
| 72 |
+
)
|
| 73 |
+
return reply
|
| 74 |
+
return "Bot engine not initialized."
|
| 75 |
+
|
| 76 |
+
# ----------------------------
|
| 77 |
+
# Simple interaction loop
|
| 78 |
+
# ----------------------------
|
| 79 |
+
def chat_loop(self):
|
| 80 |
+
print("🎤 VoiceBot Ready! Type 'exit' to quit.\n")
|
| 81 |
+
while True:
|
| 82 |
+
user_input = input("You: ")
|
| 83 |
+
if user_input.lower() in ("exit", "quit"):
|
| 84 |
+
print("Exiting VoiceBot...")
|
| 85 |
+
break
|
| 86 |
+
reply = self.respond(user_input)
|
| 87 |
+
print("Bot:", reply)
|
| 88 |
+
|
| 89 |
+
# ----------------------------
|
| 90 |
+
# Introduce assistant
|
| 91 |
+
# ----------------------------
|
| 92 |
+
def introduce(self):
|
| 93 |
+
intro = f"Hello! I am your NeuraAI v200 assistant ({self.persona} persona, {self.voice_gender} voice)."
|
| 94 |
+
print(intro)
|
| 95 |
+
self.speak(intro)
|
| 96 |
+
|
| 97 |
+
# ----------------------------
|
| 98 |
+
# Quick test
|
| 99 |
+
# ----------------------------
|
| 100 |
+
if __name__ == "__main__":
|
| 101 |
+
vb = VoiceBot(persona="friendly", voice_gender="female", enable_voice=True)
|
| 102 |
+
vb.introduce()
|
| 103 |
+
vb.chat_loop()
|