Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -13,6 +13,7 @@ logger.setLevel(logging.INFO)
|
|
| 13 |
|
| 14 |
graph = generate_graph()
|
| 15 |
|
|
|
|
| 16 |
def init():
|
| 17 |
load_dotenv(override=True)
|
| 18 |
|
|
@@ -28,6 +29,7 @@ def init():
|
|
| 28 |
# 2. Extract it
|
| 29 |
downloader.unzip(zip_path, extract_to="./")
|
| 30 |
|
|
|
|
| 31 |
def init_session():
|
| 32 |
# Generate a unique ID per browser session
|
| 33 |
return str(uuid.uuid4())
|
|
@@ -44,22 +46,31 @@ def chat(message, history, thread_id):
|
|
| 44 |
|
| 45 |
thread_id = gr.State(init_session)
|
| 46 |
supported_scriptures = "\n - ".join(
|
| 47 |
-
[
|
|
|
|
|
|
|
|
|
|
| 48 |
)
|
| 49 |
intro_messages = [
|
| 50 |
-
{
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
- Give me a pasuram by Andal
|
| 58 |
- explain sakrudeva prapannaaya shlokam in ramayana
|
| 59 |
- give the shlokam in ramayanam that vibheeshana uses to perform sharanagathi to rama, give the sanskrit shlokam and its meaning
|
| 60 |
- give one name in vishnu sahasranamam related to "cause"
|
| 61 |
- explain name of vishnu in sahasranamam related to wheel
|
| 62 |
-
"""
|
|
|
|
| 63 |
]
|
| 64 |
chatbot = gr.Chatbot(
|
| 65 |
elem_id="chatbot",
|
|
@@ -70,10 +81,10 @@ chatbot = gr.Chatbot(
|
|
| 70 |
show_copy_all_button=True,
|
| 71 |
type="messages",
|
| 72 |
height=700,
|
| 73 |
-
render_markdown=True
|
| 74 |
)
|
| 75 |
-
chatInterface = gr.ChatInterface(
|
| 76 |
-
fn=chat, additional_inputs=[thread_id], chatbot=chatbot
|
| 77 |
)
|
| 78 |
# initializze database
|
| 79 |
init()
|
|
|
|
| 13 |
|
| 14 |
graph = generate_graph()
|
| 15 |
|
| 16 |
+
|
| 17 |
def init():
|
| 18 |
load_dotenv(override=True)
|
| 19 |
|
|
|
|
| 29 |
# 2. Extract it
|
| 30 |
downloader.unzip(zip_path, extract_to="./")
|
| 31 |
|
| 32 |
+
|
| 33 |
def init_session():
|
| 34 |
# Generate a unique ID per browser session
|
| 35 |
return str(uuid.uuid4())
|
|
|
|
| 46 |
|
| 47 |
thread_id = gr.State(init_session)
|
| 48 |
supported_scriptures = "\n - ".join(
|
| 49 |
+
[
|
| 50 |
+
f"📖 **{scripture['title']}** [source]({scripture['source']})"
|
| 51 |
+
for scripture in SanatanConfig.scriptures
|
| 52 |
+
]
|
| 53 |
)
|
| 54 |
intro_messages = [
|
| 55 |
+
{
|
| 56 |
+
"role": "assistant",
|
| 57 |
+
"content": f"Namaskaram 🙏 I can help you explore the following scriptures:\n\n - {supported_scriptures}",
|
| 58 |
+
},
|
| 59 |
+
{
|
| 60 |
+
"role": "assistant",
|
| 61 |
+
"content": """
|
| 62 |
+
#### Example questions you can ask:
|
| 63 |
+
- How is the form of Vishnu described across the scriptures?
|
| 64 |
+
- What teachings did Krishna share in the Gita?
|
| 65 |
+
- How did Arjuna respond upon witnessing Krishna’s Vishwarupa?
|
| 66 |
+
- What are some names of Vishnu from the Sahasranamam?
|
| 67 |
- Give me a pasuram by Andal
|
| 68 |
- explain sakrudeva prapannaaya shlokam in ramayana
|
| 69 |
- give the shlokam in ramayanam that vibheeshana uses to perform sharanagathi to rama, give the sanskrit shlokam and its meaning
|
| 70 |
- give one name in vishnu sahasranamam related to "cause"
|
| 71 |
- explain name of vishnu in sahasranamam related to wheel
|
| 72 |
+
""",
|
| 73 |
+
},
|
| 74 |
]
|
| 75 |
chatbot = gr.Chatbot(
|
| 76 |
elem_id="chatbot",
|
|
|
|
| 81 |
show_copy_all_button=True,
|
| 82 |
type="messages",
|
| 83 |
height=700,
|
| 84 |
+
render_markdown=True,
|
| 85 |
)
|
| 86 |
+
chatInterface = gr.ChatInterface(
|
| 87 |
+
title="Sanatan-AI", fn=chat, additional_inputs=[thread_id], chatbot=chatbot
|
| 88 |
)
|
| 89 |
# initializze database
|
| 90 |
init()
|