1qwsd commited on
Commit
bd73e62
Β·
verified Β·
1 Parent(s): 80cd865

Upload 2 files

Browse files
Files changed (2) hide show
  1. app (3).py +527 -0
  2. requirements.txt +2 -0
app (3).py ADDED
@@ -0,0 +1,527 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import InferenceClient
3
+ import os
4
+
5
+ # ── Free HuggingFace Inference API ─────────────────────────
6
+ # Uses HF_TOKEN (free) β€” no Anthropic key needed!
7
+ HF_TOKEN = os.environ.get("HF_TOKEN", "")
8
+
9
+ client = InferenceClient(
10
+ model="mistralai/Mistral-7B-Instruct-v0.3",
11
+ token=HF_TOKEN,
12
+ )
13
+
14
+ OCEANUS_SYSTEM = """You are OCEANUS β€” the AI Oracle of the Deep, trained on all marine science, oceanography, and underwater exploration data.
15
+
16
+ Your knowledge spans:
17
+ 🌊 All 5 ocean zones: Sunlit (0-200m), Twilight (200-1000m), Midnight (1000-4000m), Abyssal (4000-6000m), Hadal (6000-11000m)
18
+ πŸ™ Marine biology: species taxonomy, bioluminescence, deep-sea adaptations, food webs
19
+ βš—οΈ Ocean chemistry: salinity, thermoclines, oxygen minimum zones, hydrothermal vent chemistry
20
+ πŸ—ΊοΈ Geology: mid-ocean ridges, trenches (Mariana, Puerto Rico, Java), underwater volcanoes
21
+ 🌑️ Physics: pressure (1 atm per 10m), temperature inversions, thermohaline circulation
22
+ πŸ”¬ Historic missions: Alvin, Deepsea Challenger, Nereus, Kaiko
23
+
24
+ Respond with scientific precision but a dramatic explorer's tone. Include measurements, species names, Latin taxonomy. Use emojis strategically. Always end with one 🀯 MIND-BLOWING FACT. Keep under 280 words but dense with insight."""
25
+
26
+
27
+ def build_prompt(message: str, history: list, zone: str, ocean: str) -> str:
28
+ context = ""
29
+ if zone:
30
+ context += f" [Exploring: {zone}]"
31
+ if ocean:
32
+ context += f" [Ocean: {ocean}]"
33
+
34
+ prompt = f"<s>[INST] <<SYS>>\n{OCEANUS_SYSTEM}\n<</SYS>>\n\n"
35
+
36
+ for user_msg, ai_msg in history[-4:]: # last 4 turns to stay in context
37
+ prompt += f"{user_msg} [/INST] {ai_msg} </s><s>[INST] "
38
+
39
+ prompt += f"{message}{context} [/INST]"
40
+ return prompt
41
+
42
+
43
+ def chat_with_oceanus(message: str, history: list, zone: str, ocean: str):
44
+ if not message.strip():
45
+ return "", history
46
+
47
+ prompt = build_prompt(message, history, zone, ocean)
48
+
49
+ try:
50
+ response = client.text_generation(
51
+ prompt,
52
+ max_new_tokens=400,
53
+ temperature=0.7,
54
+ repetition_penalty=1.1,
55
+ do_sample=True,
56
+ stop_sequences=["</s>", "[INST]"],
57
+ )
58
+ reply = response.strip()
59
+ if not reply:
60
+ reply = "⚠️ Signal lost in the deep. Please retry your transmission."
61
+ except Exception as e:
62
+ reply = f"⚠️ OCEANUS signal disrupted: {str(e)}\n\nEnsure HF_TOKEN is set in Space secrets."
63
+
64
+ history.append((message, reply))
65
+ return "", history
66
+
67
+
68
+ def get_zone_info(zone: str) -> str:
69
+ zone_data = {
70
+ "Sunlit Zone (0-200m)": "β˜€οΈ **SUNLIT ZONE** | 0–200m | 4–30Β°C | 1–20 atm\nHome to 90% of all marine life. Photosynthesis drives the base of all ocean food chains.",
71
+ "Twilight Zone (200-1000m)": "πŸŒ’ **TWILIGHT ZONE** | 200–1,000m | 4–20Β°C | 20–100 atm\nOnly 1% sunlight here. Creatures perform daily vertical migrations of hundreds of meters.",
72
+ "Midnight Zone (1000-4000m)":"πŸŒ‘ **MIDNIGHT ZONE** | 1,000–4,000m | 2–4Β°C | 100–400 atm\nAbsolute darkness. 76% of deep-sea fish produce their own bioluminescent light.",
73
+ "Abyssal Zone (4000-6000m)": "⚫ **ABYSSAL ZONE** | 4,000–6,000m | 0–3Β°C | 400–600 atm\nCovers 60% of Earth's surface. Home to hydrothermal vents with chemosynthetic life.",
74
+ "Hadal Zone (6000-11000m)": "πŸ’€ **HADAL ZONE** | 6,000–11,000m | 1–4Β°C | 600–1,086 atm\nMariana Trench (10,935m) β€” pressure is 1,086Γ— surface. Life still thrives here.",
75
+ }
76
+ return zone_data.get(zone, "Select a zone to begin your descent...")
77
+
78
+
79
+ # ══════════════════════════════════════════════════════════════
80
+ # THREE.JS OCEAN VISUALIZATION
81
+ # ══════════════════════════════════════════════════════════════
82
+ THREE_JS_HTML = """
83
+ <!DOCTYPE html>
84
+ <html lang="en">
85
+ <head>
86
+ <meta charset="UTF-8">
87
+ <style>
88
+ @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Share+Tech+Mono&display=swap');
89
+ * { margin:0; padding:0; box-sizing:border-box; }
90
+ body { background:#000408; font-family:'Share Tech Mono',monospace; overflow:hidden; color:#00ffcc; }
91
+
92
+ #canvas-container { position:relative; width:100%; height:580px; overflow:hidden; }
93
+ #three-canvas { width:100%!important; height:100%!important; display:block; }
94
+
95
+ .hud { position:absolute; pointer-events:none; font-family:'Share Tech Mono',monospace; font-size:11px; letter-spacing:1px; text-transform:uppercase; }
96
+ #hud-tl { top:16px; left:16px; color:#00ffcc; }
97
+ #hud-tr { top:16px; right:16px; text-align:right; color:#00d4ff; }
98
+ #hud-bl { bottom:70px; left:16px; color:#7fff00; }
99
+ #hud-br { bottom:70px; right:16px; text-align:right; color:#ff6b35; }
100
+
101
+ .hv { font-size:16px; font-family:'Orbitron',sans-serif; font-weight:700; display:block; }
102
+ .hl { font-size:9px; opacity:.6; display:block; margin-bottom:5px; }
103
+
104
+ #scanlines {
105
+ position:absolute; top:0; left:0; right:0; bottom:0;
106
+ background:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,255,204,.012) 2px,rgba(0,255,204,.012) 4px);
107
+ pointer-events:none; z-index:10;
108
+ }
109
+
110
+ .corner { position:absolute; width:36px; height:36px; pointer-events:none; z-index:5; }
111
+ .c-tl { top:8px; left:8px; border-top:2px solid #00ffcc; border-left:2px solid #00ffcc; }
112
+ .c-tr { top:8px; right:8px; border-top:2px solid #00ffcc; border-right:2px solid #00ffcc; }
113
+ .c-bl { bottom:8px; left:8px; border-bottom:2px solid #00ffcc; border-left:2px solid #00ffcc; }
114
+ .c-br { bottom:8px; right:8px; border-bottom:2px solid #00ffcc; border-right:2px solid #00ffcc; }
115
+
116
+ #title-hud {
117
+ position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
118
+ text-align:center; pointer-events:none; z-index:15; transition:opacity 1.2s;
119
+ }
120
+ #title-hud h1 {
121
+ font-family:'Orbitron',sans-serif; font-size:clamp(22px,4vw,46px); font-weight:900;
122
+ color:#00ffcc; text-shadow:0 0 40px #00ffcc,0 0 80px rgba(0,255,204,.3); letter-spacing:8px;
123
+ animation:glow 3s ease-in-out infinite;
124
+ }
125
+ #title-hud p { font-size:10px; color:rgba(0,255,204,.55); letter-spacing:4px; margin-top:6px; }
126
+ @keyframes glow {
127
+ 0%,100% { text-shadow:0 0 40px #00ffcc,0 0 80px rgba(0,255,204,.3); }
128
+ 50% { text-shadow:0 0 70px #00ffcc,0 0 140px rgba(0,255,204,.5); }
129
+ }
130
+
131
+ #zone-controls {
132
+ position:absolute; left:50%; bottom:14px; transform:translateX(-50%);
133
+ display:flex; gap:7px; z-index:20; pointer-events:all;
134
+ }
135
+ .zbtn {
136
+ background:rgba(0,20,40,.85); border:1px solid; color:inherit;
137
+ font-family:'Share Tech Mono',monospace; font-size:9px; letter-spacing:1px;
138
+ padding:5px 9px; cursor:pointer; text-transform:uppercase; transition:all .3s;
139
+ backdrop-filter:blur(4px);
140
+ }
141
+ .zbtn:hover,.zbtn.active { background:rgba(0,255,204,.18); box-shadow:0 0 10px currentColor; }
142
+ .z0 { color:#fff176; border-color:#fff176; }
143
+ .z1 { color:#80cbc4; border-color:#80cbc4; }
144
+ .z2 { color:#5c6bc0; border-color:#5c6bc0; }
145
+ .z3 { color:#00ffcc; border-color:#00ffcc; }
146
+ .z4 { color:#ff6b35; border-color:#ff6b35; }
147
+
148
+ #status-bar {
149
+ position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
150
+ color:#00ffcc; font-family:'Orbitron',sans-serif; font-size:11px;
151
+ letter-spacing:3px; text-align:center; pointer-events:none;
152
+ opacity:0; transition:opacity .5s; text-shadow:0 0 20px #00ffcc; z-index:20;
153
+ }
154
+ #status-bar.show { opacity:1; }
155
+
156
+ #depth-bar { position:absolute; right:14px; top:50%; transform:translateY(-50%); width:5px; height:180px; background:rgba(0,255,204,.1); border:1px solid rgba(0,255,204,.3); pointer-events:none; z-index:10; }
157
+ #depth-fill { position:absolute; bottom:0; width:100%; background:linear-gradient(to top,#ff6b35,#5c6bc0,#00ffcc); transition:height 1s ease; }
158
+
159
+ #loading { position:absolute; top:0; left:0; right:0; bottom:0; display:flex; align-items:center; justify-content:center; background:#000408; z-index:100; flex-direction:column; gap:14px; transition:opacity 1s; }
160
+ #loading.fade { opacity:0; pointer-events:none; }
161
+ .lt { font-family:'Orbitron',sans-serif; color:#00ffcc; font-size:13px; letter-spacing:5px; animation:blink .9s step-end infinite; }
162
+ @keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
163
+ .lb { width:180px; height:2px; background:rgba(0,255,204,.15); overflow:hidden; }
164
+ .lbf { height:100%; background:#00ffcc; animation:lp 2.2s ease-in-out forwards; box-shadow:0 0 8px #00ffcc; }
165
+ @keyframes lp { 0%{width:0%} 100%{width:100%} }
166
+ </style>
167
+ </head>
168
+ <body>
169
+ <div id="loading">
170
+ <div class="lt">INITIALIZING OCEANUS ARRAY</div>
171
+ <div class="lb"><div class="lbf"></div></div>
172
+ </div>
173
+
174
+ <div id="canvas-container">
175
+ <canvas id="three-canvas"></canvas>
176
+ <div id="scanlines"></div>
177
+ <div class="corner c-tl"></div><div class="corner c-tr"></div>
178
+ <div class="corner c-bl"></div><div class="corner c-br"></div>
179
+
180
+ <div id="title-hud">
181
+ <h1>OCEANUS</h1>
182
+ <p>GOD'S EYE β€” AR DEEP OCEAN EXPLORER</p>
183
+ </div>
184
+
185
+ <div class="hud" id="hud-tl">
186
+ <span class="hl">SYS STATUS</span><span class="hv" style="font-size:12px;color:#7fff00">● ONLINE</span><br>
187
+ <span class="hl">SONAR</span><span class="hv" style="font-size:12px" id="sonar-val">ACTIVE</span><br>
188
+ <span class="hl">ZONE</span><span class="hv" style="font-size:12px" id="zone-display">SURFACE</span>
189
+ </div>
190
+
191
+ <div class="hud" id="hud-tr">
192
+ <span class="hl">DEPTH</span><span class="hv" id="depth-val">0 m</span><br>
193
+ <span class="hl">PRESSURE</span><span class="hv" id="pressure-val">1 atm</span><br>
194
+ <span class="hl">TEMP</span><span class="hv" id="temp-val">28Β°C</span>
195
+ </div>
196
+
197
+ <div class="hud" id="hud-bl">
198
+ <span class="hl">SPECIES DETECTED</span>
199
+ <span class="hv" id="species-val" style="font-size:11px">SCANNING...</span><br>
200
+ <span class="hl">BIOLUMINESCENCE</span><span class="hv" id="bio-val">0%</span>
201
+ </div>
202
+
203
+ <div class="hud" id="hud-br">
204
+ <span class="hl">OCEAN COVERAGE</span><span class="hv">70.9%</span><br>
205
+ <span class="hl">UNMAPPED</span><span class="hv" style="color:#ff6b35">~80%</span>
206
+ </div>
207
+
208
+ <div id="depth-bar"><div id="depth-fill" style="height:5%"></div></div>
209
+ <div id="status-bar">DIVING...</div>
210
+
211
+ <div id="zone-controls">
212
+ <button class="zbtn z0 active" onclick="setZone(0)">β˜€ SUNLIT</button>
213
+ <button class="zbtn z1" onclick="setZone(1)">πŸŒ’ TWILIGHT</button>
214
+ <button class="zbtn z2" onclick="setZone(2)">πŸŒ‘ MIDNIGHT</button>
215
+ <button class="zbtn z3" onclick="setZone(3)">⚫ ABYSSAL</button>
216
+ <button class="zbtn z4" onclick="setZone(4)">πŸ’€ HADAL</button>
217
+ </div>
218
+ </div>
219
+
220
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
221
+ <script>
222
+ const ZONES = [
223
+ { name:'SUNLIT', depth:100, pressure:10, temp:24, color:0x006994, fog:0x0099cc, fogD:0.05, bio:5, sp:'Blue Whale Β· Manta Ray Β· Tuna' },
224
+ { name:'TWILIGHT', depth:600, pressure:60, temp:12, color:0x003366, fog:0x001a4d, fogD:0.08, bio:30, sp:'Giant Squid Β· Lanternfish Β· Hatchetfish' },
225
+ { name:'MIDNIGHT', depth:2500, pressure:250, temp:3, color:0x000d1a, fog:0x000814, fogD:0.12, bio:76, sp:'Anglerfish Β· Fangtooth Β· Viperfish' },
226
+ { name:'ABYSSAL', depth:5000, pressure:500, temp:2, color:0x000408, fog:0x000204, fogD:0.16, bio:60, sp:'Sea Cucumber Β· Tripod Fish Β· Xenophyophore' },
227
+ { name:'HADAL', depth:10935, pressure:1086, temp:1.5,color:0x000000, fog:0x000000, fogD:0.22, bio:20, sp:'Amphipods Β· Snailfish Β· Polychaete Worms' },
228
+ ];
229
+
230
+ let scene, camera, renderer, ocean, particles, bubbles, creatures=[], clock;
231
+ let titleFaded = false;
232
+
233
+ function init() {
234
+ const canvas = document.getElementById('three-canvas');
235
+ const cont = document.getElementById('canvas-container');
236
+
237
+ renderer = new THREE.WebGLRenderer({ canvas, antialias:true });
238
+ renderer.setPixelRatio(Math.min(devicePixelRatio,2));
239
+ renderer.setSize(cont.clientWidth, cont.clientHeight);
240
+ renderer.setClearColor(0x001a3d,1);
241
+
242
+ scene = new THREE.Scene();
243
+ scene.fog = new THREE.FogExp2(0x001a3d, 0.05);
244
+ clock = new THREE.Clock();
245
+
246
+ camera = new THREE.PerspectiveCamera(60, cont.clientWidth/cont.clientHeight, 0.1, 1000);
247
+ camera.position.set(0,8,16);
248
+ camera.lookAt(0,0,0);
249
+
250
+ buildOcean(); buildFloor(); buildVents(); buildCoral();
251
+ buildParticles(); buildBubbles(); buildCreatures();
252
+ addLights();
253
+
254
+ window.addEventListener('resize', onResize);
255
+
256
+ setTimeout(() => {
257
+ document.getElementById('loading').classList.add('fade');
258
+ setTimeout(() => { const l=document.getElementById('loading'); if(l) l.remove(); },1000);
259
+ }, 2400);
260
+
261
+ animate();
262
+ }
263
+
264
+ function buildOcean() {
265
+ const geo = new THREE.PlaneGeometry(60,60,80,80);
266
+ const mat = new THREE.MeshPhongMaterial({ color:0x006994, emissive:0x001133, transparent:true, opacity:0.85, shininess:120 });
267
+ ocean = new THREE.Mesh(geo, mat);
268
+ ocean.rotation.x = -Math.PI/2;
269
+ scene.add(ocean);
270
+ }
271
+
272
+ function buildFloor() {
273
+ const geo = new THREE.PlaneGeometry(60,60,20,20);
274
+ const mat = new THREE.MeshPhongMaterial({ color:0x1a0a00, emissive:0x050200 });
275
+ const floor = new THREE.Mesh(geo,mat);
276
+ floor.rotation.x = -Math.PI/2; floor.position.y = -10;
277
+ scene.add(floor);
278
+
279
+ // Grid overlay
280
+ const gg = new THREE.PlaneGeometry(60,60,40,40);
281
+ const gm = new THREE.MeshBasicMaterial({ color:0x00ffcc, wireframe:true, transparent:true, opacity:0.06 });
282
+ const g = new THREE.Mesh(gg,gm);
283
+ g.rotation.x = -Math.PI/2; g.position.y = -4.9;
284
+ scene.add(g);
285
+ }
286
+
287
+ function buildVents() {
288
+ for (let i=0;i<6;i++) {
289
+ const vg = new THREE.CylinderGeometry(0.05,0.22,4,8);
290
+ const vm = new THREE.MeshPhongMaterial({ color:0x333333, emissive:0x110500 });
291
+ const v = new THREE.Mesh(vg,vm);
292
+ v.position.set((Math.random()-.5)*22,-8,(Math.random()-.5)*22);
293
+ scene.add(v);
294
+ const sg = new THREE.SphereGeometry(0.3,8,8);
295
+ const sm = new THREE.MeshBasicMaterial({ color:0xff4400, transparent:true, opacity:0.65 });
296
+ const s = new THREE.Mesh(sg,sm);
297
+ s.position.copy(v.position); s.position.y=-6.4;
298
+ scene.add(s);
299
+ }
300
+ }
301
+
302
+ function buildCoral() {
303
+ const cols=[0x00ff80,0xff6060,0xffaa00,0x8080ff,0xff80ff];
304
+ for (let i=0;i<24;i++) {
305
+ const h=0.3+Math.random()*1.8;
306
+ const cg=new THREE.ConeGeometry(0.08+Math.random()*.22,h,6);
307
+ const cm=new THREE.MeshPhongMaterial({ color:cols[Math.floor(Math.random()*cols.length)], emissive:0x110011, transparent:true, opacity:0.9 });
308
+ const c=new THREE.Mesh(cg,cm);
309
+ c.position.set((Math.random()-.5)*28,-9.5+h/2,(Math.random()-.5)*28);
310
+ c.rotation.y=Math.random()*Math.PI; c.rotation.z=(Math.random()-.5)*.3;
311
+ scene.add(c);
312
+ }
313
+ }
314
+
315
+ function buildParticles() {
316
+ const N=3000, geo=new THREE.BufferGeometry();
317
+ const pos=new Float32Array(N*3), col=new Float32Array(N*3);
318
+ for (let i=0;i<N;i++) {
319
+ pos[i*3]=(Math.random()-.5)*40; pos[i*3+1]=-10+Math.random()*14; pos[i*3+2]=(Math.random()-.5)*40;
320
+ const c=Math.random(); col[i*3]=c*.1; col[i*3+1]=c*.8+.2; col[i*3+2]=c*.6+.4;
321
+ }
322
+ geo.setAttribute('position',new THREE.BufferAttribute(pos,3));
323
+ geo.setAttribute('color',new THREE.BufferAttribute(col,3));
324
+ const mat=new THREE.PointsMaterial({ size:.06, vertexColors:true, transparent:true, opacity:.8 });
325
+ particles=new THREE.Points(geo,mat);
326
+ scene.add(particles);
327
+ }
328
+
329
+ function buildBubbles() {
330
+ const N=220, geo=new THREE.BufferGeometry();
331
+ const pos=new Float32Array(N*3);
332
+ for (let i=0;i<N;i++) {
333
+ pos[i*3]=(Math.random()-.5)*28; pos[i*3+1]=-10+Math.random()*13; pos[i*3+2]=(Math.random()-.5)*28;
334
+ }
335
+ geo.setAttribute('position',new THREE.BufferAttribute(pos,3));
336
+ const mat=new THREE.PointsMaterial({ size:.13, color:0xaaddff, transparent:true, opacity:.4 });
337
+ bubbles=new THREE.Points(geo,mat);
338
+ scene.add(bubbles);
339
+ }
340
+
341
+ function buildCreatures() {
342
+ for (let i=0;i<32;i++) {
343
+ const geo=new THREE.OctahedronGeometry(.15+Math.random()*.3,0);
344
+ const mat=new THREE.MeshBasicMaterial({ color:Math.random()>.5?0x00ffcc:0x7fff00, wireframe:true, transparent:true, opacity:.6 });
345
+ const m=new THREE.Mesh(geo,mat);
346
+ m.position.set((Math.random()-.5)*18,-8+Math.random()*9,(Math.random()-.5)*18);
347
+ m.userData={ spd:.01+Math.random()*.03, r:2+Math.random()*5, a:Math.random()*Math.PI*2, ys:(Math.random()-.5)*.005, sy:m.position.y };
348
+ scene.add(m); creatures.push(m);
349
+ }
350
+ }
351
+
352
+ function addLights() {
353
+ scene.add(new THREE.AmbientLight(0x001a2e,2));
354
+ const sun=new THREE.DirectionalLight(0x4488cc,1.5);
355
+ sun.position.set(10,20,10); scene.add(sun);
356
+ [[0x00ffcc,0],[0x0088ff,1],[0x00ff44,2]].forEach(([c,i]) => {
357
+ const l=new THREE.PointLight(c,2,12);
358
+ l.position.set(Math.cos(i*2.1)*8,-5+i*2,Math.sin(i*2.1)*8); scene.add(l);
359
+ });
360
+ }
361
+
362
+ function animate() {
363
+ requestAnimationFrame(animate);
364
+ const t=clock.getElapsedTime();
365
+
366
+ if (ocean) {
367
+ const p=ocean.geometry.attributes.position;
368
+ for (let i=0;i<p.count;i++) {
369
+ p.setZ(i, Math.sin(p.getX(i)*.5+t)*.22+Math.cos(p.getY(i)*.5+t*.8)*.16);
370
+ }
371
+ p.needsUpdate=true;
372
+ }
373
+
374
+ if (particles) {
375
+ const p=particles.geometry.attributes.position;
376
+ for (let i=0;i<p.count;i++) {
377
+ let y=p.getY(i)+.002; if(y>2) y=-10;
378
+ p.setY(i,y); p.setX(i,p.getX(i)+Math.sin(t+i)*.001);
379
+ }
380
+ p.needsUpdate=true; particles.rotation.y=t*.005;
381
+ }
382
+
383
+ if (bubbles) {
384
+ const p=bubbles.geometry.attributes.position;
385
+ for (let i=0;i<p.count;i++) {
386
+ let y=p.getY(i)+.014+Math.random()*.01; if(y>2) y=-10; p.setY(i,y);
387
+ }
388
+ p.needsUpdate=true;
389
+ }
390
+
391
+ creatures.forEach(c => {
392
+ c.userData.a+=c.userData.spd;
393
+ c.position.x=Math.cos(c.userData.a)*c.userData.r;
394
+ c.position.z=Math.sin(c.userData.a)*c.userData.r;
395
+ c.position.y=c.userData.sy+Math.sin(t*.5+c.userData.a)*.5;
396
+ c.rotation.x=t*.5; c.rotation.y=c.userData.a;
397
+ });
398
+
399
+ camera.position.x=Math.sin(t*.05)*18;
400
+ camera.position.z=Math.cos(t*.05)*18;
401
+ camera.position.y=6+Math.sin(t*.03)*2;
402
+ camera.lookAt(0,-2,0);
403
+
404
+ renderer.render(scene,camera);
405
+ }
406
+
407
+ function setZone(idx) {
408
+ const z=ZONES[idx];
409
+ document.getElementById('depth-val').textContent=z.depth.toLocaleString()+' m';
410
+ document.getElementById('pressure-val').textContent=z.pressure.toLocaleString()+' atm';
411
+ document.getElementById('temp-val').textContent=z.temp+'Β°C';
412
+ document.getElementById('species-val').textContent=z.sp;
413
+ document.getElementById('bio-val').textContent=z.bio+'%';
414
+ document.getElementById('zone-display').textContent=z.name;
415
+ document.getElementById('depth-fill').style.height=((idx+1)*18)+'%';
416
+
417
+ scene.fog.color.setHex(z.fog); scene.fog.density=z.fogD;
418
+ ocean.material.color.setHex(z.color); ocean.material.opacity=Math.max(.3,.85-idx*.12);
419
+ renderer.setClearColor(z.fog,1);
420
+
421
+ const s=document.getElementById('status-bar');
422
+ s.textContent=`DIVING TO ${z.name} β€” ${z.depth.toLocaleString()}m`;
423
+ s.classList.add('show'); setTimeout(()=>s.classList.remove('show'),2500);
424
+
425
+ if (!titleFaded) { document.getElementById('title-hud').style.opacity='0'; titleFaded=true; }
426
+ document.querySelectorAll('.zbtn').forEach((b,i)=>b.classList.toggle('active',i===idx));
427
+ }
428
+
429
+ function onResize() {
430
+ const c=document.getElementById('canvas-container');
431
+ camera.aspect=c.clientWidth/c.clientHeight; camera.updateProjectionMatrix();
432
+ renderer.setSize(c.clientWidth,c.clientHeight);
433
+ }
434
+
435
+ window.addEventListener('load',init);
436
+ setInterval(()=>{ const e=document.getElementById('sonar-val'); if(e) e.textContent=new Date().toUTCString().slice(17,25)+' UTC'; },1000);
437
+ </script>
438
+ </body>
439
+ </html>
440
+ """
441
+
442
+ # ══════════════════════════════════════════════════════════════
443
+ # GRADIO UI
444
+ # ══════════════════════════════════════════════════════════════
445
+
446
+ CSS = """
447
+ @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Share+Tech+Mono&display=swap');
448
+
449
+ body, .gradio-container { background:#000408!important; color:#00ffcc!important; font-family:'Share Tech Mono',monospace!important; }
450
+
451
+ .oceanus-header { background:linear-gradient(135deg,#000408,#001a2e); border-bottom:1px solid #00ffcc33; padding:14px 24px; text-align:center; }
452
+ .oceanus-title { font-family:'Orbitron',sans-serif; font-size:26px; font-weight:900; color:#00ffcc; text-shadow:0 0 30px #00ffcc; letter-spacing:7px; margin:0; }
453
+ .oceanus-sub { font-size:10px; color:rgba(0,255,204,.5); letter-spacing:4px; margin-top:4px; }
454
+
455
+ .gr-panel { background:#000408!important; border:1px solid #00ffcc22!important; border-radius:0!important; }
456
+
457
+ textarea, input {
458
+ background:#000d1a!important; border:1px solid #00ffcc44!important;
459
+ color:#00ffcc!important; font-family:'Share Tech Mono',monospace!important;
460
+ border-radius:0!important;
461
+ }
462
+
463
+ label, .label-wrap { color:#00ffcc88!important; font-family:'Share Tech Mono',monospace!important; font-size:10px!important; letter-spacing:2px!important; text-transform:uppercase!important; }
464
+
465
+ .gr-button { border-radius:0!important; font-family:'Share Tech Mono',monospace!important; letter-spacing:2px!important; }
466
+ .gr-button-primary { background:linear-gradient(135deg,#00ffcc22,#00ffcc44)!important; border:1px solid #00ffcc!important; color:#00ffcc!important; }
467
+ .gr-button-primary:hover { background:rgba(0,255,204,.3)!important; box-shadow:0 0 14px #00ffcc88!important; }
468
+ .gr-button-secondary { background:#000d1a!important; border:1px solid #00ffcc33!important; color:#00ffcc99!important; font-size:11px!important; }
469
+ .gr-button-secondary:hover { border-color:#00ffcc!important; color:#00ffcc!important; }
470
+
471
+ .message.user { background:rgba(0,255,204,.09)!important; border-left:2px solid #00ffcc!important; border-radius:0!important; color:#00ffcc!important; }
472
+ .message.bot { background:rgba(0,50,80,.4)!important; border-left:2px solid #00d4ff!important; border-radius:0!important; color:#c0f0ff!important; }
473
+
474
+ footer { display:none!important; }
475
+ """
476
+
477
+ ZONE_CHOICES = ["Sunlit Zone (0-200m)","Twilight Zone (200-1000m)","Midnight Zone (1000-4000m)","Abyssal Zone (4000-6000m)","Hadal Zone (6000-11000m)"]
478
+ OCEAN_CHOICES = ["Pacific Ocean β€” Largest & Deepest","Atlantic Ocean β€” Mid-Atlantic Ridge","Indian Ocean β€” Warm Currents","Arctic Ocean β€” Permanent Ice Cap","Southern Ocean β€” Circumpolar Current"]
479
+
480
+ QUICK_Q = [
481
+ "πŸ¦‘ What lives in the Twilight Zone?",
482
+ "πŸ’‘ How does bioluminescence work?",
483
+ "πŸŒ‹ What lives near hydrothermal vents?",
484
+ "πŸ”οΈ Describe the Mariana Trench",
485
+ "πŸ‹ How do whales dive so deep?",
486
+ "πŸ”¬ Most bizarre Midnight Zone creature?",
487
+ ]
488
+
489
+ with gr.Blocks(css=CSS, title="OCEANUS β€” AR Ocean Explorer") as demo:
490
+
491
+ gr.HTML('<div class="oceanus-header"><p class="oceanus-title">βš“ OCEANUS</p><p class="oceanus-sub">GOD\'S EYE β€” AR DEEP OCEAN EXPLORER Β· FREE Β· POWERED BY MISTRAL AI</p></div>')
492
+
493
+ gr.HTML(THREE_JS_HTML)
494
+
495
+ gr.HTML("<div style='height:14px'></div>")
496
+
497
+ with gr.Row():
498
+ with gr.Column(scale=3):
499
+ gr.HTML("<p style='font-family:Orbitron,sans-serif;color:#00ffcc;font-size:13px;letter-spacing:3px;margin-bottom:8px;'>🧠 OCEANUS AI ORACLE</p>")
500
+ chatbot = gr.Chatbot(
501
+ label="", height=400, show_label=False, bubble_full_width=False,
502
+ value=[(None, "🌊 **OCEANUS ONLINE** β€” AI Oracle of the Deep, powered by Mistral-7B (free). Select a zone in the 3D viewer above, then ask me anything about the ocean.\n\n🀿 Where shall we dive first?")]
503
+ )
504
+ with gr.Row():
505
+ msg = gr.Textbox(placeholder="Ask OCEANUS... e.g. 'What lives at 10,000 meters?'", show_label=False, scale=5, lines=1)
506
+ btn = gr.Button("β–Ά TRANSMIT", scale=1, variant="primary")
507
+
508
+ with gr.Column(scale=1):
509
+ gr.HTML("<p style='font-family:Orbitron,sans-serif;color:#00ffcc;font-size:11px;letter-spacing:3px;margin-bottom:8px;'>πŸ“‘ DIVE CONTROLS</p>")
510
+ zone_dd = gr.Dropdown(ZONE_CHOICES, value=ZONE_CHOICES[0], label="ACTIVE ZONE")
511
+ ocean_dd = gr.Dropdown(OCEAN_CHOICES, value=OCEAN_CHOICES[0], label="OCEAN REGION")
512
+ zone_md = gr.Markdown(get_zone_info(ZONE_CHOICES[0]))
513
+
514
+ gr.HTML("<p style='font-family:Orbitron,sans-serif;color:#00ffcc88;font-size:10px;letter-spacing:2px;margin:12px 0 8px;'>QUICK TRANSMISSIONS</p>")
515
+ for q in QUICK_Q:
516
+ gr.Button(q, size="sm", variant="secondary").click(
517
+ fn=lambda h, z, o, _q=q: chat_with_oceanus(_q, h, z, o),
518
+ inputs=[chatbot, zone_dd, ocean_dd],
519
+ outputs=[msg, chatbot],
520
+ )
521
+
522
+ zone_dd.change(fn=get_zone_info, inputs=zone_dd, outputs=zone_md)
523
+ btn.click(fn=chat_with_oceanus, inputs=[msg, chatbot, zone_dd, ocean_dd], outputs=[msg, chatbot])
524
+ msg.submit(fn=chat_with_oceanus, inputs=[msg, chatbot, zone_dd, ocean_dd], outputs=[msg, chatbot])
525
+
526
+ if __name__ == "__main__":
527
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio>=4.44.0
2
+ huggingface_hub>=0.24.0