Spaces:
Runtime error
Runtime error
Update modules/CodriaoCore.py
Browse files- modules/CodriaoCore.py +18 -6
modules/CodriaoCore.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import aiohttp
|
2 |
import json
|
3 |
import logging
|
@@ -18,18 +19,19 @@ from deep_translator import GoogleTranslator
|
|
18 |
from components.adaptive_learning import AdaptiveLearningEnvironment
|
19 |
from components.real_time_data import RealTimeDataIntegrator
|
20 |
from components.sentiment_analysis import EnhancedSentimentAnalyzer
|
21 |
-
from components.self_improving_ai import SelfImprovingAI
|
22 |
-
from components.
|
23 |
|
24 |
# Codriao's enhanced modules
|
25 |
from codriao_tb_module import CodriaoHealthModule
|
26 |
-
from
|
27 |
from ethical_filter import EthicalFilter
|
28 |
from results_store import save_result
|
29 |
|
30 |
# Utilities
|
31 |
from utils.database import Database
|
32 |
from utils.logger import logger
|
|
|
33 |
|
34 |
class CodriaoCore:
|
35 |
def __init__(self, config_path: str = "config.json"):
|
@@ -43,6 +45,10 @@ class CodriaoCore:
|
|
43 |
self.http_session = aiohttp.ClientSession()
|
44 |
self.database = Database()
|
45 |
|
|
|
|
|
|
|
|
|
46 |
# Cognitive & ethical subsystems
|
47 |
self.sentiment_analyzer = EnhancedSentimentAnalyzer()
|
48 |
self.self_improving_ai = SelfImprovingAI()
|
@@ -113,14 +119,17 @@ class CodriaoCore:
|
|
113 |
|
114 |
# Auto-escalation for HIGH risk
|
115 |
if result["tb_risk"] == "HIGH":
|
116 |
-
result["next_steps"] = "â
|
117 |
elif result["tb_risk"] == "MEDIUM":
|
118 |
result["next_steps"] = "ð Consider additional testing for confirmation."
|
119 |
|
120 |
# Multi-language support
|
121 |
if language != "en":
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
124 |
|
125 |
return result
|
126 |
|
@@ -152,3 +161,6 @@ class CodriaoCore:
|
|
152 |
return decode(token, self.jwt_secret, algorithms=["HS256"])
|
153 |
except ExpiredSignatureError:
|
154 |
return None
|
|
|
|
|
|
|
|
1 |
+
|
2 |
import aiohttp
|
3 |
import json
|
4 |
import logging
|
|
|
19 |
from components.adaptive_learning import AdaptiveLearningEnvironment
|
20 |
from components.real_time_data import RealTimeDataIntegrator
|
21 |
from components.sentiment_analysis import EnhancedSentimentAnalyzer
|
22 |
+
from components.self_improving_ai import SelfImprovingAI
|
23 |
+
from components.multi_model_analyzer import MultiAgentSystem
|
24 |
|
25 |
# Codriao's enhanced modules
|
26 |
from codriao_tb_module import CodriaoHealthModule
|
27 |
+
from secure_memory_loader import load_secure_memory_module
|
28 |
from ethical_filter import EthicalFilter
|
29 |
from results_store import save_result
|
30 |
|
31 |
# Utilities
|
32 |
from utils.database import Database
|
33 |
from utils.logger import logger
|
34 |
+
from utils.secure_memory_loader import load_secure_memory_module
|
35 |
|
36 |
class CodriaoCore:
|
37 |
def __init__(self, config_path: str = "config.json"):
|
|
|
45 |
self.http_session = aiohttp.ClientSession()
|
46 |
self.database = Database()
|
47 |
|
48 |
+
# 🧠 Replace static SecureMemory with dynamic, temp version
|
49 |
+
SecureMemorySession = load_secure_memory_module()
|
50 |
+
self.secure_memory = SecureMemorySession(self._encryption_key)
|
51 |
+
|
52 |
# Cognitive & ethical subsystems
|
53 |
self.sentiment_analyzer = EnhancedSentimentAnalyzer()
|
54 |
self.self_improving_ai = SelfImprovingAI()
|
|
|
119 |
|
120 |
# Auto-escalation for HIGH risk
|
121 |
if result["tb_risk"] == "HIGH":
|
122 |
+
result["next_steps"] = "â ï¸ Immediate follow-up required. Please visit a healthcare provider."
|
123 |
elif result["tb_risk"] == "MEDIUM":
|
124 |
result["next_steps"] = "ð Consider additional testing for confirmation."
|
125 |
|
126 |
# Multi-language support
|
127 |
if language != "en":
|
128 |
+
try:
|
129 |
+
translated_result = GoogleTranslator(source="auto", target=language).translate(json.dumps(result))
|
130 |
+
return json.loads(translated_result)
|
131 |
+
except Exception as e:
|
132 |
+
result["translation_error"] = str(e)
|
133 |
|
134 |
return result
|
135 |
|
|
|
161 |
return decode(token, self.jwt_secret, algorithms=["HS256"])
|
162 |
except ExpiredSignatureError:
|
163 |
return None
|
164 |
+
|
165 |
+
async def shutdown(self):
|
166 |
+
await self.http_session.close()
|