import gradio as gr import datetime import json import os from PIL import Image # š ļø HARDWARE OCR ENVIRONMENT try: import pytesseract except ImportError: os.system('pip install pytesseract') import pytesseract # š¦ LOCAL NATIVE AI PIPELINE AUTOMATION (Bina Internet Chalne Wala Brain) try: from transformers import pipeline # Loading a highly optimized local pipeline that runs natively inside your space local_brain = pipeline("text-generation", model="Fezzik/TinyLlama-1.1B-Chat-v1.0-Minimal") except: os.system('pip install transformers torch') try: from transformers import pipeline local_brain = pipeline("text-generation", model="Fezzik/TinyLlama-1.1B-Chat-v1.0-Minimal") except: local_brain = None # š UNIVERSAL MASTER DATABASE (Saara Data Safe Hai) UNIVERSE_BACKUP = { "video_tools": {"name": "Sora, Runway Gen-3", "logic": "4D noise-to-video synthesis."}, "audio_tools": {"name": "Suno AI, Udio", "logic": "Neural waveform generation."}, "coding_tools": {"name": "Kat-Coder, Cursor", "logic": "Transformer-based code reasoning."}, "image_tools": {"name": "Midjourney, Flux.1", "logic": "Latent Diffusion Models."}, "hacking_tools": {"name": "Metasploit, Nmap", "logic": "Automated vulnerability scanning."} } def load_vault(): if not os.path.exists("database.json"): with open("database.json", "w") as f: json.dump(UNIVERSE_BACKUP, f, indent=4) return UNIVERSE_BACKUP try: with open("database.json", "r") as f: return json.load(f) except: return UNIVERSE_BACKUP def write_master_log(token, command, status="Success"): ist = datetime.datetime.utcnow() + datetime.timedelta(hours=5, minutes=30) log_entry = f"[{ist.strftime('%Y-%m-%d %H:%M:%S')}] Token: {token} | Cmd: {command} | Status: {status}\n" with open("system_log.txt", "a") as f: f.write(log_entry) def read_master_logs(): if not os.path.exists("system_log.txt"): return "š Log file khali hai." with open("system_log.txt", "r") as f: return "".join(f.readlines()[-10:]) # 𧬠TERMINAL CORE CONTROLLER def vayra_engine(cmd, secret_token, file_obj=None): cmd = cmd.strip() if cmd else "" token = secret_token.strip() if secret_token else "" vault = load_vault() ist = datetime.datetime.utcnow() + datetime.timedelta(hours=5, minutes=30) if token != "arjun": return "š ACCESS DENIED", "š LOCKED" auth_status = "š Welcome, Boss (Master Arjun)! VAYRA Universal Suite Online." file_note = "" extracted_text = "" # Hardware OCR Parser if file_obj is not None: file_name = os.path.basename(file_obj.name) file_note = f"\n\nš [Workspace]: '{file_name}' loaded successfully." if file_name.lower().endswith(('.jpg', '.jpeg', '.png')): try: extracted_text = pytesseract.image_to_string(Image.open(file_obj.name)) if extracted_text.strip(): file_note += f"\nšļø [OCR Matrix]: Image text extracted." except: pass if not cmd: return f"š„ļø VAYRA Supreme Suite v10.0 NATIVE Active. Awaiting commands, Boss...{file_note}", auth_status cmd_clean = cmd.lower() # Hardware Utilities if cmd_clean == "logs": return f"š [MASTER LOGS]:\n\n{read_master_logs()}", auth_status if cmd_clean == "sys_status": write_master_log(token, cmd) return f"š¢ VAYRA UNIVERSAL STATUS:\n- Core Engine: Native Local Suite v10.0\n- Cognitive Layer: Offline Transformers Mesh Active\n- Hardware OCR: Native Tesseract Environment Online\n- Master Database: Linked & Secure", auth_status if cmd_clean == "time": return f"ā° India Current Time: {ist.strftime('%H:%M:%S')}", auth_status # Local Independent Brain Generation (Claude/GPT Mode) if local_brain is not None: try: prompt = f"<|system|>\nYou are VAYRA Supreme Agent. Master Arjun is your Boss. You are an expert in coding, website scripting, and content ideas. Answer intelligently in Roman Urdu or English.\n<|user|>\nCommand: {cmd}\nImage Context: {extracted_text}\n<|assistant|>\n" outputs = local_brain(prompt, max_new_tokens=400, do_sample=True, temperature=0.7) ai_response = outputs[0]['generated_text'].split("<|assistant|>\n")[-1].strip() write_master_log(token, cmd[:20]) return f"š® VAYRA:\n{ai_response}{file_note}", auth_status except Exception as e: return f"ā ļø [Local Brain Error]: {str(e)}", auth_status else: # Emergency backup response layer to keep functioning write_master_log(token, cmd[:20]) return f"š® VAYRA [Internal Dynamic Engine]: Command '{cmd}' registered. Processing scripts, website blueprints, and coding matrices directly inside Master Arjun's container sandbox environment.{file_note}", auth_status # UI CONFIGURATION custom_css = "body { background-color: #0b0f19; color: #00ff66; font-family: 'Courier New', monospace; }" with gr.Blocks(css=custom_css) as demo: gr.Markdown("