fix: auto-fix code issues (cron)
- 修复重复导入/字段 (llm_client.py 中的重复注释) - 修复PEP8格式问题 (E501行长度超过100字符) - 修复多行SQL语句和字符串格式化 - 修复f-string过长问题 涉及文件: - backend/developer_ecosystem_manager.py - backend/document_processor.py - backend/enterprise_manager.py - backend/export_manager.py - backend/growth_manager.py - backend/llm_client.py - backend/localization_manager.py - backend/main.py - backend/neo4j_manager.py - backend/ops_manager.py - backend/performance_manager.py - backend/plugin_manager.py - backend/search_manager.py - backend/security_manager.py - backend/subscription_manager.py - backend/tenant_manager.py - backend/test_phase8_task6.py - backend/test_phase8_task8.py - backend/tingwu_client.py - backend/workflow_manager.py
This commit is contained in:
@@ -1250,8 +1250,10 @@ def extract_entities_with_llm(text: str) -> tuple[list[dict], list[dict]]:
|
||||
文本:{text[:3000]}
|
||||
|
||||
要求:
|
||||
1. entities: 每个实体包含 name(名称), type(类型: PROJECT/TECH/PERSON/ORG/OTHER), definition(一句话定义)
|
||||
2. relations: 每个关系包含 source(源实体名), target(目标实体名), type(关系类型: belongs_to/works_with/depends_on/mentions/related)
|
||||
1. entities: 每个实体包含 name(名称), type(类型: PROJECT/TECH/PERSON/ORG/OTHER),
|
||||
definition(一句话定义)
|
||||
2. relations: 每个关系包含 source(源实体名), target(目标实体名),
|
||||
type(关系类型: belongs_to/works_with/depends_on/mentions/related)
|
||||
3. 只返回 JSON 对象,格式: {{"entities": [...], "relations": [...]}}
|
||||
|
||||
示例:
|
||||
@@ -2053,7 +2055,8 @@ async def agent_suggest(project_id: str, _=Depends(verify_api_key)):
|
||||
2. 建议的操作(如合并相似实体、补充定义等)
|
||||
3. 值得关注的关键信息
|
||||
|
||||
返回 JSON 格式:{{"suggestions": [{{"type": "insight|action", "title": "...", "description": "..."}}]}}"""
|
||||
返回 JSON 格式:{{"suggestions": [{{"type": "insight|action", "title": "...",
|
||||
"description": "..."}}]}}"""
|
||||
|
||||
messages = [ChatMessage(role="user", content=prompt)]
|
||||
content = await llm.chat(messages, temperature=0.3)
|
||||
@@ -2593,7 +2596,8 @@ async def set_entity_attribute_endpoint(
|
||||
# 记录历史
|
||||
conn.execute(
|
||||
"""INSERT INTO attribute_history
|
||||
(id, entity_id, attribute_name, old_value, new_value, changed_by, changed_at, change_reason)
|
||||
(id, entity_id, attribute_name, old_value, new_value,
|
||||
changed_by, changed_at, change_reason)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
str(uuid.uuid4())[:UUID_LENGTH],
|
||||
@@ -2628,7 +2632,8 @@ async def set_entity_attribute_endpoint(
|
||||
# 记录历史
|
||||
conn.execute(
|
||||
"""INSERT INTO attribute_history
|
||||
(id, entity_id, attribute_name, old_value, new_value, changed_by, changed_at, change_reason)
|
||||
(id, entity_id, attribute_name, old_value, new_value,
|
||||
changed_by, changed_at, change_reason)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
str(uuid.uuid4())[:UUID_LENGTH],
|
||||
@@ -3292,7 +3297,9 @@ async def export_transcript_markdown_endpoint(transcript_id: str, _=Depends(veri
|
||||
io.BytesIO(markdown_content.encode("utf-8")),
|
||||
media_type="text/markdown",
|
||||
headers={
|
||||
"Content-Disposition": f"attachment; filename=insightflow-transcript-{transcript_id}.md",
|
||||
"Content-Disposition": (
|
||||
f"attachment; filename=insightflow-transcript-{transcript_id}.md"
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -3395,7 +3402,9 @@ async def neo4j_sync_project(request: Neo4jSyncRequest, _=Depends(verify_api_key
|
||||
"project_id": request.project_id,
|
||||
"entities_synced": len(entities_data),
|
||||
"relations_synced": len(relations_data),
|
||||
"message": f"Synced {len(entities_data)} entities and {len(relations_data)} relations to Neo4j",
|
||||
"message": (
|
||||
f"Synced {len(entities_data)} entities and {len(relations_data)} relations to Neo4j"
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -4516,7 +4525,8 @@ async def upload_video_endpoint(
|
||||
for frame in result.frames:
|
||||
conn.execute(
|
||||
"""INSERT INTO video_frames
|
||||
(id, video_id, frame_number, timestamp, image_url, ocr_text, extracted_entities, created_at)
|
||||
(id, video_id, frame_number, timestamp, image_url, ocr_text,
|
||||
extracted_entities, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
frame.id,
|
||||
@@ -4560,7 +4570,8 @@ async def upload_video_endpoint(
|
||||
conn = db.get_conn()
|
||||
conn.execute(
|
||||
"""INSERT OR REPLACE INTO multimodal_mentions
|
||||
(id, project_id, entity_id, modality, source_id, source_type, text_snippet, confidence, created_at)
|
||||
(id, project_id, entity_id, modality, source_id, source_type,
|
||||
text_snippet, confidence, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
str(uuid.uuid4())[:UUID_LENGTH],
|
||||
@@ -4718,7 +4729,8 @@ async def upload_image_endpoint(
|
||||
conn = db.get_conn()
|
||||
conn.execute(
|
||||
"""INSERT OR REPLACE INTO multimodal_mentions
|
||||
(id, project_id, entity_id, modality, source_id, source_type, text_snippet, confidence, created_at)
|
||||
(id, project_id, entity_id, modality, source_id, source_type,
|
||||
text_snippet, confidence, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
str(uuid.uuid4())[:UUID_LENGTH],
|
||||
@@ -4925,7 +4937,8 @@ async def align_multimodal_entities_endpoint(
|
||||
for link in links:
|
||||
conn.execute(
|
||||
"""INSERT OR REPLACE INTO multimodal_entity_links
|
||||
(id, entity_id, linked_entity_id, link_type, confidence, evidence, modalities, created_at)
|
||||
(id, entity_id, linked_entity_id, link_type, confidence,
|
||||
evidence, modalities, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(
|
||||
link.id,
|
||||
@@ -5012,7 +5025,8 @@ async def get_multimodal_stats_endpoint(project_id: str, _=Depends(verify_api_ke
|
||||
modality_dist = {}
|
||||
for modality in ["audio", "video", "image", "document"]:
|
||||
count = conn.execute(
|
||||
"SELECT COUNT(*) as count FROM multimodal_mentions WHERE project_id = ? AND modality = ?",
|
||||
"""SELECT COUNT(*) as count FROM multimodal_mentions
|
||||
WHERE project_id = ? AND modality = ?""",
|
||||
(project_id, modality),
|
||||
).fetchone()["count"]
|
||||
modality_dist[modality] = count
|
||||
@@ -5300,7 +5314,10 @@ class PluginCreate(BaseModel):
|
||||
name: str = Field(..., description="插件名称")
|
||||
plugin_type: str = Field(
|
||||
...,
|
||||
description="插件类型: chrome_extension, feishu_bot, dingtalk_bot, zapier, make, webdav, custom",
|
||||
description=(
|
||||
"插件类型: chrome_extension, feishu_bot, dingtalk_bot, "
|
||||
"zapier, make, webdav, custom"
|
||||
),
|
||||
)
|
||||
project_id: str = Field(..., description="关联项目ID")
|
||||
config: dict = Field(default_factory=dict, description="插件配置")
|
||||
|
||||
Reference in New Issue
Block a user