Skip to content

Commit c83559d

Browse files
committed
refactor tools and move calculations for portfolio analysis to a dedicated calculations module
1 parent ef50a03 commit c83559d

27 files changed

+2604
-2386
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Flight operator metadata can be extended by copying `config/flight_operators.exa
284284

285285
### AI Assistant (Draft)
286286

287-
The assistant module is in progress. The API endpoint (`/api/assistant/query`) currently supports a limited rules-based summarizer; unsupported modes/questions return an explicit "not implemented" response. UI/CLI chat surfaces are planned. See `docs/ai_assistant.md` for the draft plan.
287+
The assistant module is in progress. The API endpoint (`/api/assistant/query`) currently supports a limited rules-based summarizer; unsupported modes/questions return a 501 response with an explicit "not implemented" payload and `meta` warnings. UI/CLI chat surfaces are planned. See `docs/ai_assistant.md` for the draft plan.
288288

289289
### AI Synthesis (Reports)
290290

core/migration.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
from __future__ import annotations
22

33
import json
4+
import logging
5+
6+
from pydantic import ValidationError
47

58
from core.database import SessionLocal
69
from core.db_management import create_db_and_tables
7-
from modules.client_mgr.payloads import normalize_clients_payload
10+
from modules.client_mgr.schema import Client
811
from modules.client_store import DbClientStore
912

1013

@@ -15,18 +18,29 @@ def migrate_data() -> None:
1518
db = SessionLocal()
1619
try:
1720
with open("data/clients.json", "r", encoding="utf-8") as f:
18-
clients_data = json.load(f)
19-
clients_data, _ = normalize_clients_payload(clients_data)
21+
clients_raw_data = json.load(f)
22+
23+
if not isinstance(clients_raw_data, list):
24+
logging.error("data/clients.json should contain a list of clients.")
25+
return
26+
27+
clients_data = [Client.model_validate(c) for c in clients_raw_data]
28+
logging.info(f"Found {len(clients_data)} clients in data/clients.json to migrate.")
29+
2030
store = DbClientStore(db)
2131
store.sync_clients(
22-
clients_data if isinstance(clients_data, list) else [],
32+
[client.model_dump() for client in clients_data],
2333
delete_missing=False,
2434
overwrite=False,
2535
)
36+
logging.info("Data migration completed successfully.")
37+
38+
except (json.JSONDecodeError, ValidationError) as e:
39+
logging.error(f"Error migrating data from data/clients.json: {e}")
2640
finally:
2741
db.close()
2842

29-
3043
if __name__ == "__main__":
44+
logging.basicConfig(level=logging.INFO)
3145
create_db_and_tables()
3246
migrate_data()

docs/ai_assistant.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Current Status
44
- API route `/api/assistant/query` exists; limited rules-based summarizer handles client/news/tracker prompts.
5-
- Unsupported modes or questions return explicit "not implemented" responses.
5+
- Unsupported modes or questions return explicit "not implemented" payloads with a 501 status and `meta` warnings.
66
- UI/CLI chat surfaces are not implemented yet.
77

88
## Goals
@@ -41,7 +41,7 @@
4141
- `warnings` (missing data, stale cache, or blocked sources)
4242
- No hallucinated numbers or placeholder examples.
4343
- If inputs are missing, return "Unavailable" with a reason.
44-
- Until the assistant is fully wired, unsupported queries return an explicit "not implemented" response with empty sources.
44+
- Until the assistant is fully wired, unsupported queries return a 501 response with empty sources and explicit warnings.
4545

4646
## Model Options
4747
- Default: rules-based summarizer and templated narratives over deterministic data.

0 commit comments

Comments
 (0)