ajoute et implementation de la communication etre Satellite
Browse files- main.py +5 -3
- satellites/atlasSat/atlas.py +8 -2
- satellites/base_satellite.py +4 -5
- satellites/edisonSat/edison.py +23 -0
- satellites/lilithSat/lilith.py +9 -3
- satellites/pythagorasSat/pythagoras.py +14 -6
- satellites/shakaSat/shaka.py +26 -16
- satellites/yorkSat/york.py +25 -0
- stellar/base_stellar.py +5 -5
main.py
CHANGED
@@ -24,9 +24,11 @@ stellar.register_satellites(shaka)
|
|
24 |
stellar.register_satellites(edison)
|
25 |
stellar.register_satellites(york)
|
26 |
|
27 |
-
response = Stellar.route_communication("Atlas", "York", {"type": "check_resources"})
|
28 |
-
|
29 |
-
results = Stellar.broadcast_message("Atlas", {"type": "check_resources"})
|
30 |
|
|
|
|
|
|
|
31 |
|
|
|
|
|
32 |
print(results)
|
|
|
24 |
stellar.register_satellites(edison)
|
25 |
stellar.register_satellites(york)
|
26 |
|
|
|
|
|
|
|
27 |
|
28 |
+
# Exemple de communication
|
29 |
+
response = stellar.route_communication("Shaka", "Atlas", {"type": "monitor_directory", "content": "Suspicious activity detected"})
|
30 |
+
print(response)
|
31 |
|
32 |
+
# Exemple de diffusion
|
33 |
+
results = stellar.broadcast_message("Shaka", {"type": "ethics_update", "content": "New ethical guidelines"})
|
34 |
print(results)
|
satellites/atlasSat/atlas.py
CHANGED
@@ -127,7 +127,7 @@ class Atlas(VegapunkSatellite):
|
|
127 |
|
128 |
|
129 |
|
130 |
-
def
|
131 |
|
132 |
if message.get("type") == "task":
|
133 |
task_result = self.process_task(message.get("task"))
|
@@ -152,4 +152,10 @@ class Atlas(VegapunkSatellite):
|
|
152 |
return {"status": "Rapport de status généré", "result": result}
|
153 |
elif message.get("type") == "check_changes":
|
154 |
changes = self.check_directory_changes()
|
155 |
-
return {"status": "Changements vérifiés", "result": changes}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
|
129 |
|
130 |
+
def process_communication(self,sender_name:str,message:Dict[str,Any]) ->Dict[str,Any]:
|
131 |
|
132 |
if message.get("type") == "task":
|
133 |
task_result = self.process_task(message.get("task"))
|
|
|
152 |
return {"status": "Rapport de status généré", "result": result}
|
153 |
elif message.get("type") == "check_changes":
|
154 |
changes = self.check_directory_changes()
|
155 |
+
return {"status": "Changements vérifiés", "result": changes}
|
156 |
+
else:
|
157 |
+
return {"status": "Erreur", "result": "Type de tâche inconnu"}
|
158 |
+
|
159 |
+
def receive_communication(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Any]:
|
160 |
+
logging.info(f"{self.name} received communication from {sender_name}")
|
161 |
+
return self.process_communication(sender_name, message)
|
satellites/base_satellite.py
CHANGED
@@ -74,13 +74,12 @@ class VegapunkSatellite(ABC):
|
|
74 |
logging.error(f"Erreur lors de la communication avec {satellite.name} : {str(e)}")
|
75 |
return None
|
76 |
|
77 |
-
def receive_communication(self, message: Dict[str, Any]) -> Dict[str, Any]:
|
78 |
-
|
79 |
-
|
80 |
-
return {"status": "Message reçu","from":{self.name}, "details": message}
|
81 |
|
82 |
@abstractmethod
|
83 |
-
def
|
84 |
"""
|
85 |
traite le message recu d'un autre satellite
|
86 |
a implementer dans chaque classe de satellite specifique
|
|
|
74 |
logging.error(f"Erreur lors de la communication avec {satellite.name} : {str(e)}")
|
75 |
return None
|
76 |
|
77 |
+
def receive_communication(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Any]:
|
78 |
+
logging.info(f"{self.name} a recu un message de : {sender_name}")
|
79 |
+
return self.process_communication(sender_name, message)
|
|
|
80 |
|
81 |
@abstractmethod
|
82 |
+
def process_communication(self,sender_name:str,message:Dict[str,Any])->Dict[str,Any]:
|
83 |
"""
|
84 |
traite le message recu d'un autre satellite
|
85 |
a implementer dans chaque classe de satellite specifique
|
satellites/edisonSat/edison.py
CHANGED
@@ -123,3 +123,26 @@ class Edison(VegapunkSatellite):
|
|
123 |
def update_from_punkrecord(self) -> None:
|
124 |
self.log_activity("Mise à jour depuis PunkRecord")
|
125 |
# Ici, vous pourriez implémenter la logique pour mettre à jour les API externes ou les paramètres du modèle LLM
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
def update_from_punkrecord(self) -> None:
|
124 |
self.log_activity("Mise à jour depuis PunkRecord")
|
125 |
# Ici, vous pourriez implémenter la logique pour mettre à jour les API externes ou les paramètres du modèle LLM
|
126 |
+
|
127 |
+
|
128 |
+
def process_communication(self,sender_name:str,message:Dict[str,Any])->Dict[str,Any]:
|
129 |
+
if message.get("type") == "task":
|
130 |
+
task_result = self.process_task(message.get("task"))
|
131 |
+
return {"status": "Traitement effectué", "result": task_result}
|
132 |
+
elif message.get("type") == "innovation":
|
133 |
+
innovation_result = self.generate_innovation(message.get("domain"))
|
134 |
+
return {"status": "Traitement effectué", "result": innovation_result}
|
135 |
+
elif message.get("type") == "logic_problem":
|
136 |
+
logic_result = self.solve_logic_problem(message.get("problem"))
|
137 |
+
return {"status": "Traitement effectué", "result": logic_result}
|
138 |
+
elif message.get("type") == "data_analysis":
|
139 |
+
analysis_result = self.analyze_data(message.get("data"))
|
140 |
+
return {"status": "Traitement effectué", "result": analysis_result}
|
141 |
+
else:
|
142 |
+
return {"status": "Erreur", "result": "Type de tâche inconnu"}
|
143 |
+
|
144 |
+
|
145 |
+
def receive_communication(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Any]:
|
146 |
+
logging.info(f"{self.name} received communication from {sender_name}")
|
147 |
+
return self.process_communication(sender_name, message)
|
148 |
+
|
satellites/lilithSat/lilith.py
CHANGED
@@ -14,10 +14,12 @@ class Lilith(VegapunkSatellite):
|
|
14 |
super().__init__(name="Lilith", specialty=role)
|
15 |
self.idea_categories = ["Technologie", "Art", "Science", "Société", "Environnement"]
|
16 |
self.innovation_levels = ["Incrémentale", "Radicale", "Disruptive"]
|
17 |
-
self.unconventional_approaches = ["Pensée inversée", "Analogies lointaines", "Combinaison aléatoire",
|
|
|
18 |
# logging.basicConfig(filename='lilith_log.txt', level=logging.INFO)
|
19 |
self.external_apis = {}
|
20 |
self.logger = get_logger("lilith")
|
|
|
21 |
def process_task(self, task: Dict[str, Any]) -> Dict[str, Any]:
|
22 |
task_type = task.get("type")
|
23 |
if task_type == "generate_idea":
|
@@ -114,8 +116,7 @@ class Lilith(VegapunkSatellite):
|
|
114 |
self.log_activity("Mise à jour depuis PunkRecord")
|
115 |
# Ici, vous pourriez implémenter la logique pour mettre à jour les approches créatives ou les domaines d'innovation
|
116 |
|
117 |
-
|
118 |
-
def proccess_communicatioon(self,sender_name:str,message:Dict[str,Any]) ->Dict[str,Any]:
|
119 |
if message.get("type") == "task":
|
120 |
task_result = self.process_task(message.get("task"))
|
121 |
return {"status": "Traitement effectué", "result": task_result}
|
@@ -134,4 +135,9 @@ class Lilith(VegapunkSatellite):
|
|
134 |
elif message.get("type") == "status_report":
|
135 |
result = self.report_status()
|
136 |
return {"status": "Rapport de status généré", "result": result}
|
|
|
|
|
137 |
|
|
|
|
|
|
|
|
14 |
super().__init__(name="Lilith", specialty=role)
|
15 |
self.idea_categories = ["Technologie", "Art", "Science", "Société", "Environnement"]
|
16 |
self.innovation_levels = ["Incrémentale", "Radicale", "Disruptive"]
|
17 |
+
self.unconventional_approaches = ["Pensée inversée", "Analogies lointaines", "Combinaison aléatoire",
|
18 |
+
"Contraintes extrêmes"]
|
19 |
# logging.basicConfig(filename='lilith_log.txt', level=logging.INFO)
|
20 |
self.external_apis = {}
|
21 |
self.logger = get_logger("lilith")
|
22 |
+
|
23 |
def process_task(self, task: Dict[str, Any]) -> Dict[str, Any]:
|
24 |
task_type = task.get("type")
|
25 |
if task_type == "generate_idea":
|
|
|
116 |
self.log_activity("Mise à jour depuis PunkRecord")
|
117 |
# Ici, vous pourriez implémenter la logique pour mettre à jour les approches créatives ou les domaines d'innovation
|
118 |
|
119 |
+
def process_communication(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Any]:
|
|
|
120 |
if message.get("type") == "task":
|
121 |
task_result = self.process_task(message.get("task"))
|
122 |
return {"status": "Traitement effectué", "result": task_result}
|
|
|
135 |
elif message.get("type") == "status_report":
|
136 |
result = self.report_status()
|
137 |
return {"status": "Rapport de status généré", "result": result}
|
138 |
+
else:
|
139 |
+
return {"status": "Erreur", "result": "Type de tâche inconnu"}
|
140 |
|
141 |
+
def receive_communication(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Any]:
|
142 |
+
logging.info(f"{self.name} received communication from {sender_name}")
|
143 |
+
return self.process_communication(sender_name, message)
|
satellites/pythagorasSat/pythagoras.py
CHANGED
@@ -20,11 +20,11 @@ load_dotenv()
|
|
20 |
|
21 |
|
22 |
# client = OpenAI(os.getenv("LLM_API_KEY"))
|
23 |
-
|
24 |
-
client =OpenAI(
|
25 |
-
|
26 |
-
)
|
27 |
-
|
28 |
|
29 |
role = "mathématiques, statistiques et analyse de données"
|
30 |
fonction = "Effectuer des calculs complexes et analyser des ensembles de données"
|
@@ -248,7 +248,7 @@ class Pythagoras(VegapunkSatellite):
|
|
248 |
return status
|
249 |
|
250 |
|
251 |
-
def
|
252 |
if message.get("type")== "task":
|
253 |
task_result = self.process_task(message.get("task"))
|
254 |
return {"status": "Traitement effectué", "result": task_result}
|
@@ -267,3 +267,11 @@ class Pythagoras(VegapunkSatellite):
|
|
267 |
elif message.get("type") == "update_external_apis":
|
268 |
self.external_apis.update(message.get("apis", {}))
|
269 |
return {"status": "APIs mises à jour", "result": self.external_apis}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
|
22 |
# client = OpenAI(os.getenv("LLM_API_KEY"))
|
23 |
+
#
|
24 |
+
# client =OpenAI(
|
25 |
+
# organization="LLM_API_KEY",
|
26 |
+
# )
|
27 |
+
#
|
28 |
|
29 |
role = "mathématiques, statistiques et analyse de données"
|
30 |
fonction = "Effectuer des calculs complexes et analyser des ensembles de données"
|
|
|
248 |
return status
|
249 |
|
250 |
|
251 |
+
def process_communication(self,sender_name:str,message:Dict[str,Any]) ->Dict[str,Any]:
|
252 |
if message.get("type")== "task":
|
253 |
task_result = self.process_task(message.get("task"))
|
254 |
return {"status": "Traitement effectué", "result": task_result}
|
|
|
267 |
elif message.get("type") == "update_external_apis":
|
268 |
self.external_apis.update(message.get("apis", {}))
|
269 |
return {"status": "APIs mises à jour", "result": self.external_apis}
|
270 |
+
|
271 |
+
else:
|
272 |
+
return {"status": "Erreur", "result": "Type de tâche inconnu"}
|
273 |
+
|
274 |
+
def receive_communication(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Any]:
|
275 |
+
logging.info(f"{self.name} received communication from {sender_name}")
|
276 |
+
return self.process_communication(sender_name, message)
|
277 |
+
|
satellites/shakaSat/shaka.py
CHANGED
@@ -183,23 +183,33 @@ class Shaka(VegapunkSatellite):
|
|
183 |
self.add_to_knowledge_base("Last_update", "Nouveaux patterns détectés dans les données")
|
184 |
return {"Statut": "Mise à jour effectuée"}
|
185 |
|
186 |
-
def
|
187 |
-
#
|
188 |
if message.get("type") == "ethics_check":
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
|
204 |
|
205 |
|
|
|
183 |
self.add_to_knowledge_base("Last_update", "Nouveaux patterns détectés dans les données")
|
184 |
return {"Statut": "Mise à jour effectuée"}
|
185 |
|
186 |
+
def process_communication(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Any]:
|
187 |
+
# Logique spécifique à Shaka pour traiter les communications
|
188 |
if message.get("type") == "ethics_check":
|
189 |
+
# Effectuer une vérification éthique
|
190 |
+
result = self.perform_ethics_check(message.get("content"))
|
191 |
+
return {"status": "completed", "result": result}
|
192 |
+
elif message.get("type") == "security_alert":
|
193 |
+
# Traiter une alerte de sécurité du point de vue éthique
|
194 |
+
analysis = self.analyze_security_alert(message.get("content"))
|
195 |
+
return {"status": "analyzed", "ethical_analysis": analysis}
|
196 |
+
else:
|
197 |
+
return {"status": "unknown_message_type"}
|
198 |
+
|
199 |
+
|
200 |
+
def receive_communication(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Any]:
|
201 |
+
logging.info(f"{self.name} received communication from {sender_name}")
|
202 |
+
return self.process_communication(sender_name, message)
|
203 |
+
|
204 |
+
def perform_ethics_check(self, content: str) -> str:
|
205 |
+
# Implémentez ici la logique de vérification éthique
|
206 |
+
# Ceci est un exemple simplifié
|
207 |
+
return f"Ethical analysis of: {content}"
|
208 |
+
|
209 |
+
def analyze_security_alert(self, alert_content: str) -> str:
|
210 |
+
# Implémentez ici la logique d'analyse éthique des alertes de sécurité
|
211 |
+
# Ceci est un exemple simplifié
|
212 |
+
return f"Ethical implications of security alert: {alert_content}"
|
213 |
|
214 |
|
215 |
|
satellites/yorkSat/york.py
CHANGED
@@ -111,3 +111,28 @@ class York(VegapunkSatellite):
|
|
111 |
def update_from_punkrecord(self) -> None:
|
112 |
self.log_activity("Mise à jour depuis PunkRecord")
|
113 |
# Ici, vous pourriez implémenter la logique pour mettre à jour les seuils de ressources ou les plannings de maintenance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
def update_from_punkrecord(self) -> None:
|
112 |
self.log_activity("Mise à jour depuis PunkRecord")
|
113 |
# Ici, vous pourriez implémenter la logique pour mettre à jour les seuils de ressources ou les plannings de maintenance
|
114 |
+
|
115 |
+
def process_communication(self,sender_name:str,message:Dict[str,Any]) ->Dict[str,Any]:
|
116 |
+
if message.get("type") == "task":
|
117 |
+
task_result = self.process_task(message.get("task"))
|
118 |
+
return {"status": "Traitement effectué", "result": task_result}
|
119 |
+
elif message.get("type") == "resource_thresholds":
|
120 |
+
self.resource_thresholds = message.get("thresholds")
|
121 |
+
return {"status": "Seuils de ressources mis à jour", "result": self.resource_thresholds}
|
122 |
+
elif message.get("type") == "maintenance_schedule":
|
123 |
+
self.maintenance_schedule = message.get("schedule")
|
124 |
+
return {"status": "Planning de maintenance mis à jour", "result": self.maintenance_schedule}
|
125 |
+
elif message.get("type") == "external_api":
|
126 |
+
api_name = message.get("api_name")
|
127 |
+
api_config = message.get("api_config")
|
128 |
+
self.external_apis[api_name] = api_config
|
129 |
+
return {"status": "API externe ajoutée", "result": api_config}
|
130 |
+
else:
|
131 |
+
return {"status": "Message non reconnu", "result": "Aucune action effectuée"}
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
def receive_communication(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Any]:
|
136 |
+
logging.info(f"{self.name} received communication from {sender_name}")
|
137 |
+
return self.process_communication(sender_name, message)
|
138 |
+
|
stellar/base_stellar.py
CHANGED
@@ -16,17 +16,17 @@ class Stellar:
|
|
16 |
|
17 |
def route_communication(self, sender_name: str, target_name: str, message: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
18 |
if sender_name not in self.satellites or target_name not in self.satellites:
|
19 |
-
logging.error(f"
|
20 |
return None
|
21 |
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
return
|
26 |
|
27 |
def broadcast_message(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Dict[str, Any]]:
|
28 |
results = {}
|
29 |
for satellite_name, satellite in self.satellites.items():
|
30 |
if satellite_name != sender_name:
|
31 |
-
results[satellite_name] =
|
32 |
return results
|
|
|
16 |
|
17 |
def route_communication(self, sender_name: str, target_name: str, message: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
18 |
if sender_name not in self.satellites or target_name not in self.satellites:
|
19 |
+
logging.error(f"Invalid sender or target: {sender_name} -> {target_name}")
|
20 |
return None
|
21 |
|
22 |
+
sender = self.satellites[sender_name]
|
23 |
+
target = self.satellites[target_name]
|
24 |
|
25 |
+
return sender.communicate_with_other_satellite(target, message)
|
26 |
|
27 |
def broadcast_message(self, sender_name: str, message: Dict[str, Any]) -> Dict[str, Dict[str, Any]]:
|
28 |
results = {}
|
29 |
for satellite_name, satellite in self.satellites.items():
|
30 |
if satellite_name != sender_name:
|
31 |
+
results[satellite_name] = self.route_communication(sender_name, satellite_name, message)
|
32 |
return results
|