File size: 2,320 Bytes
a1042f7
 
613e777
a1042f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
613e777
a1042f7
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# app.py — HuggingFace Space entry point

import streamlit as st
import requests

API_URL = "http://localhost:8080"

st.set_page_config(
    page_title="Vaidya — Classical Ayurvedic Knowledge",
    page_icon="🌿",
    layout="wide"
)

st.title("🌿 Vaidya")
st.subheader("Citation-Grounded Ayurvedic Knowledge from Caraka-Saṃhitā")

st.info(
    "Ask questions in English, Hindi, or Sanskrit. "
    "Every answer is sourced directly from the Caraka-Saṃhitā with verse citations."
)

with st.sidebar:
    st.header("Settings")
    top_k = st.slider("Number of sources", 1, 10, 5)
    sthana = st.selectbox(
        "Filter by Sthana (optional)",
        ["All", "Sutrasthana", "Nidanasthana", "Vimanasthana",
         "Sharirasthana", "Cikitsasthana", "Kalpasthana", "Siddhisthana"]
    )
    st.markdown("---")
    st.caption("Sources: Caraka-Saṃhitā (Priyavrata Śarmā ed., Chaukhambha Orientalia)")
    st.caption("Model: Qwen2.5-72B on AMD MI300X")

query = st.text_input(
    "Enter your query:",
    placeholder="e.g., What are the properties of Vata dosha? / वात दोष के गुण क्या हैं?"
)

if st.button("Search", type="primary") and query:
    with st.spinner("Searching classical texts..."):
        try:
            payload = {
                "query": query,
                "top_k": top_k,
                "sthana_filter": None if sthana == "All" else sthana
            }
            resp = requests.post(f"{API_URL}/query", json=payload, timeout=60)
            data = resp.json()

            if data["confident"]:
                st.success("✓ Sources found in Caraka-Saṃhitā")
            else:
                st.warning("⚠ No direct source found above confidence threshold")

            st.markdown("### Response")
            st.write(data["response"])

            if data["citations"]:
                st.markdown("### Citations")
                for c in data["citations"]:
                    st.code(c)

            st.markdown("---")
            st.warning(data["disclaimer"])

        except Exception as e:
            st.error(f"Error: {e}")

st.markdown("---")
st.caption(
    "Vaidya is an AI research system. All information is for educational purposes only. "
    "Consult a certified Ayurvedic practitioner for medical advice."
)