""" Run with: python -m inference.smoke_test All 4 scenarios must pass before using the app. """ from inference.engine import VrikshayurvedaInferenceEngine engine = VrikshayurvedaInferenceEngine() def run_scenario(name: str, query: str, expected_facts: list[str]) -> None: print(f"\n{'='*60}") print(f"SCENARIO: {name}") print('='*60) result = engine.diagnose( user_query=query, expanded_queries=[], retrieved_chunks=[], ) print(f"Primary diagnosis : {result.primary_diagnosis}") print(f"Dosha : {result.dosha}") print(f"Confidence : {round(result.confidence * 100)}%") print(f"\nForward trace:") for line in result.forward_trace: print(f" {line}") print(f"\nAll facts in working memory:") for f in sorted(result.all_facts): print(f" - {f}") missing = [f for f in expected_facts if f not in result.all_facts] if missing: print(f"\n FAIL — missing expected facts: {missing}") else: print(f"\n PASS — all expected facts present") print(f"\nLLM context:") print(f" {result.llm_context}") run_scenario( name="Internal Vata — arid yellowing", query="The tree has general yellowing of leaves and fruits with loss of flowers and fruits.", expected_facts=[ "general_yellowing", "flower_fruit_loss", "internal_vata_disorder", "arid_soil_cause", "recommend_panchmula_decoction", "recommend_fermented_fat_decoction", ], ) run_scenario( name="Internal Kapha — winter oozing", query="The tree is showing delayed fruiting with bland overripe fruits and oozing sap without any injury, it is winter season.", expected_facts=[ "delayed_fruiting", "bland_overripe_fruits", "oozing_without_injury", "winter_spring_season", "internal_kapha_disorder", "fungal_rot_cause", "excessive_moisture_cause", "recommend_white_mustard_paste_roots", "recommend_sesame_ash_water", "recommend_fresh_dry_soil", ], ) run_scenario( name="Internal Pitta — end of summer decay", query="Leaves are withering early and fruits are decaying prematurely at the end of summer.", expected_facts=[ "early_leaf_withering", "early_fruit_flower_decay", "end_of_summer", "internal_pitta_disorder", "heat_fungal_cause", "salinity_cause", "recommend_triphala_ghee_honey", "recommend_milk_honey_yastamdhu_madhuka", ], ) run_scenario( name="Insect infestation", query="The tree has a foul smell, original fragrance is missing, and leaves are reduced in size with stunted seedlings.", expected_facts=[ "foul_smell", "fragrance_loss", "reduced_leaf_size", "stunted_seedlings", "insect_infestation_disorder", "recommend_vidanga_smoke_fumigation", "recommend_vidanga_ghee_ointment", "recommend_soft_water_7days", ], )