Download app.py from Hacker0809/PST: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/Hacker0809/PST/resolve/main/app.py
- Command line
-
hf download hf://Hacker0809/PST/app.py
-
curl -L -o app.py https://huggingface.co/Hacker0809/PST/resolve/main/app.py
1.17 kB
| import json | |
| import difflib | |
| import gradio as gr | |
| # Load Q&A data | |
| with open("premanand_qa_full.json", "r", encoding="utf-8") as f: | |
| qa_pairs = json.load(f) | |
| def get_answer(user_question): | |
| questions = [item["question"] for item in qa_pairs] | |
| closest_match = difflib.get_close_matches(user_question, questions, n=1, cutoff=0.4) | |
| if closest_match: | |
| for item in qa_pairs: | |
| if item["question"] == closest_match[0]: | |
| return f"🌸 {item['answer']}" | |
| else: | |
| return "🙏 बेटा, इस प्रश्न का उत्तर अभी मेरे पास नहीं है। कृपया कुछ और पूछो।" | |
| # Gradio UI | |
| iface = gr.Interface( | |
| fn=get_answer, | |
| inputs=gr.Textbox(lines=2, placeholder="प्रश्न पूछिए..."), | |
| outputs="text", | |
| title="🌼 श्री प्रेमानंद जी महाराज", | |
| description="प्रेमानंद जी महाराज के भावों में आध्यात्मिक उत्तर प्राप्त करें।" | |
| ) | |
| iface.launch() | |