Initial commit: CI Agent competitive-intelligence monitoring app

FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring,
source collection, LLM-based change analysis, enrichment, and account
security (Turnstile, escalating lockout, email verification).
This commit is contained in:
2026-08-05 10:48:20 -04:00
commit 1a4c80958f
365 changed files with 43541 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
"""Task A: document relevance. Decides whether a collected document is
actually about the target company and matches the user's stated focus,
before it's used as evidence for anything else."""
from __future__ import annotations
from pydantic import BaseModel, Field
from app.analysis.llm.base import LLMProvider
from app.prompts.base import build_user_prompt
SYSTEM_PROMPT = (
"You are a competitive intelligence analyst. Given a single document and a company "
"profile, judge only whether the document is genuinely about that company and whether "
"it relates to the user's stated monitoring focus. Do not summarize the document's "
"content here - a later task does that. Be conservative: if the document could be about "
"a different company with a similar name, say so."
)
class RelevanceAssessment(BaseModel):
is_relevant: bool = Field(description="Is this document genuinely about the target company?")
matches_focus: bool = Field(description="Does it relate to the user's stated monitoring focus?")
topic_categories: list[str] = Field(default_factory=list)
source_reliability: float = Field(ge=0.0, le=1.0)
reasoning: str
async def assess_relevance(
llm: LLMProvider,
*,
company_name: str,
company_aliases: list[str],
monitoring_focus: str | None,
document_title: str | None,
document_text: str,
document_url: str,
) -> RelevanceAssessment:
evidence = {
"company_name": company_name,
"company_aliases": company_aliases,
"monitoring_focus": monitoring_focus,
"document_title": document_title,
"document_url": document_url,
"document_text": document_text[:4000],
}
user_prompt = build_user_prompt(
"Assess whether this document is about the target company and matches its monitoring focus.",
evidence,
)
return await llm.generate_structured(SYSTEM_PROMPT, user_prompt, RelevanceAssessment)