phase 17: pass all tracked tickers to extractor, soften prompt for macro-to-company relevance

This commit is contained in:
Celes Renata
2026-04-12 09:18:08 -07:00
parent 59f89d03d2
commit 57d0fc7d33
6 changed files with 142 additions and 4 deletions
+3 -1
View File
@@ -88,10 +88,12 @@ async def main() -> None:
company_id_map = await _build_company_id_map(pool)
try:
# Pass all tracked tickers so the model can identify any mentioned companies
all_tickers = list(company_id_map.keys()) if company_id_map else ([ticker] if ticker else None)
extraction_response = await ollama.extract(
text,
document_id=document_id,
known_tickers=[ticker] if ticker else None,
known_tickers=all_tickers,
)
result = await persist_extraction(
pool=pool,
+6 -3
View File
@@ -102,9 +102,12 @@ def build_extraction_prompt(
if known_tickers:
tickers_str = ", ".join(known_tickers)
ticker_hint = (
f"\nThe following tickers may be referenced in this document: {tickers_str}\n"
"Only include a ticker in your output if the document actually discusses that company. "
"Do NOT include a ticker just because it appears in this hint."
f"\nTracked tickers: {tickers_str}\n"
"If the document discusses market conditions, sectors, or themes that directly affect "
"any of these companies, include those companies with appropriate sentiment and impact scores. "
"A macro article about oil prices IS relevant to energy companies like XOM. "
"A tech sector article IS relevant to AAPL, MSFT, NVDA, etc. "
"Use your judgment — but only include companies where the connection is clear from the text."
)
schema_str = json.dumps(EXTRACTION_JSON_SCHEMA, indent=2)