fix: auto-fix code issues - duplicate imports and unused imports

- 移除函数内部的重复 import re
- 移除函数内部的重复 import csv
- 移除函数内部的重复 import random
- 移除未使用的 urllib.request 导入
- 添加缺失的 time 导入到 ai_manager.py
This commit is contained in:
OpenClaw Bot
2026-02-28 03:05:42 +08:00
parent a8fa805af4
commit 7853b2392b
6 changed files with 2 additions and 13 deletions

View File

@@ -8,14 +8,14 @@ AI 能力增强模块
- 预测性分析(趋势预测、异常检测) - 预测性分析(趋势预测、异常检测)
""" """
import re
import asyncio import asyncio
import json import json
import os import os
import random import random
import re
import sqlite3 import sqlite3
import statistics import statistics
import time
import uuid import uuid
from collections import defaultdict from collections import defaultdict
from dataclasses import dataclass from dataclasses import dataclass
@@ -430,8 +430,6 @@ class AIManager:
content = result["choices"][0]["message"]["content"] content = result["choices"][0]["message"]["content"]
# 解析 JSON # 解析 JSON
import re
json_match = re.search(r"\[.*?\]", content, re.DOTALL) json_match = re.search(r"\[.*?\]", content, re.DOTALL)
if json_match: if json_match:
try: try:
@@ -689,8 +687,6 @@ class AIManager:
self, rag_id: str, query: str, project_entities: list[dict], project_relations: list[dict] self, rag_id: str, query: str, project_entities: list[dict], project_relations: list[dict]
) -> RAGQuery: ) -> RAGQuery:
"""基于知识图谱的 RAG 查询""" """基于知识图谱的 RAG 查询"""
import time
start_time = time.time() start_time = time.time()
rag = self.get_kg_rag(rag_id) rag = self.get_kg_rag(rag_id)

View File

@@ -275,8 +275,6 @@ class ExportManager:
Returns: Returns:
CSV 字符串 CSV 字符串
""" """
import csv
output = io.StringIO() output = io.StringIO()
# 收集所有可能的属性列 # 收集所有可能的属性列

View File

@@ -115,8 +115,6 @@ class KnowledgeReasoner:
content = await self._call_llm(prompt, temperature=0.1) content = await self._call_llm(prompt, temperature=0.1)
import re
json_match = re.search(r"\{{.*?\}}", content, re.DOTALL) json_match = re.search(r"\{{.*?\}}", content, re.DOTALL)
if json_match: if json_match:
try: try:

View File

@@ -11,7 +11,6 @@ import json
import os import os
import sqlite3 import sqlite3
import time import time
import urllib.request
import uuid import uuid
from dataclasses import dataclass, field from dataclasses import dataclass, field
from datetime import datetime from datetime import datetime

View File

@@ -321,7 +321,6 @@ class TestOpsManager:
try: try:
# 记录历史指标数据 # 记录历史指标数据
import random
base_time = datetime.now() - timedelta(days=30) base_time = datetime.now() - timedelta(days=30)
for i in range(30): for i in range(30):
timestamp = (base_time + timedelta(days=i)).isoformat() timestamp = (base_time + timedelta(days=i)).isoformat()

View File

@@ -13,7 +13,6 @@ import asyncio
import base64 import base64
import hashlib import hashlib
import hmac import hmac
import urllib.request
import json import json
import logging import logging
import uuid import uuid