critical_issues 섹션 정보 출력
This commit is contained in:
1 parent
35e5e98524
commit
484ee41810
4 files changed
+53
-3
No files matched your search
@@ -8,8 +8,8 @@ from common.db.run import select_run, update_run_report, update_run_plan
|
||||
from common.db.source import select_run_raw_data, select_run_mainpage_url
|
||||
from common.db.market import select_market
|
||||
from integrations.llm.llm_service import LLMService
|
||||
from integrations.llm.prompt import report_prompt, plan_prompt, youtube_diagnosis_prompt, brand_consistency_prompt
|
||||
from integrations.llm.schemas.report import ReportOutput, ClinicSnapshot, YouTubeAudit, BrandConsistencyOutput
|
||||
from integrations.llm.prompt import report_prompt, plan_prompt, youtube_diagnosis_prompt, brand_consistency_prompt, critical_issues_prompt
|
||||
from integrations.llm.schemas.report import ReportOutput, ClinicSnapshot, YouTubeAudit, BrandConsistencyOutput, CriticalIssuesOutput, DiagnosisItem
|
||||
from integrations.llm.schemas.plan import PlanOutput
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -208,6 +208,17 @@ async def _build_youtube_audit(youtube: dict) -> dict:
|
||||
return YouTubeAudit.model_validate(yt_patch).model_dump()
|
||||
|
||||
|
||||
async def _build_critical_issues(analysis_run_id: str, raw: dict) -> list[dict]:
|
||||
result: CriticalIssuesOutput = await LLMService(provider="perplexity").generate(
|
||||
critical_issues_prompt,
|
||||
{
|
||||
"clinic_name": (raw.get("mainpage") or {}).get("clinicName"),
|
||||
"data": json.dumps(raw, ensure_ascii=False),
|
||||
},
|
||||
)
|
||||
return [DiagnosisItem.model_validate(item).model_dump() for item in result.diagnosis]
|
||||
|
||||
|
||||
async def _build_overrides(analysis_run_id: str) -> dict:
|
||||
raw = await select_run_raw_data(analysis_run_id)
|
||||
if not raw:
|
||||
@@ -243,6 +254,7 @@ async def _build_overrides(analysis_run_id: str) -> dict:
|
||||
|
||||
brand = await generate_brand_consistency(analysis_run_id)
|
||||
brand_patch = brand.model_dump()["brand_inconsistencies"]
|
||||
critical_issues = await _build_critical_issues(analysis_run_id, raw)
|
||||
|
||||
fb_patch: dict = {}
|
||||
if fb_pages:
|
||||
@@ -259,6 +271,8 @@ async def _build_overrides(analysis_run_id: str) -> dict:
|
||||
overrides["facebook_audit"] = fb_patch
|
||||
if yt_patch:
|
||||
overrides["youtube_audit"] = yt_patch
|
||||
if critical_issues:
|
||||
overrides["problem_diagnosis"] = critical_issues
|
||||
return overrides
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user