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:
@@ -0,0 +1,62 @@
|
||||
"""Deterministic mock search provider - the default (`SEARCH_PROVIDER=mock`)
|
||||
and what every automated test runs against. Never calls a network.
|
||||
|
||||
Unlike `MockLLMProvider` (which fabricates plausible-looking structured
|
||||
output from real evidence), this provider has no real evidence to work
|
||||
from - a company name alone isn't enough to honestly guess an industry,
|
||||
headquarters, or competitor list. So except for the one query type where a
|
||||
name-derived guess is genuinely meaningful (official website - many
|
||||
companies really do live at a domain close to their name), every other
|
||||
query honestly reports "no information available" as its snippet text.
|
||||
That honesty flows through `discovery_service.py` and the company-profile
|
||||
LLM task: fields with no real evidence come back `None`/`[]`, and the
|
||||
wizard's Review step shows them as "not found - fill in yourself" rather
|
||||
than presenting fabricated data as fact.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
from app.search.base import SearchResult
|
||||
|
||||
_DOMAIN_STRIP_RE = re.compile(r"[^a-z0-9]+")
|
||||
_WEBSITE_SUFFIX = " official website"
|
||||
|
||||
|
||||
def _guess_domain(name: str) -> str:
|
||||
slug = _DOMAIN_STRIP_RE.sub("", name.lower())
|
||||
return f"{slug}.com" if slug else "example.com"
|
||||
|
||||
|
||||
class MockSearchProvider:
|
||||
provider_name = "mock"
|
||||
|
||||
async def search(self, query: str, *, count: int = 5) -> list[SearchResult]:
|
||||
if query.lower().endswith(_WEBSITE_SUFFIX):
|
||||
name = query[: -len(_WEBSITE_SUFFIX)]
|
||||
domain = _guess_domain(name)
|
||||
results = [
|
||||
SearchResult(
|
||||
title=f"{name} - Official Site",
|
||||
url=f"https://{domain}",
|
||||
snippet=(
|
||||
f"A likely official website for {name}, guessed from its name. "
|
||||
"Mock search - no real web search performed; set SEARCH_PROVIDER=brave "
|
||||
"for real results."
|
||||
),
|
||||
)
|
||||
]
|
||||
else:
|
||||
results = [
|
||||
SearchResult(
|
||||
title=f"Mock search: {query}",
|
||||
url="https://example.com/mock-search",
|
||||
snippet=(
|
||||
"No information available - SEARCH_PROVIDER=mock is the dev/test "
|
||||
"default and performs no real web search. Set SEARCH_PROVIDER=brave "
|
||||
"for real discovery."
|
||||
),
|
||||
)
|
||||
]
|
||||
return results[:count]
|
||||
Reference in New Issue
Block a user