feat: make AI Copilot an optional dependency

This change makes AI Copilot features optional to reduce installation
size and support restricted environments.

Changes:
- Split AI dependencies into ai-requirements.txt
- Add ai-copilot optional dependency in pyproject.toml
- Add import protection in gns3server/agent/__init__.py
- Return 501 for AI endpoints when dependencies not installed
- Add gns3server-uninstall-ai-copilot command for cleanup
- Update README with installation and uninstallation instructions

Installation:
- Basic: pip install gns3-server
- With AI: pip install gns3-server[ai-copilot]
- Development: pip install gns3-server[ai-copilot,dev]

Uninstallation:
- gns3server-uninstall-ai-copilot
This commit is contained in:
YueGuobin committed 2026-03-18 15:21:23 +08:00
1 parent 0b741dd834
commit cd1d28729a
8 files changed
+337 -76

No files matched your search

+25 -18
View File
@@ -30,24 +30,31 @@ from .controller.gns3vm import GNS3VM
from .controller.nodes import NodeCreate, NodeUpdate, NodeDuplicate, NodeCapture, Node
from .controller.projects import ProjectCreate, ProjectUpdate, ProjectDuplicate, Project, ProjectFile, ProjectCompression
from .controller.users import UserCreate, UserUpdate, LoggedInUserUpdate, User, Credentials, UserGroupCreate, UserGroupUpdate, UserGroup
from .controller.llm_model_configs import (
LLMModelConfigData,
LLMModelConfigCreate,
LLMModelConfigUpdate,
LLMModelConfigResponse,
LLMModelConfigWithSource,
LLMModelConfigInheritedResponse,
LLMModelConfigListResponse
)
from .controller.chat import (
OpenAIToolCall,
ChatRequest,
ChatResponse,
OpenAIMessage,
ConversationHistory,
ChatSession,
RenameSession
)
# Conditionally import AI-related schemas
try:
from .controller.llm_model_configs import (
LLMModelConfigData,
LLMModelConfigCreate,
LLMModelConfigUpdate,
LLMModelConfigResponse,
LLMModelConfigWithSource,
LLMModelConfigInheritedResponse,
LLMModelConfigListResponse
)
from .controller.chat import (
OpenAIToolCall,
ChatRequest,
ChatResponse,
OpenAIMessage,
ConversationHistory,
ChatSession,
RenameSession
)
except ImportError:
# AI schemas are not available (should not happen as they don't depend on external libs)
pass
from .controller.rbac import RoleCreate, RoleUpdate, Role, Privilege, ACECreate, ACEUpdate, ACE
from .controller.pools import Resource, ResourceCreate, ResourcePoolCreate, ResourcePoolUpdate, ResourcePool
from .controller.tokens import Token