mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
feat(agent): update import paths for gns3_copilot modules
Updated import statements across multiple agent files to use absolute paths starting with `gns3server.agent.gns3_copilot` instead of relative `gns3_copilot` imports. This ensures proper module resolution within the gns3-server package structure and prevents import errors when the agent is executed from different contexts.
This commit is contained in:
1 parent
73de248381
commit
dde2a00c5b
17 files changed
+36
-28
No files matched your search
@@ -43,17 +43,17 @@ from typing_extensions import TypedDict
|
||||
|
||||
import logging
|
||||
|
||||
from gns3_copilot.agent.model_factory import (
|
||||
from gns3server.agent.gns3_copilot.agent.model_factory import (
|
||||
create_base_model_with_tools,
|
||||
create_title_model,
|
||||
)
|
||||
from gns3_copilot.gns3_client import GNS3TopologyTool
|
||||
from gns3_copilot.prompts import TITLE_PROMPT, load_system_prompt
|
||||
from gns3server.agent.gns3_copilot.gns3_client import GNS3TopologyTool
|
||||
from gns3server.agent.gns3_copilot.prompts import TITLE_PROMPT, load_system_prompt
|
||||
import sys
|
||||
from pathlib import Path
|
||||
# Add backend to path for prompt_manager
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent.parent.parent / "backend"))
|
||||
from gns3_copilot.tools_v2 import (
|
||||
from gns3server.agent.gns3_copilot.tools_v2 import (
|
||||
ExecuteMultipleDeviceCommands,
|
||||
GNS3CreateNodeTool,
|
||||
GNS3LinkTool,
|
||||
|
||||
@@ -12,7 +12,7 @@ from uuid import UUID
|
||||
|
||||
from langchain.chat_models import init_chat_model
|
||||
|
||||
from gns3_copilot.gns3_client import get_llm_config
|
||||
from gns3server.agent.gns3_copilot.gns3_client import get_llm_config
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import aiosqlite
|
||||
from langchain_core.messages import HumanMessage, AIMessage, ToolMessage
|
||||
from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
|
||||
|
||||
from gns3_copilot.agent.gns3_copilot import agent_builder
|
||||
from gns3server.agent.gns3_copilot.agent.gns3_copilot import agent_builder
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ Main Functions:
|
||||
get_gns3_connector: Create a Gns3Connector with JWT token
|
||||
|
||||
Example:
|
||||
from gns3_copilot.gns3_client import get_gns3_connector
|
||||
from gns3server.agent.gns3_copilot.gns3_client import get_gns3_connector
|
||||
|
||||
# Auto-detect URL from Controller or Config
|
||||
connector = get_gns3_connector(jwt_token="your_token")
|
||||
@@ -29,7 +29,7 @@ Authentication:
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from gns3_copilot.gns3_client.custom_gns3fy import Gns3Connector
|
||||
from gns3server.agent.gns3_copilot.gns3_client.custom_gns3fy import Gns3Connector
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -241,7 +241,7 @@ async def get_gns3_connector_with_llm_config(
|
||||
url = _detect_url_for_api()
|
||||
|
||||
# Step 3: Get LLM config
|
||||
from gns3_copilot.utils.llm_config_helper import get_user_llm_config
|
||||
from gns3server.agent.gns3_copilot.utils.llm_config_helper import get_user_llm_config
|
||||
|
||||
llm_config = await get_user_llm_config(
|
||||
user_id=user_id,
|
||||
@@ -316,7 +316,7 @@ def get_gns3_server_host() -> str:
|
||||
Hostname/IP address string
|
||||
|
||||
Example:
|
||||
from gns3_copilot.gns3_client import get_gns3_server_host
|
||||
from gns3server.agent.gns3_copilot.gns3_client import get_gns3_server_host
|
||||
|
||||
host = get_gns3_server_host()
|
||||
print(f"GNS3 server host: {host}")
|
||||
@@ -353,7 +353,7 @@ def get_llm_config(user_id, jwt_token: str) -> Optional[dict]:
|
||||
or None if not found.
|
||||
|
||||
Example:
|
||||
from gns3_copilot.gns3_client import get_llm_config
|
||||
from gns3server.agent.gns3_copilot.gns3_client import get_llm_config
|
||||
|
||||
config = get_llm_config(user_id, jwt_token)
|
||||
if config:
|
||||
@@ -372,7 +372,7 @@ def get_llm_config(user_id, jwt_token: str) -> Optional[dict]:
|
||||
url = _detect_url_for_api()
|
||||
|
||||
# Import the async helper
|
||||
from gns3_copilot.utils.llm_config_helper import get_user_llm_config
|
||||
from gns3server.agent.gns3_copilot.utils.llm_config_helper import get_user_llm_config
|
||||
|
||||
# Run async function in sync context
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
@@ -9,7 +9,7 @@ from typing import Any
|
||||
|
||||
from langchain.tools import BaseTool
|
||||
|
||||
from gns3_copilot.gns3_client import Project, get_gns3_connector
|
||||
from gns3server.agent.gns3_copilot.gns3_client import Project, get_gns3_connector
|
||||
|
||||
# Configure logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -8,7 +8,7 @@ import logging
|
||||
import os
|
||||
from typing import Any
|
||||
|
||||
from gns3_copilot.gns3_client import get_gns3_server_host
|
||||
from gns3server.agent.gns3_copilot.gns3_client import get_gns3_server_host
|
||||
|
||||
from langchain.tools import BaseTool
|
||||
from langchain_core.callbacks import CallbackManagerForToolRun
|
||||
@@ -18,7 +18,7 @@ from nornir.core import Nornir
|
||||
from nornir.core.task import AggregatedResult, Result, Task
|
||||
from nornir_netmiko.tasks import netmiko_send_config
|
||||
|
||||
from gns3_copilot.utils import get_device_ports_from_topology
|
||||
from gns3server.agent.gns3_copilot.utils import get_device_ports_from_topology
|
||||
|
||||
# config log
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -9,7 +9,7 @@ import os
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
from gns3_copilot.gns3_client import get_gns3_server_host
|
||||
from gns3server.agent.gns3_copilot.gns3_client import get_gns3_server_host
|
||||
|
||||
from langchain.tools import BaseTool
|
||||
from langchain_core.callbacks import CallbackManagerForToolRun
|
||||
@@ -19,7 +19,7 @@ from nornir.core import Nornir
|
||||
from nornir.core.task import AggregatedResult, Result, Task
|
||||
from nornir_netmiko.tasks import netmiko_multiline
|
||||
|
||||
from gns3_copilot.utils import get_device_ports_from_topology
|
||||
from gns3server.agent.gns3_copilot.utils import get_device_ports_from_topology
|
||||
|
||||
# config log
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -13,7 +13,7 @@ from typing import Any
|
||||
from langchain.tools import BaseTool
|
||||
from langchain_core.callbacks import CallbackManagerForToolRun
|
||||
|
||||
from gns3_copilot.gns3_client import Link, get_gns3_connector
|
||||
from gns3server.agent.gns3_copilot.gns3_client import Link, get_gns3_connector
|
||||
|
||||
# Configure logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -13,7 +13,7 @@ from typing import Any
|
||||
from langchain.tools import BaseTool
|
||||
from langchain_core.callbacks import CallbackManagerForToolRun
|
||||
|
||||
from gns3_copilot.gns3_client import Node, get_gns3_connector
|
||||
from gns3server.agent.gns3_copilot.gns3_client import Node, get_gns3_connector
|
||||
|
||||
# Configure logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -13,7 +13,7 @@ from typing import Any
|
||||
from langchain.tools import BaseTool
|
||||
from langchain_core.callbacks import CallbackManagerForToolRun
|
||||
|
||||
from gns3_copilot.gns3_client import get_gns3_connector
|
||||
from gns3server.agent.gns3_copilot.gns3_client import get_gns3_connector
|
||||
|
||||
# Configure logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -14,7 +14,7 @@ from typing import Any
|
||||
from langchain.tools import BaseTool
|
||||
from langchain_core.callbacks import CallbackManagerForToolRun
|
||||
|
||||
from gns3_copilot.gns3_client import Node, get_gns3_connector
|
||||
from gns3server.agent.gns3_copilot.gns3_client import Node, get_gns3_connector
|
||||
|
||||
# Configure logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -12,7 +12,7 @@ from typing import Any
|
||||
from langchain.tools import BaseTool
|
||||
from langchain_core.callbacks import CallbackManagerForToolRun
|
||||
|
||||
from gns3_copilot.gns3_client import Node, get_gns3_connector
|
||||
from gns3server.agent.gns3_copilot.gns3_client import Node, get_gns3_connector
|
||||
|
||||
# Configure logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -15,8 +15,8 @@ from langchain.tools import BaseTool
|
||||
from langchain_core.callbacks import CallbackManagerForToolRun
|
||||
from telnetlib3 import Telnet
|
||||
|
||||
from gns3_copilot.gns3_client import get_gns3_server_host
|
||||
from gns3_copilot.utils import get_device_ports_from_topology
|
||||
from gns3server.agent.gns3_copilot.gns3_client import get_gns3_server_host
|
||||
from gns3server.agent.gns3_copilot.utils import get_device_ports_from_topology
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ def get_device_ports_from_topology(
|
||||
|
||||
try:
|
||||
# Lazy import to avoid circular dependency
|
||||
from gns3_copilot.gns3_client import GNS3TopologyTool
|
||||
from gns3server.agent.gns3_copilot.gns3_client import GNS3TopologyTool
|
||||
|
||||
# Get topology information
|
||||
topo = GNS3TopologyTool()
|
||||
|
||||
@@ -11,7 +11,7 @@ This allows the copilot module to access API keys that are hidden from API respo
|
||||
while leveraging the API's default_config selection logic.
|
||||
|
||||
Usage:
|
||||
from gns3_copilot.utils.llm_config_helper import get_user_llm_config
|
||||
from gns3server.agent.gns3_copilot.utils.llm_config_helper import get_user_llm_config
|
||||
|
||||
# Get user's default LLM config (with API key)
|
||||
config = get_user_llm_config(user_id, jwt_token, gns3_url)
|
||||
@@ -232,7 +232,7 @@ def _detect_gns3_url() -> Optional[str]:
|
||||
GNS3 server URL, or None if detection failed
|
||||
"""
|
||||
try:
|
||||
from gns3_copilot.gns3_client.connector_factory import (
|
||||
from gns3server.agent.gns3_copilot.gns3_client.connector_factory import (
|
||||
_get_url_from_controller,
|
||||
_get_url_from_config,
|
||||
DEFAULT_GNS3_URL
|
||||
|
||||
Reference in new issue
Block a user