File size: 6,423 Bytes
1554f2f
b5603a1
58aa00e
 
c4e14e1
3987419
773a18b
9628743
 
 
 
 
 
fbafc4f
 
 
 
 
 
 
 
 
 
 
 
 
773a18b
45ba1ba
 
 
 
 
 
 
 
c0dba89
45ba1ba
 
 
 
 
 
 
c0dba89
c4e14e1
c0dba89
c4e14e1
45ba1ba
c0dba89
 
c4e14e1
45ba1ba
c0dba89
773a18b
45ba1ba
 
 
 
 
c4e14e1
45ba1ba
c4e14e1
45ba1ba
773a18b
45ba1ba
942a9a0
c4e14e1
773a18b
45ba1ba
 
773a18b
c4e14e1
9628743
 
 
fbafc4f
3ea956b
 
45ba1ba
 
fbafc4f
45ba1ba
 
 
773a18b
45ba1ba
 
 
 
c4e14e1
fbafc4f
9502c1a
45ba1ba
3ea956b
45ba1ba
fbafc4f
 
 
 
 
 
 
 
 
 
 
 
 
 
773a18b
 
bdceee5
45ba1ba
fbafc4f
942a9a0
c4e14e1
45ba1ba
773a18b
3ea956b
 
c0dba89
 
3ea956b
 
45ba1ba
c0dba89
45ba1ba
 
 
 
9502c1a
8ade76a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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("<h1 style='text-align: center; color: #00ff66;'>๐Ÿ›ก๏ธ VAYRA UNIVERSAL AGENT CORE v10.0</h1>")
    
    token_input = gr.Textbox(label="๐Ÿ”‘ Hidden Master Token", type="password")
    dev_panel = gr.Textbox(label="๐Ÿ› ๏ธ Authorization Status", value="๐Ÿ”’ ADMIN PANEL: LOCKED", interactive=False)
    input_box = gr.Textbox(label="โŒจ๏ธ Terminal Input (Ask Coding, Scripting, Website Ideas, or Management)", placeholder="Type your command here, Boss...")
    file_input = gr.File(label="๐Ÿ“‚ Upload Image / Document Layer")
    output_box = gr.Textbox(label="๐Ÿ–ฅ๏ธ VAYRA Executive Response Output", lines=12)
    
    with gr.Row():
        btn_status = gr.Button("๐Ÿ” System Status")
        btn_time = gr.Button("โฐ Live Time")
    submit_btn = gr.Button("๐Ÿš€ Execute Command", variant="primary")
    
    submit_btn.click(fn=vayra_engine, inputs=[input_box, token_input, file_input], outputs=[output_box, dev_panel])
    input_box.submit(fn=vayra_engine, inputs=[input_box, token_input, file_input], outputs=[output_box, dev_panel])
    btn_status.click(fn=lambda: vayra_engine("sys_status", "arjun"), outputs=[output_box, dev_panel])
    btn_time.click(fn=lambda: vayra_engine("time", "arjun"), outputs=[output_box, dev_panel])

demo.launch()