From b3fa8edf60f24f1e0fc3d4f923f367757c070581 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Thu, 10 Oct 2024 18:31:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20cmd.risk-analyze?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cucyuqing/cmd/risk-analyze.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cucyuqing/cmd/risk-analyze.py b/cucyuqing/cmd/risk-analyze.py index ac7c5a4..4d2ebe9 100644 --- a/cucyuqing/cmd/risk-analyze.py +++ b/cucyuqing/cmd/risk-analyze.py @@ -10,19 +10,16 @@ from cucyuqing.utils import print from cucyuqing.config import OPENAI_RISK_LLM_API_KEY, OPENAI_RISK_LLM_BASE_URL from cucyuqing.pg import pool, get_cur from cucyuqing.mysql import mysql +from cucyuqing.dbscan import run_dbscan async def main(): await pool.open() - print(await batch_risk_analyze(["你是老师", "我是初音未来"])) - -async def get_docs() -> list[dict]: - # [TODO] - raise NotImplemented - await mysql.execute(""" - """) - return [] - + dbscan_result = await run_dbscan() + docs = [cluster[0] for cluster in dbscan_result.clusters] + analyze_rusult = await batch_risk_analyze([doc.title for doc in docs]) + for result, doc in zip(analyze_rusult, docs): + print(f"风险: {result} 标题: {doc.title}") async def batch_risk_analyze(