Gaston895 commited on
Commit
c46c96e
·
verified ·
1 Parent(s): 84d8efb

Deploy: Working AEGIS BIO LAB 10 CONDUCTOR 20260111_185821

Browse files
Files changed (1) hide show
  1. app.py +51 -247
app.py CHANGED
@@ -1,16 +1,13 @@
1
  from flask import Flask, render_template, request, jsonify
2
  import torch
3
- from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
4
  import re
5
  import gc
6
  import json
7
  import threading
8
  import time
9
  from datetime import datetime
10
- from typing import Dict, List, Optional
11
- from pydantic import BaseModel
12
  import logging
13
- import os
14
 
15
  # Configure logging
16
  logging.basicConfig(level=logging.INFO)
@@ -27,91 +24,47 @@ loading_status = "Initializing AEGIS BIO LAB 10 CONDUCTOR Multi-Domain Expert Sy
27
  # AEGIS BIO LAB 10 CONDUCTOR Configuration
28
  MODEL_REPO = "Gaston895/aegisconduct"
29
  AEGIS_VERSION = "10.0"
30
- GLOBAL_REGIONS = [
31
- "North America", "Europe", "Asia", "Africa",
32
- "South America", "Middle East", "Oceania", "Arctic Region"
33
- ]
34
-
35
- def clear_memory():
36
- """Clear memory aggressively"""
37
- gc.collect()
38
- if torch.cuda.is_available():
39
- torch.cuda.empty_cache()
40
 
41
  def load_model():
42
- """Load the AEGIS Conduct model with 8-bit quantization for CPU"""
43
  global model, tokenizer, model_loaded, loading_status
44
 
45
  try:
46
- # Initial memory cleanup
47
- clear_memory()
48
-
49
  loading_status = "Loading AEGIS BIO LAB 10 CONDUCTOR tokenizer..."
50
- print("🔄 Loading AEGIS BIO LAB 10 CONDUCTOR tokenizer...")
51
 
52
- # 1. Load tokenizer first (fast)
53
  tokenizer = AutoTokenizer.from_pretrained(
54
  MODEL_REPO,
55
- trust_remote_code=True,
56
- use_fast=True
57
  )
58
 
59
- # Set padding token if not set
60
  if tokenizer.pad_token is None:
61
  tokenizer.pad_token = tokenizer.eos_token
62
 
63
- loading_status = "Configuring 8-bit quantization for CPU optimization..."
64
- print("⚙️ Configuring 8-bit quantization (reduces 16GB model to ~8GB)...")
65
-
66
- # 2. Configure 8-bit quantization for CPU
67
- quantization_config = BitsAndBytesConfig(
68
- load_in_8bit=True, # Essential for 16GB model
69
- llm_int8_threshold=6.0,
70
- llm_int8_has_fp16_weight=False, # Important for CPU
71
- bnb_8bit_compute_dtype=torch.float32, # Use float32 for CPU
72
- bnb_8bit_use_double_quant=False, # Disable for CPU compatibility
73
- )
74
 
75
- loading_status = "Loading 16GB model with 8-bit quantization (2-3 minutes)..."
76
- print("📥 Loading 16GB model with 8-bit quantization...")
77
-
78
- # 3. Load model with 8-bit quantization
79
  model = AutoModelForCausalLM.from_pretrained(
80
  MODEL_REPO,
81
- quantization_config=quantization_config,
82
- device_map="cpu", # Let it handle device mapping
83
  trust_remote_code=True,
84
- low_cpu_mem_usage=True, # Critical for large models
85
- torch_dtype=torch.float32, # CPU compatible
86
- max_memory={"cpu": "12GB"}, # Limit CPU memory usage
87
  )
88
 
89
- # 4. Set model to evaluation mode
90
- model.eval()
91
-
92
- # 5. Final memory cleanup
93
- clear_memory()
94
-
95
- # Check actual memory usage
96
- if hasattr(model, 'get_memory_footprint'):
97
- try:
98
- memory_footprint = model.get_memory_footprint()
99
- print(f"✅ Model memory footprint: {memory_footprint / 1024**3:.2f} GB")
100
- except:
101
- print("✅ Model loaded with 8-bit quantization")
102
-
103
- print(f"✅ AEGIS BIO LAB 10 CONDUCTOR loaded successfully!")
104
- print(f"⚡ 8-bit quantization: 16GB → ~8GB memory usage")
105
- print(f"🚀 Ready for fast CPU inference")
106
 
107
  loading_status = "AEGIS BIO LAB 10 CONDUCTOR Multi-Domain Expert loaded successfully!"
 
108
  model_loaded = True
109
  return True
110
 
111
  except Exception as e:
112
  loading_status = f"Error loading AEGIS BIO LAB 10 CONDUCTOR model: {str(e)}"
113
- print(f"Error loading model: {e}")
114
- print(f"💡 Tip: Ensure bitsandbytes>=0.41.0 is installed")
115
  model_loaded = False
116
  return False
117
 
@@ -126,64 +79,37 @@ def format_response(text):
126
 
127
  return text
128
 
129
- def analyze_with_aegis_conductor(prompt: str, analysis_type: str = "general") -> str:
130
- """Analyze using AEGIS BIO LAB 10 CONDUCTOR - Multi-Domain Expert System"""
131
  global model, tokenizer, model_loaded
132
 
133
  if not model_loaded or model is None or tokenizer is None:
134
  return "AEGIS BIO LAB 10 CONDUCTOR is still loading... Please wait a moment and try again."
135
 
136
- # Enhanced prompts for AEGIS BIO LAB 10 CONDUCTOR multi-domain analysis
137
- system_prompts = {
138
- "general": f"You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR - an advanced multi-domain analysis system. You can provide expert analysis on ANY topic including economics, technology, science, politics, health, environment, security, and more. Provide comprehensive, well-reasoned responses with global perspective across all 8 regions: {', '.join(GLOBAL_REGIONS)}.",
139
- "economic": f"You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR Economics Expert. Provide comprehensive economic analysis covering market dynamics, financial implications, GDP impacts, inflation effects, trade relationships, and policy recommendations across all 8 global regions: {', '.join(GLOBAL_REGIONS)}.",
140
- "technology": f"You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR Technology Expert. Analyze technological developments, AI impacts, cybersecurity, innovation trends, and digital transformation across global regions.",
141
- "security": f"You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR Security Expert. Focus on threat analysis, risk assessment, geopolitical stability, and security implications across {len(GLOBAL_REGIONS)} global regions.",
142
- "health": f"You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR Health & Bio Expert. Analyze health systems, pandemic preparedness, biotechnology, medical innovations, and public health policies globally.",
143
- "environment": f"You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR Environmental Expert. Focus on climate change, sustainability, environmental policy, and ecological impacts across all global regions.",
144
- "strategic": f"You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR Strategic Planning Expert. Provide long-term strategic analysis, policy frameworks, and comprehensive planning across multiple domains and regions.",
145
- "threat": f"You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR Threat Analysis Expert. Assess multi-domain threats including economic, technological, environmental, security, and health risks across {len(GLOBAL_REGIONS)} global regions.",
146
- "aegis_conductor": f"You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR - the ultimate multi-domain analysis system. Provide comprehensive cross-domain analysis covering all aspects: economic, technological, security, health, environmental, and strategic implications across all 8 global regions: {', '.join(GLOBAL_REGIONS)}."
147
- }
148
-
149
- system_prompt = system_prompts.get(analysis_type, system_prompts["general"])
150
-
151
- # Use Llama chat format (AEGIS model is based on Llama)
152
- enhanced_prompt = f"""<s>[INST] <<SYS>>
153
- {system_prompt}
154
-
155
- AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR MULTI-DOMAIN CAPABILITIES:
156
- - Cross-Continental Analysis ({len(GLOBAL_REGIONS)} regions)
157
- - Multi-Domain Expertise (Economics, Technology, Security, Health, Environment, Strategy)
158
- - Threat Assessment & Risk Analysis
159
- - Policy Recommendations & Strategic Planning
160
- - Real-time Analysis & Insights
161
- - Global Perspective & Regional Adaptation
162
- <</SYS>>
163
-
164
- {prompt}
165
-
166
- As the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR, provide a comprehensive analysis that includes:
167
-
168
- 1. **Core Analysis** - Direct response to the query with expert insights
169
- 2. **Multi-Domain Perspective** - Consider interconnections across different fields
170
- 3. **Global Context** - Assess implications across relevant regions
171
- 4. **Strategic Insights** - Long-term implications and recommendations
172
- 5. **Risk Assessment** - Identify potential challenges and opportunities
173
- 6. **Actionable Guidance** - Practical recommendations and next steps
174
-
175
- Provide thorough, well-reasoned analysis that demonstrates deep expertise while remaining accessible and actionable. [/INST]"""
176
-
177
  try:
178
- # Tokenize input with optimized length for 8-bit model
179
- inputs = tokenizer(enhanced_prompt, return_tensors="pt", truncation=True, max_length=2048)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
 
181
- # Generate response with 8-bit quantized model (faster inference)
182
  with torch.no_grad():
183
  outputs = model.generate(
184
  **inputs,
185
- max_new_tokens=512, # Good balance for 8-bit model
186
- temperature=0.7,
187
  do_sample=True,
188
  top_p=0.9,
189
  top_k=50,
@@ -191,121 +117,25 @@ Provide thorough, well-reasoned analysis that demonstrates deep expertise while
191
  pad_token_id=tokenizer.eos_token_id,
192
  eos_token_id=tokenizer.eos_token_id,
193
  use_cache=True,
194
- num_beams=1 # Faster for CPU
195
  )
196
 
197
  # Decode response
198
  response = tokenizer.decode(outputs[0], skip_special_tokens=True)
199
 
200
  # Extract only the new response
201
- response = response[len(enhanced_prompt):].strip()
202
 
203
  # Format and clean response
204
  response = format_response(response)
205
 
206
  # Clean up memory after generation
207
- clear_memory()
208
 
209
- return response if response else "I apologize, but I couldn't generate a proper AEGIS BIO LAB 10 CONDUCTOR analysis. Please try rephrasing your question."
210
 
211
  except Exception as e:
212
- return f"AEGIS BIO LAB 10 CONDUCTOR analysis error: {str(e)}. Please try a shorter question."
213
-
214
- def conduct_aegis_threat_analysis(tech_scores: Dict[str, float], year: str = None) -> Dict:
215
- """Conduct comprehensive AEGIS BIO LAB 10 CONDUCTOR threat analysis"""
216
- if year is None:
217
- year = str(datetime.now().year)
218
-
219
- # Filter critical economic threats (scores > 6.0 in our 0-10 scale)
220
- critical_threats = {k: v for k, v in tech_scores.items() if v > 6.0}
221
-
222
- # Enhanced AEGIS BIO LAB 10 CONDUCTOR threat analysis prompt
223
- analysis_prompt = f"""AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR - COMPREHENSIVE THREAT ANALYSIS - Year {year}
224
-
225
- TECHNOLOGY THREAT ASSESSMENT:
226
- Critical Threats: {len(critical_threats)} detected from {len(tech_scores)} total threat categories
227
- High-Impact Threat Categories: {list(critical_threats.keys())}
228
- Technology Threat Scores: {dict(list(tech_scores.items()))}
229
-
230
- REQUIRED CALCULATIONS AND ANALYSIS:
231
-
232
- CALCULATE METRICS:
233
- 1. Market Shock Index (0-1 scale): Calculate based on threat interaction effects
234
- 2. Impact Classification: Determine impact level (Limited/Moderate/Major/Crisis)
235
- 3. Threat Level: Assess overall threat (Low/Medium/High/Extreme Risk)
236
-
237
- REGIONAL VULNERABILITIES (0-10 scale for each region):
238
- 4. North America: Technology and financial sector resilience
239
- 5. Europe: Manufacturing and energy security
240
- 6. Asia: Trade diversification and supply chain adaptation
241
- 7. Africa: Agricultural and resource sector protection
242
- 8. South America: Climate adaptation and economic diversification
243
- 9. Middle East: Energy transition and modernization
244
- 10. Oceania: Resource security and climate resilience
245
- 11. Arctic Region: Sustainable development
246
-
247
- CONTAGION METRICS (0-1 scale):
248
- 12. Cascade Probability: Risk of cascading failures
249
- 13. Propagation Speed: Rate of impact spread
250
- 14. Containment Difficulty: Challenge of limiting damage
251
- 15. Systemic Risk: Overall system stability threat
252
-
253
- Provide comprehensive analysis with specific numerical values for all calculated metrics."""
254
-
255
- # Get comprehensive analysis from the AEGIS model
256
- full_analysis = analyze_with_aegis_conductor(analysis_prompt, "aegis_conductor")
257
-
258
- # Parse metrics from the response
259
- result = {
260
- "reasoning_analysis": full_analysis,
261
- "market_shock_index": 0.0,
262
- "impact_classification": "Analysis in Progress",
263
- "threat_level": "Assessment Pending",
264
- "regional_vulnerabilities": {},
265
- "contagion_metrics": {},
266
- "tech_scores": tech_scores,
267
- "year": year,
268
- "analysis_timestamp": datetime.now().isoformat()
269
- }
270
-
271
- # Extract metrics from model response
272
- lines = full_analysis.split('\n')
273
- for line in lines:
274
- line = line.strip()
275
- if 'Market Shock Index:' in line or 'market shock index' in line.lower():
276
- try:
277
- import re
278
- numbers = re.findall(r'(\d+\.?\d*)', line)
279
- if numbers:
280
- value = float(numbers[0])
281
- if value <= 1.0:
282
- result["market_shock_index"] = value
283
- except:
284
- pass
285
- elif 'Impact Classification:' in line or 'impact classification' in line.lower():
286
- parts = line.split(':')
287
- if len(parts) > 1:
288
- result["impact_classification"] = parts[1].strip()
289
- elif 'Threat Level:' in line or 'threat level' in line.lower():
290
- parts = line.split(':')
291
- if len(parts) > 1:
292
- result["threat_level"] = parts[1].strip()
293
-
294
- # Extract regional vulnerabilities
295
- for region in GLOBAL_REGIONS:
296
- for line in lines:
297
- if region.lower() in line.lower() and ':' in line:
298
- try:
299
- import re
300
- numbers = re.findall(r'(\d+\.?\d*)', line)
301
- if numbers:
302
- score = float(numbers[0])
303
- if score <= 10.0:
304
- result["regional_vulnerabilities"][region] = score
305
- except:
306
- pass
307
-
308
- return result
309
 
310
  @app.route('/')
311
  def index():
@@ -314,66 +144,40 @@ def index():
314
 
315
  @app.route('/status')
316
  def status():
317
- """Get AEGIS model loading status"""
318
  return jsonify({
319
  'loaded': model_loaded,
320
  'status': loading_status,
321
  'model': MODEL_REPO,
322
- 'version': AEGIS_VERSION,
323
- 'regions': len(GLOBAL_REGIONS),
324
- 'quantization': '8-bit' if model_loaded else 'Loading'
325
  })
326
 
327
  @app.route('/chat', methods=['POST'])
328
  def chat():
329
- """Handle AEGIS multi-domain chat messages"""
330
  data = request.json
331
  message = data.get('message', '').strip()
332
  history = data.get('history', [])
333
  temperature = float(data.get('temperature', 0.7))
334
- max_tokens = int(data.get('max_tokens', 256))
335
- analysis_type = data.get('analysis_type', 'general')
336
 
337
  if not message:
338
  return jsonify({'error': 'No message provided'}), 400
339
 
340
- # Generate response using AEGIS Multi-Domain System
341
- response = analyze_with_aegis_conductor(message, analysis_type)
342
 
343
  return jsonify({
344
  'response': response,
345
  'timestamp': time.time(),
346
- 'model': f"AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR (8-bit)",
347
- 'analysis_type': analysis_type
348
  })
349
 
350
- @app.route('/aegis_analysis', methods=['POST'])
351
- def aegis_analysis():
352
- """Handle comprehensive AEGIS BIO LAB 10 CONDUCTOR threat analysis"""
353
- data = request.json
354
-
355
- # Get technology threat scores
356
- tech_scores = {
357
- 'AI': float(data.get('ai_score', 7.0)),
358
- 'Cyber': float(data.get('cyber_score', 6.5)),
359
- 'Bio': float(data.get('bio_score', 8.0)),
360
- 'Nuclear': float(data.get('nuclear_score', 4.0)),
361
- 'Climate': float(data.get('climate_score', 7.5)),
362
- 'Space': float(data.get('space_score', 5.0))
363
- }
364
-
365
- year = data.get('year', str(datetime.now().year))
366
-
367
- # Conduct comprehensive AEGIS analysis
368
- analysis_result = conduct_aegis_threat_analysis(tech_scores, year)
369
-
370
- return jsonify(analysis_result)
371
-
372
  @app.route('/clear', methods=['POST'])
373
  def clear_chat():
374
  """Clear chat history and free memory"""
375
- clear_memory()
376
- return jsonify({'status': 'AEGIS BIO LAB 10 CONDUCTOR memory cleared'})
377
 
378
  # Start model loading in background thread
379
  def start_model_loading():
@@ -385,4 +189,4 @@ if __name__ == '__main__':
385
  loading_thread.daemon = True
386
  loading_thread.start()
387
 
388
- app.run(host='0.0.0.0', port=7860, debug=False)
 
1
  from flask import Flask, render_template, request, jsonify
2
  import torch
3
+ from transformers import AutoTokenizer, AutoModelForCausalLM
4
  import re
5
  import gc
6
  import json
7
  import threading
8
  import time
9
  from datetime import datetime
 
 
10
  import logging
 
11
 
12
  # Configure logging
13
  logging.basicConfig(level=logging.INFO)
 
24
  # AEGIS BIO LAB 10 CONDUCTOR Configuration
25
  MODEL_REPO = "Gaston895/aegisconduct"
26
  AEGIS_VERSION = "10.0"
 
 
 
 
 
 
 
 
 
 
27
 
28
  def load_model():
29
+ """Load the AEGIS Conduct model optimized for CPU"""
30
  global model, tokenizer, model_loaded, loading_status
31
 
32
  try:
 
 
 
33
  loading_status = "Loading AEGIS BIO LAB 10 CONDUCTOR tokenizer..."
34
+ print("Loading AEGIS BIO LAB 10 CONDUCTOR Multi-Domain Expert for CPU...")
35
 
36
+ # Load tokenizer first
37
  tokenizer = AutoTokenizer.from_pretrained(
38
  MODEL_REPO,
39
+ trust_remote_code=True
 
40
  )
41
 
42
+ # Add pad token if missing
43
  if tokenizer.pad_token is None:
44
  tokenizer.pad_token = tokenizer.eos_token
45
 
46
+ loading_status = "Loading AEGIS BIO LAB 10 CONDUCTOR model (this may take a few minutes)..."
 
 
 
 
 
 
 
 
 
 
47
 
48
+ # Load model optimized for CPU
 
 
 
49
  model = AutoModelForCausalLM.from_pretrained(
50
  MODEL_REPO,
51
+ torch_dtype=torch.float16,
52
+ device_map="cpu",
53
  trust_remote_code=True,
54
+ low_cpu_mem_usage=True
 
 
55
  )
56
 
57
+ # Force garbage collection
58
+ gc.collect()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  loading_status = "AEGIS BIO LAB 10 CONDUCTOR Multi-Domain Expert loaded successfully!"
61
+ print("AEGIS BIO LAB 10 CONDUCTOR Multi-Domain Expert loaded successfully on CPU!")
62
  model_loaded = True
63
  return True
64
 
65
  except Exception as e:
66
  loading_status = f"Error loading AEGIS BIO LAB 10 CONDUCTOR model: {str(e)}"
67
+ print(f"Error loading model: {e}")
 
68
  model_loaded = False
69
  return False
70
 
 
79
 
80
  return text
81
 
82
+ def generate_response(message, history=None, temperature=0.7, max_tokens=128):
83
+ """Generate response from the model optimized for CPU"""
84
  global model, tokenizer, model_loaded
85
 
86
  if not model_loaded or model is None or tokenizer is None:
87
  return "AEGIS BIO LAB 10 CONDUCTOR is still loading... Please wait a moment and try again."
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  try:
90
+ # Build conversation context
91
+ conversation = ""
92
+ if history:
93
+ # Only use last 2 exchanges to save memory
94
+ recent_history = history[-2:] if len(history) > 2 else history
95
+ for exchange in recent_history:
96
+ conversation += f"User: {exchange['user']}\nAssistant: {exchange['assistant']}\n\n"
97
+
98
+ # Add current message with AEGIS prompt
99
+ aegis_prompt = f"""You are the AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR - an advanced multi-domain analysis system. You can provide expert analysis on ANY topic including economics, technology, science, politics, health, environment, security, and more. Provide comprehensive, well-reasoned responses.
100
+
101
+ User: {message}
102
+ Assistant:"""
103
+
104
+ # Tokenize input with strict length limit for CPU
105
+ inputs = tokenizer(aegis_prompt, return_tensors="pt", truncation=True, max_length=512)
106
 
107
+ # Generate response with CPU-optimized settings
108
  with torch.no_grad():
109
  outputs = model.generate(
110
  **inputs,
111
+ max_new_tokens=max_tokens,
112
+ temperature=temperature,
113
  do_sample=True,
114
  top_p=0.9,
115
  top_k=50,
 
117
  pad_token_id=tokenizer.eos_token_id,
118
  eos_token_id=tokenizer.eos_token_id,
119
  use_cache=True,
120
+ num_beams=1
121
  )
122
 
123
  # Decode response
124
  response = tokenizer.decode(outputs[0], skip_special_tokens=True)
125
 
126
  # Extract only the new response
127
+ response = response[len(aegis_prompt):].strip()
128
 
129
  # Format and clean response
130
  response = format_response(response)
131
 
132
  # Clean up memory after generation
133
+ gc.collect()
134
 
135
+ return response if response else "I apologize, but I couldn't generate a proper response. Please try rephrasing your question."
136
 
137
  except Exception as e:
138
+ return f"Error generating response: {str(e)}. Please try a shorter question."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
  @app.route('/')
141
  def index():
 
144
 
145
  @app.route('/status')
146
  def status():
147
+ """Get model loading status"""
148
  return jsonify({
149
  'loaded': model_loaded,
150
  'status': loading_status,
151
  'model': MODEL_REPO,
152
+ 'version': AEGIS_VERSION
 
 
153
  })
154
 
155
  @app.route('/chat', methods=['POST'])
156
  def chat():
157
+ """Handle chat messages"""
158
  data = request.json
159
  message = data.get('message', '').strip()
160
  history = data.get('history', [])
161
  temperature = float(data.get('temperature', 0.7))
162
+ max_tokens = int(data.get('max_tokens', 128))
 
163
 
164
  if not message:
165
  return jsonify({'error': 'No message provided'}), 400
166
 
167
+ # Generate response
168
+ response = generate_response(message, history, temperature, max_tokens)
169
 
170
  return jsonify({
171
  'response': response,
172
  'timestamp': time.time(),
173
+ 'model': f"AEGIS BIO LAB {AEGIS_VERSION} CONDUCTOR"
 
174
  })
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  @app.route('/clear', methods=['POST'])
177
  def clear_chat():
178
  """Clear chat history and free memory"""
179
+ gc.collect()
180
+ return jsonify({'status': 'cleared'})
181
 
182
  # Start model loading in background thread
183
  def start_model_loading():
 
189
  loading_thread.daemon = True
190
  loading_thread.start()
191
 
192
+ app.run(host='0.0.0.0', port=7860, debug=False)