feat: add health consultation report pipeline
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
from scripts.jyotish_api_server import JyotishAPIHandler
|
||||
from scripts.jyotish_engine import _build_ai_prompt_pack, _build_health_narrative_payload
|
||||
|
||||
|
||||
def _varga(asc, placements):
|
||||
return {
|
||||
"ascendant": {"sign": asc, "sign_index": 0},
|
||||
"planets": {planet: {"sign": sign} for planet, sign in placements.items()},
|
||||
}
|
||||
|
||||
|
||||
def _report():
|
||||
modules = {
|
||||
"chart": {"ascendant": {"sign": "Leo", "sign_idx": 4}, "planets": {}, "birth_info": {}},
|
||||
"varga_full": {
|
||||
"D6_Shashthamsa": _varga("Aries", {"Saturn": "Taurus", "Jupiter": "Gemini"}),
|
||||
"D8_Ashtamsa": _varga("Taurus", {"Saturn": "Cancer", "Jupiter": "Leo"}),
|
||||
"D30_Trimsamsa": _varga("Gemini", {"Saturn": "Virgo", "Jupiter": "Libra"}),
|
||||
},
|
||||
"dasha": {"current_dasha": {"mahadasha": "Saturn", "antardasha": "Jupiter"}},
|
||||
"shadbala": {"planets": {
|
||||
"Saturn": {"total_rupas": 6.2, "min_required": 5.0, "strength_level": "strong"},
|
||||
"Jupiter": {"total_rupas": 4.1, "min_required": 5.0, "strength_level": "weak"},
|
||||
"Venus": {"total_rupas": 9.9, "min_required": 5.0, "strength_level": "strong"},
|
||||
}},
|
||||
}
|
||||
return {"chart": modules["chart"], "modules": modules, "birth_info": {}}
|
||||
|
||||
|
||||
def test_health_narrative_uses_only_health_vargas_lords_dasha_and_related_shadbala():
|
||||
report = _report()
|
||||
payload = _build_health_narrative_payload(report["modules"], report["chart"])
|
||||
assert set(payload) == {"headline", "strengths", "risks", "boundaries"}
|
||||
joined = " ".join([payload["headline"], *payload["strengths"], *payload["risks"]])
|
||||
for layer in ("D6", "D8", "D30", "Saturn", "Jupiter"):
|
||||
assert layer in joined
|
||||
assert "Venus" not in joined
|
||||
assert "非医疗" in " ".join(payload["boundaries"])
|
||||
prompt = _build_ai_prompt_pack(report)
|
||||
assert prompt["evidence_snapshot"]["health_narrative"]["headline"] == payload["headline"]
|
||||
|
||||
|
||||
def test_api_prompt_pack_keeps_compact_health_narrative():
|
||||
report = _report()
|
||||
chart = {**report["chart"], "modules": report["modules"], "birth": {}, "dasha": {}}
|
||||
prompt = JyotishAPIHandler.__new__(JyotishAPIHandler)._build_chart_prompt_pack(chart)
|
||||
seed = prompt["evidence_snapshot"]["health_narrative"]
|
||||
assert seed["status"] == "parameter_sensitive"
|
||||
assert "D6/D8/D30" in seed["headline"]
|
||||
assert "非医疗" in " ".join(seed["boundaries"])
|
||||
@@ -87,7 +87,7 @@ def test_unified_consultation_orchestrator_routes_health_questions() -> None:
|
||||
assert route["question_type"] == "health"
|
||||
assert route["primary_theme"] == "health"
|
||||
assert "D6" in route["focus_techniques"]
|
||||
assert "non-medical boundary" in route["focus_techniques"]
|
||||
assert "Functional Benefic/Malefic" in route["focus_techniques"]
|
||||
|
||||
|
||||
def test_unified_consultation_orchestrator_routes_extended_product_domains() -> None:
|
||||
@@ -519,3 +519,19 @@ def test_machine_evidence_packet_carries_vedastro_raw_archive_manifest() -> None
|
||||
section = packet["sections"]["vedastro_official_raw_archive_manifest"]
|
||||
assert section["status"] == "used"
|
||||
assert section["source_path"] == "vedastro_gateway.archives"
|
||||
|
||||
|
||||
def test_health_route_uses_three_window_contract_and_required_layers() -> None:
|
||||
orchestrator = UnifiedConsultationOrchestrator()
|
||||
route = orchestrator.resolve_route("健康压力与恢复节奏", ["health"])
|
||||
assert route["focus_techniques"] == [
|
||||
"D6", "D8", "D30", "Dasha", "Narayana Dasha", "Shadbala",
|
||||
"Transit", "Functional Benefic/Malefic",
|
||||
]
|
||||
assert orchestrator.route_profile_contract("health")["sections"] == [
|
||||
"pressure_windows", "event_risk_windows", "recovery_support_windows",
|
||||
"non_medical_boundary", "verification_questions",
|
||||
]
|
||||
required = orchestrator.evidence_packet_required_sections("health")
|
||||
for layer in ("D6", "D8", "D30", "narayana_dasha", "functional_benefic_malefic", "transit", "non_medical_boundary"):
|
||||
assert layer in required
|
||||
|
||||
Reference in New Issue
Block a user