refactor: parallel LLM analysis via asyncio.gather instead of sequential
This commit is contained in:
@@ -228,12 +228,15 @@ async def _run_llm_analysis(findings: list[Finding], session: AsyncSession) -> l
|
|||||||
await session.commit()
|
await session.commit()
|
||||||
|
|
||||||
reports = []
|
reports = []
|
||||||
for finding in findings:
|
|
||||||
|
async def _analyze_one(finding):
|
||||||
report = await analyze_finding(finding.data)
|
report = await analyze_finding(finding.data)
|
||||||
if report:
|
if report:
|
||||||
finding.report = report
|
finding.report = report
|
||||||
reports.append(report)
|
reports.append(report)
|
||||||
else:
|
else:
|
||||||
finding.report = None
|
finding.report = None
|
||||||
|
|
||||||
|
await asyncio.gather(*(_analyze_one(f) for f in findings))
|
||||||
await session.commit()
|
await session.commit()
|
||||||
return reports
|
return reports
|
||||||
|
|||||||
Reference in New Issue
Block a user