From ba1a7c216c8e9f9ab1dec0e5b44896d3342aab98 Mon Sep 17 00:00:00 2001 From: 3 Date: Wed, 9 Jul 2025 13:26:10 +0800 Subject: [PATCH] 1 --- .idea/AI-powered-switches.iml | 2 +- src/backend/.envExample | 11 ----------- src/backend/app/services/ai_services.py | 4 ++-- src/backend/config.py | 14 +++++++++----- src/backend/requirements.txt | 1 + 5 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 src/backend/.envExample diff --git a/.idea/AI-powered-switches.iml b/.idea/AI-powered-switches.iml index 7801d9e..61dc63f 100644 --- a/.idea/AI-powered-switches.iml +++ b/.idea/AI-powered-switches.iml @@ -9,7 +9,7 @@ - + diff --git a/src/backend/.envExample b/src/backend/.envExample deleted file mode 100644 index 9439543..0000000 --- a/src/backend/.envExample +++ /dev/null @@ -1,11 +0,0 @@ -# 硅基流动API配置 -SILICONFLOW_API_KEY=sk-114514 -SILICONFLOW_API_URL=https://api.siliconflow.ai/v1 - -# 交换机登录凭证 -SWITCH_USERNAME=admin -SWITCH_PASSWORD=your_switch_password -SWITCH_TIMEOUT=10 - -# 应用设置 -DEBUG=True diff --git a/src/backend/app/services/ai_services.py b/src/backend/app/services/ai_services.py index e4d0712..f023e6f 100644 --- a/src/backend/app/services/ai_services.py +++ b/src/backend/app/services/ai_services.py @@ -26,7 +26,7 @@ class AIService: """ data = { - "model": "text-davinci-003", + "model": "deepseek-ai/DeepSeek-V3", "prompt": prompt, "max_tokens": 1000, "temperature": 0.3 @@ -35,7 +35,7 @@ class AIService: try: async with httpx.AsyncClient() as client: response = await client.post( - f"{self.api_url}/completions", + f"{self.api_url}/chat/completions", headers=self.headers, json=data, timeout=30 diff --git a/src/backend/config.py b/src/backend/config.py index e79d088..2e2901c 100644 --- a/src/backend/config.py +++ b/src/backend/config.py @@ -1,26 +1,30 @@ from pydantic import BaseModel from pydantic_settings import BaseSettings from dotenv import load_dotenv +import os load_dotenv() -import os + class Settings(BaseSettings): APP_NAME: str = "AI Network Configurator" DEBUG: bool = True API_PREFIX: str = "/api" # 硅基流动API配置 - SILICONFLOW_API_KEY: str = os.getenv("SILICON_API_KEY", "") - SILICONFLOW_API_URL: str = os.getenv("SILICONFLOW_API_URL", "https://api.siliconflow.ai/v1") + SILICONFLOW_API_KEY: str = os.getenv("SILICONFLOW_API_KEY", "sk-mhzuedasunrgdrxfkcxmxgaypgjnxgodvvmrzzdbqrwtkqej") + SILICONFLOW_API_URL: str = os.getenv("SILICONFLOW_API_URL", "https://api.siliconflow.cn/v1") # 交换机配置 - SWITCH_USERNAME: str = os.getenv("SWITCH_USERNAME", "admin") - SWITCH_PASSWORD: str = os.getenv("SWITCH_PASSWORD", "admin") SWITCH_TIMEOUT: int = os.getenv("SWITCH_TIMEOUT", 10) + # eNSP配置 + ENSP_DEFAULT_IP: str = "172.17.99.201" + ENSP_DEFAULT_PORT: int = 2000 + class Config: env_file = ".env" + extra = "ignore" settings = Settings() \ No newline at end of file diff --git a/src/backend/requirements.txt b/src/backend/requirements.txt index 05abb1a..fc26dff 100644 --- a/src/backend/requirements.txt +++ b/src/backend/requirements.txt @@ -13,6 +13,7 @@ telnetlib3==2.0.3 httpx==0.27.0 python-nmap==0.7.1 + # 异步文件操作 -i https://pypi.tuna.tsinghua.edu.cn/simple aiofiles==23.2.1