fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解
This commit is contained in:
@@ -291,7 +291,7 @@ class AIManager:
|
||||
return self._row_to_custom_model(row)
|
||||
|
||||
def list_custom_models(
|
||||
self, tenant_id: str, model_type: ModelType | None = None, status: ModelStatus | None = None
|
||||
self, tenant_id: str, model_type: ModelType | None = None, status: ModelStatus | None = None,
|
||||
) -> list[CustomModel]:
|
||||
"""列出自定义模型"""
|
||||
query = "SELECT * FROM custom_models WHERE tenant_id = ?"
|
||||
@@ -311,7 +311,7 @@ class AIManager:
|
||||
return [self._row_to_custom_model(row) for row in rows]
|
||||
|
||||
def add_training_sample(
|
||||
self, model_id: str, text: str, entities: list[dict], metadata: dict = None
|
||||
self, model_id: str, text: str, entities: list[dict], metadata: dict = None,
|
||||
) -> TrainingSample:
|
||||
"""添加训练样本"""
|
||||
sample_id = f"ts_{uuid.uuid4().hex[:16]}"
|
||||
@@ -638,7 +638,7 @@ class AIManager:
|
||||
}
|
||||
|
||||
def get_multimodal_analyses(
|
||||
self, tenant_id: str, project_id: str | None = None
|
||||
self, tenant_id: str, project_id: str | None = None,
|
||||
) -> list[MultimodalAnalysis]:
|
||||
"""获取多模态分析历史"""
|
||||
query = "SELECT * FROM multimodal_analyses WHERE tenant_id = ?"
|
||||
@@ -721,7 +721,7 @@ class AIManager:
|
||||
return self._row_to_kg_rag(row)
|
||||
|
||||
def list_kg_rags(
|
||||
self, tenant_id: str, project_id: str | None = None
|
||||
self, tenant_id: str, project_id: str | None = None,
|
||||
) -> list[KnowledgeGraphRAG]:
|
||||
"""列出知识图谱 RAG 配置"""
|
||||
query = "SELECT * FROM kg_rag_configs WHERE tenant_id = ?"
|
||||
@@ -738,7 +738,7 @@ class AIManager:
|
||||
return [self._row_to_kg_rag(row) for row in rows]
|
||||
|
||||
async def query_kg_rag(
|
||||
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:
|
||||
"""基于知识图谱的 RAG 查询"""
|
||||
start_time = time.time()
|
||||
@@ -1123,7 +1123,7 @@ class AIManager:
|
||||
"""获取预测模型"""
|
||||
with self._get_db() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT * FROM prediction_models WHERE id = ?", (model_id,)
|
||||
"SELECT * FROM prediction_models WHERE id = ?", (model_id,),
|
||||
).fetchone()
|
||||
|
||||
if not row:
|
||||
@@ -1132,7 +1132,7 @@ class AIManager:
|
||||
return self._row_to_prediction_model(row)
|
||||
|
||||
def list_prediction_models(
|
||||
self, tenant_id: str, project_id: str | None = None
|
||||
self, tenant_id: str, project_id: str | None = None,
|
||||
) -> list[PredictionModel]:
|
||||
"""列出预测模型"""
|
||||
query = "SELECT * FROM prediction_models WHERE tenant_id = ?"
|
||||
@@ -1149,7 +1149,7 @@ class AIManager:
|
||||
return [self._row_to_prediction_model(row) for row in rows]
|
||||
|
||||
async def train_prediction_model(
|
||||
self, model_id: str, historical_data: list[dict]
|
||||
self, model_id: str, historical_data: list[dict],
|
||||
) -> PredictionModel:
|
||||
"""训练预测模型"""
|
||||
model = self.get_prediction_model(model_id)
|
||||
@@ -1369,7 +1369,7 @@ class AIManager:
|
||||
predicted_relations = [
|
||||
{"type": rel_type, "likelihood": min(count / len(relation_history), 0.95)}
|
||||
for rel_type, count in sorted(
|
||||
relation_counts.items(), key=lambda x: x[1], reverse=True
|
||||
relation_counts.items(), key=lambda x: x[1], reverse=True,
|
||||
)[:5]
|
||||
]
|
||||
|
||||
@@ -1394,7 +1394,7 @@ class AIManager:
|
||||
return [self._row_to_prediction_result(row) for row in rows]
|
||||
|
||||
def update_prediction_feedback(
|
||||
self, prediction_id: str, actual_value: str, is_correct: bool
|
||||
self, prediction_id: str, actual_value: str, is_correct: bool,
|
||||
) -> None:
|
||||
"""更新预测反馈(用于模型改进)"""
|
||||
with self._get_db() as conn:
|
||||
|
||||
Reference in New Issue
Block a user