diff --git a/gns3server/agent/gns3_copilot/__init__.py b/gns3server/agent/gns3_copilot/__init__.py
index ed68f154e..f6aa26a80 100644
--- a/gns3server/agent/gns3_copilot/__init__.py
+++ b/gns3server/agent/gns3_copilot/__init__.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
GNS3-Copilot - AI-powered network automation assistant for GNS3.
This package provides a command-line interface for launching the GNS3-Copilot
diff --git a/gns3server/agent/gns3_copilot/agent/__init__.py b/gns3server/agent/gns3_copilot/agent/__init__.py
index 3657e4208..eb06974df 100644
--- a/gns3server/agent/gns3_copilot/agent/__init__.py
+++ b/gns3server/agent/gns3_copilot/agent/__init__.py
@@ -26,8 +26,6 @@ GNS3-Copilot Agent Package
This package contains the main GNS3-Copilot agent implementation for
network automation tasks using LangGraph workflow orchestration.
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
from .gns3_copilot import agent_builder
diff --git a/gns3server/agent/gns3_copilot/agent/context_manager.py b/gns3server/agent/gns3_copilot/agent/context_manager.py
index a6f0c0349..25244429e 100644
--- a/gns3server/agent/gns3_copilot/agent/context_manager.py
+++ b/gns3server/agent/gns3_copilot/agent/context_manager.py
@@ -32,8 +32,6 @@ including:
- Tool definition token estimation
- Template variable injection for topology info
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
import json
@@ -49,7 +47,6 @@ from langchain_core.messages import (
logger = logging.getLogger(__name__)
-
# ============================================================================
# Constants
# ============================================================================
@@ -63,7 +60,6 @@ CONTEXT_STRATEGY_RATIOS = {
DEFAULT_CONTEXT_STRATEGY = "balanced"
-
# ============================================================================
# Token Counting - Using tiktoken for accuracy
# ============================================================================
@@ -71,7 +67,6 @@ DEFAULT_CONTEXT_STRATEGY = "balanced"
# Global tiktoken encoding cache (lazy loading)
_tiktoken_encoding = None
-
def _get_tiktoken_encoding():
"""
Get tiktoken encoding instance (cached).
@@ -98,7 +93,6 @@ def _get_tiktoken_encoding():
)
return _tiktoken_encoding
-
def count_tokens_accurately(text: str) -> int:
"""
Count tokens in text accurately using tiktoken.
@@ -122,7 +116,6 @@ def count_tokens_accurately(text: str) -> int:
logger.error("tiktoken encoding failed: %s", e)
raise
-
def count_messages_tokens(messages: list[Any]) -> int:
"""
Count total tokens in a list of messages accurately.
@@ -144,7 +137,6 @@ def count_messages_tokens(messages: list[Any]) -> int:
total += count_tokens_accurately(content)
return total
-
# ============================================================================
# Tool Definition Token Estimation
# ============================================================================
@@ -208,7 +200,6 @@ def estimate_tool_tokens(tools: list[Any]) -> int:
logger.info("Tool definitions estimated at ~%d total tokens (%d tools)", total_tokens, len(tools))
return total_tokens
-
# ============================================================================
# Model Context Limits
# ============================================================================
@@ -227,7 +218,6 @@ def estimate_tool_tokens(tools: list[Any]) -> int:
#
# Always verify current limits from official provider documentation.
-
def get_model_context_limit(
model_name: str,
llm_config: dict[str, Any] | None = None
@@ -277,7 +267,6 @@ def get_model_context_limit(
f"Refer to the model provider's documentation for the current context window size."
)
-
def calculate_max_tokens(
model_limit: int,
strategy: Literal["conservative", "balanced", "aggressive"] = DEFAULT_CONTEXT_STRATEGY
@@ -305,7 +294,6 @@ def calculate_max_tokens(
return max_tokens
-
# ============================================================================
# Message Trimming
# ============================================================================
@@ -414,7 +402,6 @@ def trim_messages_for_context(
return trimmed
-
def _trim_to_token_limit(messages: list[Any], max_tokens: int) -> list[Any]:
"""
Trim messages to fit within token limit using tiktoken.
@@ -448,7 +435,6 @@ def _trim_to_token_limit(messages: list[Any], max_tokens: int) -> list[Any]:
return trimmed
-
# ============================================================================
# Token Usage Summary
# ============================================================================
@@ -504,7 +490,6 @@ def get_token_usage_summary(
"needs_trimming": usage_percentage > 80,
}
-
# ============================================================================
# Main Entry Point - Context Preparation with Template Injection
# ============================================================================
@@ -634,7 +619,6 @@ def prepare_context_messages(
return trimmed_messages
-
# ============================================================================
# Module Test
# ============================================================================
diff --git a/gns3server/agent/gns3_copilot/agent/gns3_copilot.py b/gns3server/agent/gns3_copilot/agent/gns3_copilot.py
index 7a08fcbc1..7679768db 100644
--- a/gns3server/agent/gns3_copilot/agent/gns3_copilot.py
+++ b/gns3server/agent/gns3_copilot/agent/gns3_copilot.py
@@ -35,8 +35,6 @@ The agent provides:
- Automatic conversation title generation
- Integration with GNS3 topology management
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
import operator
@@ -101,7 +99,6 @@ DEFAULT_CONVERSATION_TITLE = "New Conversation"
UNTITLED_SESSION_FALLBACK = "Untitled Session"
TITLE_MAX_LENGTH = 40
-
# Define state
class MessagesState(TypedDict):
"""
@@ -130,7 +127,6 @@ class MessagesState(TypedDict):
# Store GNS3 topology information
topology_info: dict | None
-
# Define llm call node
def llm_call(state: dict, config: RunnableConfig | None = None):
"""LLM decides whether to call a tool or not"""
@@ -232,7 +228,6 @@ def llm_call(state: dict, config: RunnableConfig | None = None):
"topology_info": topology_info,
}
-
# Define generate title node
def generate_title(state: MessagesState, config: RunnableConfig | None = None) -> dict:
"""
@@ -317,7 +312,6 @@ def generate_title(state: MessagesState, config: RunnableConfig | None = None) -
# Title already exists → no update needed
return {}
-
# Define tool node
def tool_node(state: dict, config: RunnableConfig | None = None):
"""Performs the tool call"""
@@ -344,7 +338,6 @@ def tool_node(state: dict, config: RunnableConfig | None = None):
))
return {"messages": result}
-
# Routing logic after the LLM node
def should_continue(
state: MessagesState,
@@ -370,7 +363,6 @@ def should_continue(
# Normal completion (multi-turn conversation or title already exists)
return END
-
# Routing logic after the tool node, Check remaining_steps
def recursion_limit_continue(state: MessagesState) -> Literal["llm_call", END]:
"""
@@ -397,7 +389,6 @@ def recursion_limit_continue(state: MessagesState) -> Literal["llm_call", END]:
return END
-
# Build and compile the agent
# Build workflow
agent_builder = StateGraph(MessagesState)
diff --git a/gns3server/agent/gns3_copilot/agent/model_factory.py b/gns3server/agent/gns3_copilot/agent/model_factory.py
index 58a1fae4a..3d7ec022d 100644
--- a/gns3server/agent/gns3_copilot/agent/model_factory.py
+++ b/gns3server/agent/gns3_copilot/agent/model_factory.py
@@ -26,8 +26,6 @@ Model Factory for GNS3-Copilot Agent
This module provides factory functions to create fresh LLM model instances.
Configuration is passed directly from the database.
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
import logging
@@ -37,7 +35,6 @@ from langchain.chat_models import init_chat_model
logger = logging.getLogger(__name__)
-
def _load_llm_config(
llm_config: Optional[dict[str, Any]] = None,
) -> dict[str, str]:
@@ -70,7 +67,6 @@ def _load_llm_config(
"temperature": str(llm_config.get("temperature", "0")),
}
-
def create_base_model(
llm_config: Optional[dict[str, Any]] = None,
) -> Any:
@@ -124,7 +120,6 @@ def create_base_model(
logger.error("Failed to create base model: %s", e)
raise RuntimeError(f"Failed to create base model: {e}") from e
-
def create_title_model(
llm_config: Optional[dict[str, Any]] = None,
) -> Any:
@@ -180,7 +175,6 @@ def create_title_model(
logger.error("Failed to create title model: %s", e)
raise RuntimeError(f"Failed to create title model: {e}") from e
-
def create_model_with_tools(
model: Any,
tools: list[Any],
@@ -206,7 +200,6 @@ def create_model_with_tools(
logger.error("Failed to bind tools to model: %s", e)
raise RuntimeError(f"Failed to bind tools to model: {e}") from e
-
def create_base_model_with_tools(
tools: list[Any],
llm_config: Optional[dict[str, Any]] = None,
diff --git a/gns3server/agent/gns3_copilot/agent_service.py b/gns3server/agent/gns3_copilot/agent_service.py
index 44607d821..59ddbcc9c 100644
--- a/gns3server/agent/gns3_copilot/agent_service.py
+++ b/gns3server/agent/gns3_copilot/agent_service.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
GNS3 Copilot Agent Service
Provides project-level Agent instances with SQLite checkpoint management.
@@ -48,7 +46,6 @@ from gns3server.agent.gns3_copilot.utils.message_converters import convert_langc
log = logging.getLogger(__name__)
-
class AgentService:
"""
Project-level Agent Service with async checkpoint management.
diff --git a/gns3server/agent/gns3_copilot/chat_sessions_repository.py b/gns3server/agent/gns3_copilot/chat_sessions_repository.py
index da1952aef..191bab228 100644
--- a/gns3server/agent/gns3_copilot/chat_sessions_repository.py
+++ b/gns3server/agent/gns3_copilot/chat_sessions_repository.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
Chat Sessions Repository for managing chat session data.
Provides CRUD operations for the chat_sessions table in the project's
@@ -39,7 +37,6 @@ import aiosqlite
log = logging.getLogger(__name__)
-
class ChatSession:
"""Chat session model."""
@@ -100,7 +97,6 @@ class ChatSession:
"pinned": self.pinned,
}
-
class ChatSessionsRepository:
"""
Repository for managing chat sessions in the checkpoint database.
diff --git a/gns3server/agent/gns3_copilot/gns3_client/__init__.py b/gns3server/agent/gns3_copilot/gns3_client/__init__.py
index 4ef9e02bb..ef15bb76a 100644
--- a/gns3server/agent/gns3_copilot/gns3_client/__init__.py
+++ b/gns3server/agent/gns3_copilot/gns3_client/__init__.py
@@ -41,9 +41,6 @@ Main functions:
- get_gns3_server_host: Get GNS3 server hostname from Controller or Config
- get_llm_config: Get LLM model configuration for a user
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
-
Upstream gns3fy: https://github.com/davidban77/gns3fy
"""
diff --git a/gns3server/agent/gns3_copilot/gns3_client/connector_factory.py b/gns3server/agent/gns3_copilot/gns3_client/connector_factory.py
index f36507275..44bdb2c39 100644
--- a/gns3server/agent/gns3_copilot/gns3_client/connector_factory.py
+++ b/gns3server/agent/gns3_copilot/gns3_client/connector_factory.py
@@ -32,8 +32,6 @@ Features:
- Fallback URL strategy for flexible deployment
- LLM configuration retrieval for users
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
import logging
@@ -47,13 +45,11 @@ logger = logging.getLogger(__name__)
_jwt_token_context: ContextVar[Optional[str]] = ContextVar("_jwt_token_context", default=None)
_llm_config_context: ContextVar[Optional[dict]] = ContextVar("_llm_config_context", default=None)
-
def set_current_jwt_token(token: str) -> None:
"""Set the JWT token for the current request context."""
_jwt_token_context.set(token)
logger.debug("JWT token set in context")
-
def get_current_jwt_token() -> Optional[str]:
"""Get the JWT token for the current request context."""
token = _jwt_token_context.get()
@@ -63,14 +59,12 @@ def get_current_jwt_token() -> Optional[str]:
logger.warning("JWT token not found in context")
return token
-
def set_current_llm_config(config: dict) -> None:
"""Set the LLM config for the current request context."""
_llm_config_context.set(config)
logger.debug("LLM config set in context: provider=%s, model=%s",
config.get("provider"), config.get("model"))
-
def get_current_llm_config() -> Optional[dict]:
"""Get the LLM config for the current request context."""
config = _llm_config_context.get()
@@ -87,7 +81,6 @@ from gns3server.agent.gns3_copilot.gns3_client.custom_gns3fy import Gns3Connecto
# Fallback default URL
DEFAULT_GNS3_URL = "http://127.0.0.1:3080"
-
def _get_url_from_controller() -> Optional[str]:
"""Try to get GNS3 server URL from running Controller instance.
@@ -122,7 +115,6 @@ def _get_url_from_controller() -> Optional[str]:
logger.warning("Unexpected error getting URL from Controller: %s", str(e))
return None
-
def _get_url_from_config() -> Optional[str]:
"""Try to get GNS3 server URL from Config settings.
@@ -152,7 +144,6 @@ def _get_url_from_config() -> Optional[str]:
logger.warning("Unexpected error getting URL from Config: %s", str(e))
return None
-
def get_gns3_connector(jwt_token: Optional[str] = None, url: Optional[str] = None) -> Optional[Gns3Connector]:
"""Create and return a Gns3Connector instance with JWT authentication.
@@ -239,7 +230,6 @@ def get_gns3_connector(jwt_token: Optional[str] = None, url: Optional[str] = Non
logger.error("Failed to create Gns3Connector: %s", str(e), exc_info=True)
return None
-
async def get_gns3_connector_with_llm_config(
user_id,
jwt_token: str,
@@ -327,7 +317,6 @@ async def get_gns3_connector_with_llm_config(
logger.error(f"Failed to get GNS3 connector with LLM config: {e}", exc_info=True)
return None
-
def _detect_url_for_api() -> Optional[str]:
"""
Detect GNS3 server URL for API calls.
@@ -358,7 +347,6 @@ def _detect_url_for_api() -> Optional[str]:
logger.debug("Using fallback URL for API call: %s", DEFAULT_GNS3_URL)
return DEFAULT_GNS3_URL
-
def get_gns3_server_host() -> str:
"""
Get GNS3 server hostname from Controller or Config.
@@ -395,7 +383,6 @@ def get_gns3_server_host() -> str:
logger.warning("Failed to extract host from URL %s: %s, using fallback", url, e)
return DEFAULT_GNS3_URL.split("://")[1].split(":")[0]
-
def get_llm_config(user_id, jwt_token: str, app=None) -> Optional[dict]:
"""
Get LLM model configuration for a user.
diff --git a/gns3server/agent/gns3_copilot/gns3_client/custom_gns3fy.py b/gns3server/agent/gns3_copilot/gns3_client/custom_gns3fy.py
index 7c372ef3c..aa7203c2a 100644
--- a/gns3server/agent/gns3_copilot/gns3_client/custom_gns3fy.py
+++ b/gns3server/agent/gns3_copilot/gns3_client/custom_gns3fy.py
@@ -35,9 +35,6 @@ Modifications made for GNS3-Copilot:
Note: This file is adapted from upstream gns3fy for compatibility with
GNS3-Copilot's architecture.
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
-
Upstream: https://github.com/davidban77/gns3fy
"""
@@ -68,7 +65,6 @@ F = TypeVar("F", bound=Callable[..., Any])
config = ConfigDict(validate_assignment=True, extra="ignore")
-
NODE_TYPES = [
"cloud",
"nat",
@@ -99,7 +95,6 @@ CONSOLE_TYPES = [
LINK_TYPES = ["ethernet", "serial"]
-
class Gns3Connector:
"""
Connector to be use for interaction against GNS3 server controller API.
@@ -730,7 +725,6 @@ class Gns3Connector:
return cast(dict[str, Any], _response_data)
-
def verify_connector_and_id(f: F) -> F:
"""
Main checker for connector object and respective object's ID for their retrieval
@@ -773,7 +767,6 @@ def verify_connector_and_id(f: F) -> F:
return cast(F, wrapper)
-
@dataclass(config=config)
class Link:
"""
@@ -973,7 +966,6 @@ class Link:
# Update object
self._update(_response.json())
-
@dataclass(config=config)
class Node:
"""
@@ -1501,7 +1493,6 @@ class Node:
_conn.http_call("post", _url, data=data)
-
@dataclass(config=config)
class Project:
"""
diff --git a/gns3server/agent/gns3_copilot/gns3_client/gns3_project_info.py b/gns3server/agent/gns3_copilot/gns3_client/gns3_project_info.py
index d431608c9..b6f150c0f 100644
--- a/gns3server/agent/gns3_copilot/gns3_client/gns3_project_info.py
+++ b/gns3server/agent/gns3_copilot/gns3_client/gns3_project_info.py
@@ -27,8 +27,6 @@ This module provides a LangChain BaseTool to retrieve basic information of a
specific GNS3 project by project ID. Returns project name, status, node count,
and link count.
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
import logging
@@ -41,7 +39,6 @@ from gns3server.agent.gns3_copilot.gns3_client import Project, get_gns3_connecto
# Configure logging
logger = logging.getLogger(__name__)
-
class GNS3ProjectInfoTool(BaseTool):
"""LangChain tool for retrieving GNS3 project basic information."""
@@ -133,7 +130,6 @@ class GNS3ProjectInfoTool(BaseTool):
logger.error("Error retrieving GNS3 project info: %s", str(e))
return {"error": f"Failed to retrieve project info: {str(e)}"}
-
if __name__ == "__main__":
from pprint import pprint
diff --git a/gns3server/agent/gns3_copilot/gns3_client/gns3_topology_reader.py b/gns3server/agent/gns3_copilot/gns3_client/gns3_topology_reader.py
index b2ac98caf..71e914623 100644
--- a/gns3server/agent/gns3_copilot/gns3_client/gns3_topology_reader.py
+++ b/gns3server/agent/gns3_copilot/gns3_client/gns3_topology_reader.py
@@ -26,8 +26,6 @@ GNS3 Topology Reader Tool
This module provides a LangChain BaseTool to retrieve the topology of a
specific GNS3 project by project ID. Returns nodes, links, and project metadata.
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
import copy
@@ -41,7 +39,6 @@ from gns3server.agent.gns3_copilot.gns3_client import Project, get_gns3_connecto
# Configure logging
logger = logging.getLogger(__name__)
-
# Define LangChain tool class
class GNS3TopologyTool(BaseTool):
"""LangChain tool for retrieving GNS3 project topology information."""
@@ -143,7 +140,6 @@ class GNS3TopologyTool(BaseTool):
]
return data
-
if __name__ == "__main__":
from pprint import pprint
diff --git a/gns3server/agent/gns3_copilot/project_agent_manager.py b/gns3server/agent/gns3_copilot/project_agent_manager.py
index 9320e5019..9d91ec9a6 100644
--- a/gns3server/agent/gns3_copilot/project_agent_manager.py
+++ b/gns3server/agent/gns3_copilot/project_agent_manager.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
Project Agent Manager
Manages AgentService instances for GNS3 projects using a singleton pattern.
@@ -37,7 +35,6 @@ from gns3server.agent.gns3_copilot.agent_service import AgentService
log = logging.getLogger(__name__)
-
class ProjectAgentManager:
"""
Singleton manager for project-level Agent services.
@@ -124,12 +121,10 @@ class ProjectAgentManager:
"""
return list(self._agents.keys())
-
# Global singleton instance
_project_agent_manager: Optional[ProjectAgentManager] = None
_manager_lock = asyncio.Lock()
-
async def get_project_agent_manager() -> ProjectAgentManager:
"""
Get the global ProjectAgentManager singleton instance.
diff --git a/gns3server/agent/gns3_copilot/prompts/__init__.py b/gns3server/agent/gns3_copilot/prompts/__init__.py
index 91f1985ae..3deef6c0c 100644
--- a/gns3server/agent/gns3_copilot/prompts/__init__.py
+++ b/gns3server/agent/gns3_copilot/prompts/__init__.py
@@ -26,8 +26,6 @@ Prompts Module for GNS3-Copilot
This package contains system prompts and prompt loading utilities for
the GNS3-Copilot AI agent.
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
from .base_prompt import SYSTEM_PROMPT
diff --git a/gns3server/agent/gns3_copilot/prompts/base_prompt.py b/gns3server/agent/gns3_copilot/prompts/base_prompt.py
index 3dd30b9b7..d1c331820 100644
--- a/gns3server/agent/gns3_copilot/prompts/base_prompt.py
+++ b/gns3server/agent/gns3_copilot/prompts/base_prompt.py
@@ -28,8 +28,6 @@ to guide network diagnostics and teaching activities.
CRITICAL: This assistant has DIAGNOSIS permissions only, NO configuration permissions.
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
# System prompt for LangChain v1.0 agent
diff --git a/gns3server/agent/gns3_copilot/prompts/prompt_loader.py b/gns3server/agent/gns3_copilot/prompts/prompt_loader.py
index d725ebdee..40483e2f2 100644
--- a/gns3server/agent/gns3_copilot/prompts/prompt_loader.py
+++ b/gns3server/agent/gns3_copilot/prompts/prompt_loader.py
@@ -27,8 +27,6 @@ This module provides utilities for loading system prompts.
Can be extended to support multiple prompt variants based on
environment variables (e.g., ENGLISH_LEVEL).
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
import logging
@@ -38,7 +36,6 @@ from .base_prompt import SYSTEM_PROMPT
logger = logging.getLogger(__name__)
-
def load_system_prompt() -> str:
"""
Load the system prompt for GNS3-Copilot.
diff --git a/gns3server/agent/gns3_copilot/prompts/title_prompt.py b/gns3server/agent/gns3_copilot/prompts/title_prompt.py
index 90b6ebb23..62a1b8b58 100644
--- a/gns3server/agent/gns3_copilot/prompts/title_prompt.py
+++ b/gns3server/agent/gns3_copilot/prompts/title_prompt.py
@@ -26,8 +26,6 @@ Title Generation Prompt for GNS3-Copilot
Prompt template for generating conversation titles.
Generates concise Chinese or English titles based on conversation language.
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
"""
TITLE_PROMPT = """
diff --git a/gns3server/agent/gns3_copilot/tools_v2/__init__.py b/gns3server/agent/gns3_copilot/tools_v2/__init__.py
index 0e0812a2d..77adbfa82 100644
--- a/gns3server/agent/gns3_copilot/tools_v2/__init__.py
+++ b/gns3server/agent/gns3_copilot/tools_v2/__init__.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
GNS3-Copilot Tools Package
This package provides various tools for interacting with GNS3 network simulator, including:
diff --git a/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py b/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py
index daa4d0ce0..601d7c11f 100644
--- a/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py
+++ b/gns3server/agent/gns3_copilot/tools_v2/config_tools_nornir.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
This module provides a tool to execute configuration commands on multiple devices
in a GNS3 topology using Nornir.
"""
@@ -47,13 +45,11 @@ from gns3server.agent.gns3_copilot.utils import get_device_ports_from_topology
# config log
logger = logging.getLogger(__name__)
-
# Local Nornir configuration functions for Cisco IOS Telnet devices
def _get_nornir_defaults() -> dict[str, Any]:
"""Get Nornir default configuration for Cisco IOS."""
return {"data": {"location": "gns3"}}
-
def _get_nornir_groups_config() -> dict[str, dict[str, Any]]:
"""Get Nornir groups configuration for Cisco IOS Telnet devices."""
return {
@@ -69,13 +65,11 @@ def _get_nornir_groups_config() -> dict[str, dict[str, Any]]:
},
}
-
def _get_nornir_group(group_name: str = "cisco_IOSv_telnet") -> dict[str, Any]:
"""Get Nornir group configuration for a specific group."""
all_groups = _get_nornir_groups_config()
return all_groups.get(group_name, {})
-
class ExecuteMultipleDeviceConfigCommands(BaseTool):
"""
A tool to execute configuration commands on multiple devices in a GNS3 topology using Nornir.
@@ -481,7 +475,6 @@ class ExecuteMultipleDeviceConfigCommands(BaseTool):
return results
-
if __name__ == "__main__":
# Example usage with new format
# example tool_input with project_id
diff --git a/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py b/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py
index 131cfb015..0fffe95ed 100644
--- a/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py
+++ b/gns3server/agent/gns3_copilot/tools_v2/display_tools_nornir.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
This module provides a tool to execute display commands on multiple devices
in a GNS3 topology using Nornir.
"""
@@ -48,13 +46,11 @@ from gns3server.agent.gns3_copilot.utils import get_device_ports_from_topology
# config log
logger = logging.getLogger(__name__)
-
# Local Nornir configuration functions for Cisco IOS Telnet devices
def _get_nornir_defaults() -> dict[str, Any]:
"""Get Nornir default configuration for Cisco IOS."""
return {"data": {"location": "gns3"}}
-
def _get_nornir_groups_config() -> dict[str, dict[str, Any]]:
"""Get Nornir groups configuration for Cisco IOS Telnet devices."""
return {
@@ -70,13 +66,11 @@ def _get_nornir_groups_config() -> dict[str, dict[str, Any]]:
},
}
-
def _get_nornir_group(group_name: str = "cisco_IOSv_telnet") -> dict[str, Any]:
"""Get Nornir group configuration for a specific group."""
all_groups = _get_nornir_groups_config()
return all_groups.get(group_name, {})
-
class ExecuteMultipleDeviceCommands(BaseTool):
"""
A READ-ONLY diagnostic tool for viewing network device configurations and protocol states.
@@ -495,7 +489,6 @@ class ExecuteMultipleDeviceCommands(BaseTool):
return results
-
if __name__ == "__main__":
# Example usage with new format
device_commands = json.dumps(
diff --git a/gns3server/agent/gns3_copilot/tools_v2/gns3_create_link.py b/gns3server/agent/gns3_copilot/tools_v2/gns3_create_link.py
index fb1b3d635..e7d17ed01 100644
--- a/gns3server/agent/gns3_copilot/tools_v2/gns3_create_link.py
+++ b/gns3server/agent/gns3_copilot/tools_v2/gns3_create_link.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
GNS3 link creation tool for connecting network nodes.
Provides functionality to create links between nodes in GNS3 projects
@@ -42,7 +40,6 @@ from gns3server.agent.gns3_copilot.gns3_client import Link, get_gns3_connector
# Configure logging
logger = logging.getLogger(__name__)
-
class GNS3LinkTool(BaseTool):
"""
Tool for creating network links between GNS3 nodes.
@@ -249,7 +246,6 @@ class GNS3LinkTool(BaseTool):
logger.error("Failed to process link creation: %s", e)
return [{"error": f"Failed to process link creation: {str(e)}"}]
-
if __name__ == "__main__":
# Test with single link
single_link_input = json.dumps(
diff --git a/gns3server/agent/gns3_copilot/tools_v2/gns3_create_node.py b/gns3server/agent/gns3_copilot/tools_v2/gns3_create_node.py
index b451721fd..2c380ae03 100644
--- a/gns3server/agent/gns3_copilot/tools_v2/gns3_create_node.py
+++ b/gns3server/agent/gns3_copilot/tools_v2/gns3_create_node.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
GNS3 node creation tool for network topology building.
Provides functionality to create multiple nodes in GNS3 projects
@@ -42,7 +40,6 @@ from gns3server.agent.gns3_copilot.gns3_client import Node, get_gns3_connector
# Configure logging
logger = logging.getLogger(__name__)
-
class GNS3CreateNodeTool(BaseTool):
"""
A LangChain tool to create multiple nodes in a GNS3 project
@@ -267,7 +264,6 @@ class GNS3CreateNodeTool(BaseTool):
logger.error("Failed to process node creation request: %s", e)
return {"error": f"Failed to process node creation request: {str(e)}"}
-
if __name__ == "__main__":
# Test the tool locally with multiple nodes
test_input = json.dumps(
diff --git a/gns3server/agent/gns3_copilot/tools_v2/gns3_get_node_temp.py b/gns3server/agent/gns3_copilot/tools_v2/gns3_get_node_temp.py
index 2cb932b46..6c51dea97 100644
--- a/gns3server/agent/gns3_copilot/tools_v2/gns3_get_node_temp.py
+++ b/gns3server/agent/gns3_copilot/tools_v2/gns3_get_node_temp.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
GNS3 template retrieval tool for device discovery.
Provides functionality to retrieve all available device templates
@@ -42,7 +40,6 @@ from gns3server.agent.gns3_copilot.gns3_client import get_gns3_connector
# Configure logging
logger = logging.getLogger(__name__)
-
class GNS3TemplateTool(BaseTool):
"""
A LangChain tool to retrieve all available device templates from a GNS3 server.
@@ -133,7 +130,6 @@ class GNS3TemplateTool(BaseTool):
)
return {"error": f"Failed to retrieve templates: {str(e)}"}
-
if __name__ == "__main__":
# Test's tool locally
tool = GNS3TemplateTool()
diff --git a/gns3server/agent/gns3_copilot/tools_v2/gns3_start_node.py b/gns3server/agent/gns3_copilot/tools_v2/gns3_start_node.py
index 0907b9bb3..fde9c16dc 100644
--- a/gns3server/agent/gns3_copilot/tools_v2/gns3_start_node.py
+++ b/gns3server/agent/gns3_copilot/tools_v2/gns3_start_node.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
GNS3 node startup tool for network device activation.
Provides functionality to start one or multiple nodes in GNS3 projects
@@ -43,7 +41,6 @@ from gns3server.agent.gns3_copilot.gns3_client import Node, get_gns3_connector
# Configure logging
logger = logging.getLogger(__name__)
-
def show_progress_bar(
duration: int = 120, interval: int = 1, node_count: int = 1
) -> None:
@@ -73,7 +70,6 @@ def show_progress_bar(
print(f"\n{node_count} node(s) startup completed!")
-
class GNS3StartNodeTool(BaseTool):
"""
A LangChain tool to start one or multiple nodes in a GNS3 project.
@@ -224,7 +220,6 @@ class GNS3StartNodeTool(BaseTool):
logger.error("Failed to start nodes: %s", e)
return {"error": f"Failed to start nodes: {str(e)}"}
-
class GNS3StartNodeQuickTool(BaseTool):
"""
A LangChain tool to start one or multiple nodes in a GNS3 project WITHOUT waiting.
@@ -373,7 +368,6 @@ class GNS3StartNodeQuickTool(BaseTool):
logger.error("Failed to start nodes: %s", e)
return {"error": f"Failed to start nodes: {str(e)}"}
-
if __name__ == "__main__":
# Test with single node
print("=== Testing single node startup ===")
diff --git a/gns3server/agent/gns3_copilot/tools_v2/gns3_update_node_name.py b/gns3server/agent/gns3_copilot/tools_v2/gns3_update_node_name.py
index 614d3e348..fb760358f 100644
--- a/gns3server/agent/gns3_copilot/tools_v2/gns3_update_node_name.py
+++ b/gns3server/agent/gns3_copilot/tools_v2/gns3_update_node_name.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
GNS3 node name update tool for renaming network devices.
Provides functionality to update the name of one or multiple nodes in GNS3 projects.
@@ -41,7 +39,6 @@ from gns3server.agent.gns3_copilot.gns3_client import Node, get_gns3_connector
# Configure logging
logger = logging.getLogger(__name__)
-
class GNS3UpdateNodeNameTool(BaseTool):
"""
A LangChain tool to update the name of one or multiple nodes in a GNS3 project.
@@ -205,7 +202,6 @@ class GNS3UpdateNodeNameTool(BaseTool):
logger.error("Failed to update node names: %s", e)
return {"error": f"Failed to update node names: {str(e)}"}
-
if __name__ == "__main__":
# Test with single node
print("=== Testing single node name update ===")
diff --git a/gns3server/agent/gns3_copilot/tools_v2/vpcs_tools_telnetlib3.py b/gns3server/agent/gns3_copilot/tools_v2/vpcs_tools_telnetlib3.py
index 4e5c8e80e..c17f2957a 100644
--- a/gns3server/agent/gns3_copilot/tools_v2/vpcs_tools_telnetlib3.py
+++ b/gns3server/agent/gns3_copilot/tools_v2/vpcs_tools_telnetlib3.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
Multi-device VPCS command execution tool using telnetlib3 with threading.
Supports concurrent execution of multiple command groups across multiple VPCS devices.
"""
@@ -44,7 +42,6 @@ from gns3server.agent.gns3_copilot.utils import get_device_ports_from_topology
logger = logging.getLogger(__name__)
-
class VPCSMultiCommands(BaseTool):
"""
A tool for VPCS (Virtual PC Simulator) devices to view PC configurations and test connectivity.
@@ -426,7 +423,6 @@ class VPCSMultiCommands(BaseTool):
return results
-
if __name__ == "__main__":
# Example usage
command_groups = json.dumps(
diff --git a/gns3server/agent/gns3_copilot/utils/__init__.py b/gns3server/agent/gns3_copilot/utils/__init__.py
index e9d2a091c..d9863449b 100644
--- a/gns3server/agent/gns3_copilot/utils/__init__.py
+++ b/gns3server/agent/gns3_copilot/utils/__init__.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
GNS3-Copilot Public Model Package
This package provides reusable public models and utilities for GNS3 network automation tasks.
@@ -55,7 +53,6 @@ __author__ = "Guobin Yue"
__description__ = "AI-powered network automation assistant for GNS3"
__url__ = "https://github.com/yueguobin/gns3-copilot"
-
# Export main utility functions
__all__ = [
"get_device_ports_from_topology",
diff --git a/gns3server/agent/gns3_copilot/utils/get_gns3_device_port.py b/gns3server/agent/gns3_copilot/utils/get_gns3_device_port.py
index 90d554318..a6873be75 100644
--- a/gns3server/agent/gns3_copilot/utils/get_gns3_device_port.py
+++ b/gns3server/agent/gns3_copilot/utils/get_gns3_device_port.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
Public module for getting device port information from GNS3 topology
"""
@@ -31,7 +29,6 @@ from typing import Any
logger = logging.getLogger(__name__)
-
def get_device_ports_from_topology(
device_names: list[str],
project_id: str | None = None,
diff --git a/gns3server/agent/gns3_copilot/utils/gns3_drawing_utils.py b/gns3server/agent/gns3_copilot/utils/gns3_drawing_utils.py
index 17bbf99cf..005888f90 100644
--- a/gns3server/agent/gns3_copilot/utils/gns3_drawing_utils.py
+++ b/gns3server/agent/gns3_copilot/utils/gns3_drawing_utils.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
Drawing utility functions for GNS3 area annotations.
Calculates drawing parameters and generates SVG content for network area annotations.
@@ -102,7 +100,6 @@ COLOR_SCHEMES = {
},
}
-
def calculate_two_node_shape(
node1: dict,
node2: dict,
@@ -241,7 +238,6 @@ def calculate_two_node_shape(
"metadata": metadata,
}
-
def generate_ellipse_svg(
rx: int,
ry: int,
@@ -252,7 +248,6 @@ def generate_ellipse_svg(
"""Generate SVG for ellipse."""
return f''''''
-
def generate_rectangle_svg(
width: int,
height: int,
@@ -261,7 +256,6 @@ def generate_rectangle_svg(
"""Generate SVG for rectangle."""
return f''''''
-
def generate_text_svg(text: str, color_scheme: dict[str, Any]) -> str:
"""Generate SVG for text label."""
text_width = len(text) * 8 + 20
@@ -269,7 +263,6 @@ def generate_text_svg(text: str, color_scheme: dict[str, Any]) -> str:
return f''''''
-
def _hsv_to_hex(h: int, s: int, v: int) -> str:
"""Convert HSV to HEX color."""
h_norm = (h % 360) / 360
@@ -303,7 +296,6 @@ def _hsv_to_hex(h: int, s: int, v: int) -> str:
return f"#{r:02x}{g:02x}{b:02x}"
-
def calculate_z_order(area_size: float) -> int:
"""
Calculate z-order based on area size for proper layering.
@@ -321,7 +313,6 @@ def calculate_z_order(area_size: float) -> int:
else:
return 3
-
def _get_color_scheme(area_name: str) -> dict[str, Any]:
"""
Get color scheme based on area name using keyword inference.
@@ -410,7 +401,6 @@ def _get_color_scheme(area_name: str) -> dict[str, Any]:
return COLOR_SCHEMES["DEFAULT"]
-
def calculate_two_node_ellipse(
node1: dict,
node2: dict,
@@ -431,7 +421,6 @@ def calculate_two_node_ellipse(
"metadata": result["metadata"],
}
-
def calculate_two_node_rectangle(
node1: dict,
node2: dict,
diff --git a/gns3server/agent/gns3_copilot/utils/llm_config_helper.py b/gns3server/agent/gns3_copilot/utils/llm_config_helper.py
index 7d0124868..fee056cce 100644
--- a/gns3server/agent/gns3_copilot/utils/llm_config_helper.py
+++ b/gns3server/agent/gns3_copilot/utils/llm_config_helper.py
@@ -21,8 +21,6 @@
#
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
LLM Model Configuration Helper for GNS3 Copilot
This module provides utility functions to retrieve LLM model configurations
@@ -47,7 +45,6 @@ from fastapi import FastAPI
logger = logging.getLogger(__name__)
-
async def get_user_llm_config_with_app(
user_id: UUID,
app: FastAPI
diff --git a/gns3server/agent/gns3_copilot/utils/message_converters.py b/gns3server/agent/gns3_copilot/utils/message_converters.py
index dd9894c13..6ec5e7350 100644
--- a/gns3server/agent/gns3_copilot/utils/message_converters.py
+++ b/gns3server/agent/gns3_copilot/utils/message_converters.py
@@ -17,8 +17,6 @@
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
Message format converters for OpenAI-compatible message format.
Converts between LangChain messages and OpenAI-compatible format.
"""
@@ -27,7 +25,6 @@ import uuid
from datetime import datetime
from typing import Dict, Any
-
def _ensure_string(content: Any) -> str:
"""Ensure content is a string, converting dicts/lists to JSON if needed."""
if isinstance(content, str):
@@ -37,7 +34,6 @@ def _ensure_string(content: Any) -> str:
else:
return str(content)
-
def convert_langchain_to_openai(lc_message) -> Dict[str, Any]:
"""
Convert LangChain message to OpenAI-compatible format.
@@ -126,7 +122,6 @@ def convert_langchain_to_openai(lc_message) -> Dict[str, Any]:
"content": str(lc_message)
}
-
def convert_openai_to_langchain(msg: Dict[str, Any]):
"""
Convert OpenAI-compatible format to LangChain message.
@@ -175,7 +170,6 @@ def convert_openai_to_langchain(msg: Dict[str, Any]):
# Fallback to HumanMessage for unknown roles
return HumanMessage(content=content)
-
def convert_stream_event_to_openai(event: Dict[str, Any]) -> Dict[str, Any]:
"""
Convert LangGraph streaming event to OpenAI-compatible format.
diff --git a/gns3server/agent/gns3_copilot/utils/parse_tool_content.py b/gns3server/agent/gns3_copilot/utils/parse_tool_content.py
index 5898df9e4..541de35c6 100644
--- a/gns3server/agent/gns3_copilot/utils/parse_tool_content.py
+++ b/gns3server/agent/gns3_copilot/utils/parse_tool_content.py
@@ -60,9 +60,6 @@ Standard Tool Response Format:
Author: Guobin Yue
"""
-This module is part of the GNS3-Copilot project.
-GitHub: https://github.com/yueguobin/gns3-copilot
-
import ast
import json
import logging
@@ -70,7 +67,6 @@ from typing import Any
logger = logging.getLogger(__name__)
-
def parse_tool_content(
content: str | dict | list | int | float | bool | None,
fallback_to_raw: bool = True,
@@ -227,7 +223,6 @@ def parse_tool_content(
logger.info("Returning error: %s", result)
return result
-
def format_tool_response(
content: str | dict | list | int | float | bool | None, indent: int = 2
) -> str:
@@ -277,7 +272,6 @@ def format_tool_response(
logger.info("format_tool_response returning error: %s", result)
return result
-
def normalize_tool_response(
response: dict | list | str,
tool_name: str = "unknown"
@@ -456,7 +450,6 @@ def normalize_tool_response(
"metadata": metadata
}
-
# Test function to verify the implementation
def _test_parse_tool_content() -> None:
"""Test function to verify parse_tool_content works correctly with all input types"""
@@ -515,6 +508,5 @@ def _test_parse_tool_content() -> None:
valid = "✗"
print(f"Format Test {i + 1}: {valid} Input: {repr(input_data)} -> {result}")
-
if __name__ == "__main__":
_test_parse_tool_content()