From ffe19eb23a1e12fef1589e2ac7a41564ac8fafde Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Wed, 15 Apr 2026 00:39:53 +0000 Subject: [PATCH] fix: handle empty ticker in MinIO storage paths, clean up debug log --- services/extractor/client.py | 6 ++++++ services/shared/storage.py | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/services/extractor/client.py b/services/extractor/client.py index 48c7f34..728c9ec 100644 --- a/services/extractor/client.py +++ b/services/extractor/client.py @@ -234,6 +234,12 @@ class OllamaClient: # the model to output plain text instead of valid JSON. # Omitting "think" lets the model use thinking mode (slightly # slower but structured output actually works). + "options": { + # Ollama defaults num_predict to 4096 which is consumed + # entirely by thinking tokens, leaving nothing for content. + # Set high enough for thinking + JSON output. + "num_predict": self._config.max_tokens, + }, } url = f"{self._config.base_url}/api/chat" diff --git a/services/shared/storage.py b/services/shared/storage.py index 7e8ed50..c7b27ff 100644 --- a/services/shared/storage.py +++ b/services/shared/storage.py @@ -267,8 +267,9 @@ def upload_extraction_prompt( Stores under extraction/{ticker}/{yyyy}/{mm}/{dd}/{document_id}/prompt.json """ ts = timestamp or datetime.now(timezone.utc) + safe_ticker = ticker or "_unknown" path = ( - f"extraction/{ticker}/{ts.year}/{ts.month:02d}/{ts.day:02d}/" + f"extraction/{safe_ticker}/{ts.year}/{ts.month:02d}/{ts.day:02d}/" f"{document_id}/prompt.json" ) return upload_artifact( @@ -291,8 +292,9 @@ def upload_extraction_raw_output( Stores under extraction/{ticker}/{yyyy}/{mm}/{dd}/{document_id}/raw_output_{attempt}.json """ ts = timestamp or datetime.now(timezone.utc) + safe_ticker = ticker or "_unknown" path = ( - f"extraction/{ticker}/{ts.year}/{ts.month:02d}/{ts.day:02d}/" + f"extraction/{safe_ticker}/{ts.year}/{ts.month:02d}/{ts.day:02d}/" f"{document_id}/raw_output_{attempt_index}.json" ) return upload_artifact( @@ -314,8 +316,9 @@ def upload_extraction_validation( Stores under extraction/{ticker}/{yyyy}/{mm}/{dd}/{document_id}/validation.json """ ts = timestamp or datetime.now(timezone.utc) + safe_ticker = ticker or "_unknown" path = ( - f"extraction/{ticker}/{ts.year}/{ts.month:02d}/{ts.day:02d}/" + f"extraction/{safe_ticker}/{ts.year}/{ts.month:02d}/{ts.day:02d}/" f"{document_id}/validation.json" ) return upload_artifact( @@ -337,8 +340,9 @@ def upload_extraction_intelligence( Stores under extraction/{ticker}/{yyyy}/{mm}/{dd}/{document_id}/intelligence.json """ ts = timestamp or datetime.now(timezone.utc) + safe_ticker = ticker or "_unknown" path = ( - f"extraction/{ticker}/{ts.year}/{ts.month:02d}/{ts.day:02d}/" + f"extraction/{safe_ticker}/{ts.year}/{ts.month:02d}/{ts.day:02d}/" f"{document_id}/intelligence.json" ) return upload_artifact(