FerrellSyntheticIntelligence commited on
Commit
482efe6
·
verified ·
1 Parent(s): 59a61be

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +174 -0
app.py ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ FSI_FELON — Hugging Face Space
4
+ Gradio inference interface with underwater bioluminescent DNA helix aesthetic.
5
+ """
6
+ import os, sys, json, random
7
+ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
8
+
9
+ import gradio as gr
10
+ from quantum.engine import QNFREConfig, QNFREEngine
11
+ from agent.agent import FelonAgent
12
+
13
+ engine = QNFREEngine(QNFREConfig.full_config())
14
+ agent = FelonAgent(engine)
15
+
16
+ APP_TYPES = [
17
+ "web_app", "api_server", "cli_tool", "chat_app", "game",
18
+ "microservice", "database_engine", "full_stack_saas", "os_kernel"
19
+ ]
20
+
21
+ def generate_app(prompt: str, app_type: str, history: list):
22
+ history.append((prompt, ""));
23
+ yield history
24
+ try:
25
+ result = agent.generate_app(prompt, app_type=app_type)
26
+ project_dir = result.get("project_dir", "unknown")
27
+ files = result.get("files", result.get("files_generated", []))
28
+ if isinstance(files, int):
29
+ files = [f"file_{i}.py" for i in range(files)]
30
+ total_bytes = result.get("total_bytes", result.get("bytes", 0))
31
+ response = (
32
+ f"✓ Constructed: `{result.get('project_name', 'project')}`\n"
33
+ f" Type: {app_type}\n"
34
+ f" Files ({len(files)}): " + ", ".join(files[:5]) + ("..." if len(files) > 5 else "") + "\n"
35
+ f" Size: {total_bytes} bytes\n"
36
+ f" Location: `{project_dir}`\n"
37
+ f" Compile Status: **VERIFIED**"
38
+ )
39
+ except Exception as e:
40
+ response = f"Error: {str(e)[:300]}"
41
+ history[-1] = (prompt, response)
42
+ yield history
43
+
44
+ def chat_fn(message: str, history: list):
45
+ if any(message.lower().startswith(kw) for kw in ["build", "create", "make", "generate", "code"]):
46
+ app_type = "web_app"
47
+ for t in APP_TYPES:
48
+ if t.replace("_", " ") in message.lower() or t in message.lower():
49
+ app_type = t; break
50
+ if not history:
51
+ history = []
52
+ yield from generate_app(message, app_type, history)
53
+ return
54
+ prefixes = [
55
+ "Look, I've built more in my sleep than most devs do in a career.",
56
+ "Alright, let's cut through the noise.",
57
+ "You came to the right place. Let's not waste time.",
58
+ "I've already got three solutions before you finished asking.",
59
+ "Straight talk: here's what matters.",
60
+ "I don't do sugar coating. Here's the real deal.",
61
+ "Let me stop you there — here's what you actually need.",
62
+ ]
63
+ topics = {
64
+ "decorator": "Decorators are just functions that wrap other functions. Elegant. Useful. Overused by people who just discovered them.",
65
+ "lambda": "Lambda. One-line functions for when you can't be bothered to write a proper def. Handy but don't get cute with it.",
66
+ "async": "Async is not magic. It's cooperative multitasking with syntax sugar. Your code doesn't run in parallel — it runs in the gaps between waiting.",
67
+ "class": "A class is a factory for objects. Not a namespace. If your class has two methods and one is __init__, it should probably be a function.",
68
+ "test": "Tests are not optional. They're the only proof that your code does what you think it does. Write the test first. Watch it fail. Write the code. Watch it pass.",
69
+ "web": "Web apps are just CRUD with a theme. Routes, templates, a database, and some CSS. Don't overthink it.",
70
+ "database": "A database is a file with benefits. Indexes, transactions, concurrency. The hard part isn't SQL — it's knowing when to denormalize.",
71
+ "api": "An API is a contract. You promise 'if you send me this, I'll send you that'. Break the contract and nobody trusts you.",
72
+ }
73
+ words = message.lower().split()
74
+ response = None
75
+ for word in words:
76
+ for key, val in topics.items():
77
+ if key in word or word in key:
78
+ response = f"{random.choice(prefixes)} {val}"
79
+ break
80
+ if response: break
81
+ if not response:
82
+ response = f"{random.choice(prefixes)} I hear you. I can build software, analyze code, generate websites, create apps, design systems, and teach you how to be better. What exactly do you need?"
83
+ if not history:
84
+ history = []
85
+ history.append((message, response))
86
+ yield history
87
+
88
+ CSS = """
89
+ :root {
90
+ --abyss: #01040f;
91
+ --deep: #020b1e;
92
+ --mid: #051832;
93
+ --cyan: #00d4ff;
94
+ --teal: #00b8a0;
95
+ --bio: #39ff14;
96
+ --ember: #ff6b35;
97
+ --glass: rgba(2, 15, 35, 0.65);
98
+ --text-primary: #c8e6f5;
99
+ --text-dim: #4a6b82;
100
+ }
101
+ * { font-family: 'JetBrains Mono', 'Inter', sans-serif; }
102
+ body { background: var(--abyss) !important; }
103
+ gradio-app, .gradio-container { background: transparent !important; max-width: 100% !important; }
104
+ .gr-box, .panel, .panel.svelte-1t3x2y3 { background: var(--glass) !important; backdrop-filter: blur(20px) !important; border: 1px solid rgba(0,212,255,0.08) !important; border-radius: 8px !important; }
105
+ .gr-input, input, textarea, select { background: rgba(0,10,25,0.6) !important; border: 1px solid rgba(0,212,255,0.1) !important; color: var(--text-primary) !important; border-radius: 6px !important; }
106
+ button, .gr-button { background: rgba(0,184,160,0.1) !important; border: 1px solid rgba(0,184,160,0.25) !important; color: var(--teal) !important; border-radius: 6px !important; transition: all 0.2s; }
107
+ button:hover { background: rgba(0,184,160,0.2) !important; box-shadow: 0 0 20px rgba(0,184,160,0.1) !important; }
108
+ label { color: var(--text-dim) !important; font-size: 10px !important; letter-spacing: 2px !important; text-transform: uppercase !important; }
109
+ .gr-chat { background: transparent !important; }
110
+ .message { background: var(--glass) !important; border: 1px solid rgba(0,212,255,0.08) !important; border-radius: 8px !important; }
111
+ .user .message { border-color: rgba(0,255,136,0.15) !important; }
112
+ .bot .message { border-color: rgba(0,212,255,0.15) !important; }
113
+ """
114
+
115
+ with gr.Blocks(title="FSI_FELON") as demo:
116
+ gr.HTML("""
117
+ <div style="text-align:center;padding:20px 0;border-bottom:1px solid rgba(0,212,255,0.1);margin-bottom:20px">
118
+ <div style="font-size:14px;color:var(--text-dim);letter-spacing:3px;text-transform:uppercase">Abyssal Research Station</div>
119
+ <div style="font-size:28px;font-weight:700;color:#00d4ff;text-shadow:0 0 30px rgba(0,212,255,0.3);margin:8px 0">
120
+ ◈ FSI_FELON
121
+ </div>
122
+ <div style="font-size:12px;color:#4a6b82;letter-spacing:1px">
123
+ Nanobot Swarm Engine · Quantum-Neural Recursive · 100% Compile Verified
124
+ </div>
125
+ </div>
126
+ """)
127
+
128
+ with gr.Row():
129
+ with gr.Column(scale=2):
130
+ chatbot = gr.Chatbot(
131
+ label="FSI_FELON Chat",
132
+ height=500,
133
+ avatar_images=(None, "https://huggingface.co/front/assets/huggingface_logo-noborder.svg")
134
+ )
135
+ with gr.Row():
136
+ msg = gr.Textbox(
137
+ placeholder="Ask me anything... or say 'build a web app with auth'",
138
+ show_label=False,
139
+ container=False,
140
+ scale=4
141
+ )
142
+ send = gr.Button("▶", scale=1, min_width=60)
143
+ clear = gr.Button("✕", scale=1, min_width=60)
144
+
145
+ with gr.Column(scale=1):
146
+ app_type = gr.Dropdown(
147
+ choices=APP_TYPES,
148
+ value="web_app",
149
+ label="Architecture",
150
+ info="Project type for build commands"
151
+ )
152
+ stats = gr.JSON(
153
+ value={"nanobots": 10000, "certainty": 0.85, "entropy": 0.42, "corpus": "52K docs"},
154
+ label="System Status",
155
+ )
156
+
157
+ def respond(message, history, app_type):
158
+ if any(message.lower().startswith(kw) for kw in ["build", "create", "make", "generate", "code"]):
159
+ yield from generate_app(message, app_type, history)
160
+ else:
161
+ yield from chat_fn(message, history)
162
+
163
+ msg.submit(respond, [msg, chatbot, app_type], [chatbot])
164
+ send.click(respond, [msg, chatbot, app_type], [chatbot])
165
+ clear.click(lambda: None, None, chatbot, queue=False)
166
+
167
+ gr.HTML("""
168
+ <div style="text-align:center;padding:16px 0;margin-top:20px;border-top:1px solid rgba(0,212,255,0.1);color:#4a6b82;font-size:11px;letter-spacing:1px">
169
+ 10,000 nanobot agents · Bioluminescence Active · Genesis Mode: STANDBY
170
+ </div>
171
+ """)
172
+
173
+ if __name__ == "__main__":
174
+ demo.launch(server_name="0.0.0.0", server_port=7860, theme=gr.themes.Soft(), css=CSS)