|
@@ -0,0 +1,27 @@
|
|
|
+from pqai_agent.data_models.service_module import ServiceModule, ModuleAgentType
|
|
|
+from pqai_agent.logging_service import logger
|
|
|
+
|
|
|
+class ServiceModuleManager:
|
|
|
+ def __init__(self, session_maker):
|
|
|
+ self.session_maker = session_maker
|
|
|
+ self.module_configs = {}
|
|
|
+ self.refresh_configs()
|
|
|
+
|
|
|
+ def refresh_configs(self):
|
|
|
+ try:
|
|
|
+ with self.session_maker() as session:
|
|
|
+ data = session.query(ServiceModule).filter_by(is_delete=False).all()
|
|
|
+ module_configs = {}
|
|
|
+ for module in data:
|
|
|
+ module_configs[module.name] = {
|
|
|
+ 'display_name': module.display_name,
|
|
|
+ 'default_agent_type': ModuleAgentType(module.default_agent_type),
|
|
|
+ 'default_agent_id': module.default_agent_id
|
|
|
+ }
|
|
|
+ self.module_configs = module_configs
|
|
|
+ logger.debug(f"Refreshed module configurations: {module_configs}")
|
|
|
+ except Exception as e:
|
|
|
+ logger.error(f"Error refreshing module configs: {e}")
|
|
|
+
|
|
|
+ def get_module_config(self, module_name: str):
|
|
|
+ return self.module_configs.get(module_name)
|