fix: auto-fix code issues (cron)
- 修复PEP8格式问题(行长度超过120字符) - 修复类型注解(添加__init__和_get_db返回类型) - 删除__pycache__缓存文件 - 优化长SQL查询语句格式
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -204,14 +204,14 @@ class SmartSummary:
|
||||
class AIManager:
|
||||
"""AI 能力管理主类"""
|
||||
|
||||
def __init__(self, db_path: str = DB_PATH):
|
||||
def __init__(self, db_path: str = DB_PATH) -> None:
|
||||
self.db_path = db_path
|
||||
self.kimi_api_key = os.getenv("KIMI_API_KEY", "")
|
||||
self.kimi_base_url = os.getenv("KIMI_BASE_URL", "https://api.kimi.com/coding")
|
||||
self.openai_api_key = os.getenv("OPENAI_API_KEY", "")
|
||||
self.anthropic_api_key = os.getenv("ANTHROPIC_API_KEY", "")
|
||||
|
||||
def _get_db(self) -> None:
|
||||
def _get_db(self) -> sqlite3.Connection:
|
||||
"""获取数据库连接"""
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
conn.row_factory = sqlite3.Row
|
||||
|
||||
@@ -47,7 +47,7 @@ class ApiKeyManager:
|
||||
KEY_PREFIX = "ak_live_"
|
||||
KEY_LENGTH = 48 # 总长度: 前缀(8) + 随机部分(40)
|
||||
|
||||
def __init__(self, db_path: str = DB_PATH):
|
||||
def __init__(self, db_path: str = DB_PATH) -> None:
|
||||
self.db_path = db_path
|
||||
self._init_db()
|
||||
|
||||
|
||||
@@ -167,7 +167,8 @@ class DatabaseManager:
|
||||
def create_entity(self, entity: Entity) -> Entity:
|
||||
conn = self.get_conn()
|
||||
conn.execute(
|
||||
"""INSERT INTO entities (id, project_id, name, canonical_name, type, definition, aliases, created_at, updated_at)
|
||||
"""INSERT INTO entities (id, project_id, name, canonical_name, type,
|
||||
definition, aliases, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
entity.id,
|
||||
@@ -736,7 +737,8 @@ class DatabaseManager:
|
||||
now = datetime.now().isoformat()
|
||||
conn.execute(
|
||||
"""INSERT INTO attribute_templates
|
||||
(id, project_id, name, type, options, default_value, description, is_required, sort_order, created_at, updated_at)
|
||||
(id, project_id, name, type, options, default_value, description,
|
||||
is_required, sort_order, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
template.id,
|
||||
|
||||
@@ -980,12 +980,14 @@ class DeveloperEcosystemManager:
|
||||
"""
|
||||
INSERT INTO plugin_market
|
||||
(id, name, description, category, tags, author_id, author_name, status,
|
||||
price, currency, pricing_model, preview_image_url, demo_url, documentation_url,
|
||||
repository_url, download_url, webhook_url, permissions, install_count,
|
||||
active_install_count, rating, rating_count, review_count, version,
|
||||
min_platform_version, file_size, checksum, created_at, updated_at,
|
||||
published_at, reviewed_by, reviewed_at, review_notes)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
price, currency, pricing_model, preview_image_url, demo_url,
|
||||
documentation_url, repository_url, download_url, webhook_url,
|
||||
permissions, install_count, active_install_count, rating,
|
||||
rating_count, review_count, version, min_platform_version,
|
||||
file_size, checksum, created_at, updated_at, published_at,
|
||||
reviewed_by, reviewed_at, review_notes)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
plugin.id,
|
||||
|
||||
@@ -1003,7 +1003,11 @@ class EnterpriseManager:
|
||||
def _generate_self_signed_cert(self) -> str:
|
||||
"""生成自签名证书(简化实现)"""
|
||||
# 实际应该使用 cryptography 库生成
|
||||
return "MIICpDCCAYwCCQDU+pQ4nEHXqzANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDDAlsb2NhbGhvc3QwHhcNMjQwMTAxMDAwMDAwWhcNMjUwMTAxMDAwMDAwWjAUMRIwEAYDVQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC..."
|
||||
return (
|
||||
"MIICpDCCAYwCCQDU+pQ4nEHXqzANBgkqhkiG9w0BAQsFADAUMRIwEAYDVQQDDAlsb2NhbGhvc3Qw"
|
||||
"HhcNMjQwMTAxMDAwMDAwWhcNMjUwMTAxMDAwMDAwWjAUMRIwEAYDVQQDDAlsb2NhbGhvc3QwggEi"
|
||||
"MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC..."
|
||||
)
|
||||
|
||||
# ==================== SCIM 用户目录同步 ====================
|
||||
|
||||
|
||||
@@ -121,14 +121,17 @@ class ExportManager:
|
||||
|
||||
# 生成 SVG
|
||||
svg_parts = [
|
||||
f'<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}">',
|
||||
f'<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" '
|
||||
f'viewBox="0 0 {width} {height}">',
|
||||
"<defs>",
|
||||
' <marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">',
|
||||
' <marker id="arrowhead" markerWidth="10" markerHeight="7" '
|
||||
'refX="9" refY="3.5" orient="auto">',
|
||||
' <polygon points="0 0, 10 3.5, 0 7" fill="#7f8c8d"/>',
|
||||
" </marker>",
|
||||
"</defs>",
|
||||
f'<rect width="{width}" height="{height}" fill="#f8f9fa"/>',
|
||||
f'<text x="{center_x}" y="30" text-anchor="middle" font-size="20" font-weight="bold" fill="#2c3e50">知识图谱 - {project_id}</text>',
|
||||
f'<text x="{center_x}" y="30" text-anchor="middle" font-size="20" '
|
||||
f'font-weight="bold" fill="#2c3e50">知识图谱 - {project_id}</text>',
|
||||
]
|
||||
|
||||
# 绘制关系连线
|
||||
@@ -440,7 +443,10 @@ class ExportManager:
|
||||
story.append(Paragraph("InsightFlow 项目报告", title_style))
|
||||
story.append(Paragraph(f"项目名称: {project_name}", styles["Heading2"]))
|
||||
story.append(
|
||||
Paragraph(f"生成时间: {datetime.now().strftime('%Y-%m-%d %H:%M')}", styles["Normal"])
|
||||
Paragraph(
|
||||
f"生成时间: {datetime.now().strftime('%Y-%m-%d %H:%M')}",
|
||||
styles["Normal"],
|
||||
)
|
||||
)
|
||||
story.append(Spacer(1, 0.3 * inch))
|
||||
|
||||
|
||||
@@ -119,18 +119,23 @@ class LLMClient:
|
||||
文本:{text[:3000]}
|
||||
|
||||
要求:
|
||||
1. entities: 每个实体包含 name(名称), type(类型: PROJECT/TECH/PERSON/ORG/OTHER), definition(一句话定义), confidence(置信度0-1)
|
||||
2. relations: 每个关系包含 source(源实体名), target(目标实体名), type(关系类型: belongs_to/works_with/depends_on/mentions/related), confidence(置信度0-1)
|
||||
1. entities: 每个实体包含 name(名称), type(类型: PROJECT/TECH/PERSON/ORG/OTHER),
|
||||
definition(一句话定义), confidence(置信度0-1)
|
||||
2. relations: 每个关系包含 source(源实体名), target(目标实体名),
|
||||
type(关系类型: belongs_to/works_with/depends_on/mentions/related), confidence(置信度0-1)
|
||||
3. 只返回 JSON 对象,格式: {{"entities": [...], "relations": [...]}}
|
||||
|
||||
示例:
|
||||
{{
|
||||
"entities": [
|
||||
{{"name": "Project Alpha", "type": "PROJECT", "definition": "核心项目", "confidence": 0.95}},
|
||||
{{"name": "K8s", "type": "TECH", "definition": "Kubernetes容器编排平台", "confidence": 0.88}}
|
||||
{{"name": "Project Alpha", "type": "PROJECT", "definition": "核心项目",
|
||||
"confidence": 0.95}},
|
||||
{{"name": "K8s", "type": "TECH", "definition": "Kubernetes容器编排平台",
|
||||
"confidence": 0.88}}
|
||||
],
|
||||
"relations": [
|
||||
{{"source": "Project Alpha", "target": "K8s", "type": "depends_on", "confidence": 0.82}}
|
||||
{{"source": "Project Alpha", "target": "K8s", "type": "depends_on",
|
||||
"confidence": 0.82}}
|
||||
]
|
||||
}}"""
|
||||
|
||||
|
||||
@@ -917,7 +917,8 @@ class LocalizationManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT OR IGNORE INTO localized_payment_methods
|
||||
(id, provider, name, name_local, supported_countries, supported_currencies, is_active, display_order)
|
||||
(id, provider, name, name_local, supported_countries,
|
||||
supported_currencies, is_active, display_order)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
@@ -1001,10 +1002,14 @@ class LocalizationManager:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO translations (id, key, language, value, namespace, context, created_at, updated_at)
|
||||
INSERT INTO translations
|
||||
(id, key, language, value, namespace, context, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(key, language, namespace) DO UPDATE SET
|
||||
value = excluded.value, context = excluded.context, updated_at = excluded.updated_at, is_reviewed = 0
|
||||
value = excluded.value,
|
||||
context = excluded.context,
|
||||
updated_at = excluded.updated_at,
|
||||
is_reviewed = 0
|
||||
""",
|
||||
(translation_id, key, language, value, namespace, context, now, now),
|
||||
)
|
||||
@@ -1186,11 +1191,15 @@ class LocalizationManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
INSERT INTO tenant_data_center_mappings
|
||||
(id, tenant_id, primary_dc_id, secondary_dc_id, region_code, data_residency, created_at, updated_at)
|
||||
(id, tenant_id, primary_dc_id, secondary_dc_id, region_code,
|
||||
data_residency, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(tenant_id) DO UPDATE SET
|
||||
primary_dc_id = excluded.primary_dc_id, secondary_dc_id = excluded.secondary_dc_id,
|
||||
region_code = excluded.region_code, data_residency = excluded.data_residency, updated_at = excluded.updated_at
|
||||
primary_dc_id = excluded.primary_dc_id,
|
||||
secondary_dc_id = excluded.secondary_dc_id,
|
||||
region_code = excluded.region_code,
|
||||
data_residency = excluded.data_residency,
|
||||
updated_at = excluded.updated_at
|
||||
""",
|
||||
(
|
||||
mapping_id,
|
||||
|
||||
@@ -4880,7 +4880,8 @@ async def get_multimodal_stats_endpoint(project_id: str, _=Depends(verify_api_ke
|
||||
|
||||
# 统计跨模态关联
|
||||
cross_modal_count = conn.execute(
|
||||
"SELECT COUNT(*) as count FROM multimodal_entity_links WHERE entity_id IN (SELECT id FROM entities WHERE project_id = ?)",
|
||||
"""SELECT COUNT(*) as count FROM multimodal_entity_links
|
||||
WHERE entity_id IN (SELECT id FROM entities WHERE project_id = ?)""",
|
||||
(project_id,),
|
||||
).fetchone()["count"]
|
||||
|
||||
|
||||
@@ -973,7 +973,12 @@ class OpsManager:
|
||||
"tag": "div",
|
||||
"text": {
|
||||
"tag": "lark_md",
|
||||
"content": f"**描述:** {alert.description}\n\n**指标:** {alert.metric}\n**当前值:** {alert.value}\n**阈值:** {alert.threshold}",
|
||||
"content": (
|
||||
f"**描述:** {alert.description}\n\n"
|
||||
f"**指标:** {alert.metric}\n"
|
||||
f"**当前值:** {alert.value}\n"
|
||||
f"**阈值:** {alert.threshold}"
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user