mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
feat(copilot): add user-aware LLM calls and project cleanup
- Modified `llm_call` and `generate_title` functions to accept `config` parameter, extracting `user_id` and `jwt_token` for per-user LLM configuration and API authentication - Updated `create_base_model_with_tools` and `create_title_model` calls to pass user authentication details - Added `jwt_token` to state for tool usage in GNS3 API calls - Integrated chat router into controller API routes under `/chat` endpoint - Implemented `_cleanup_copilot_agent` method in `Project` class to remove AgentService resources upon project closure, preventing resource leaks - Enhanced error handling in agent cleanup to avoid interrupting project close operations
This commit is contained in:
1 parent
e1f1bb7d9f
commit
73de248381
7 files changed
+772
-5
No files matched your search
@@ -849,6 +849,9 @@ class Project:
|
||||
if not ignore_notification:
|
||||
self.emit_controller_notification("project.closed", self.asdict())
|
||||
|
||||
# Cleanup GNS3 Copilot AgentService for this project
|
||||
await self._cleanup_copilot_agent()
|
||||
|
||||
self.reset()
|
||||
self._closing = False
|
||||
|
||||
@@ -885,6 +888,23 @@ class Project:
|
||||
except OSError as e:
|
||||
log.warning(f"Could not delete unused pictures: {e}")
|
||||
|
||||
async def _cleanup_copilot_agent(self):
|
||||
"""
|
||||
Cleanup GNS3 Copilot AgentService for this project.
|
||||
|
||||
This should be called when the project is closed to free resources.
|
||||
"""
|
||||
try:
|
||||
from gns3server.agent.gns3_copilot.project_agent_manager import get_project_agent_manager
|
||||
|
||||
agent_manager = await get_project_agent_manager()
|
||||
if agent_manager.has_agent(self._id):
|
||||
log.info(f"Cleaning up AgentService for project '{self.name}' ({self._id})")
|
||||
await agent_manager.remove_agent(self._id)
|
||||
except Exception as e:
|
||||
# Don't fail project close if agent cleanup fails
|
||||
log.warning(f"Failed to cleanup AgentService for project '{self.name}': {e}")
|
||||
|
||||
async def delete(self):
|
||||
|
||||
if self._status != "opened":
|
||||
|
||||
Reference in new issue
Block a user