Epic-Minds / markdown.py
Sarath0x8f's picture
Upload 2 files
32ca645 verified
description = """
## 🕉️ **Project Title: Epic-Minds 🏹🛞**
---
### 🔍 **Project Overview**
**RamayanaGPT** and **GitaGPT** are intelligent chatbots designed to answer spiritual and literary questions from the *Valmiki Ramayana* and the *Bhagavad Gita* respectively. They follow a **Retrieval-Augmented Generation (RAG)** pipeline to ensure that the responses are contextually grounded in the scriptures.
These tools integrate:
- **MongoDB Atlas Vector Search** for semantic document retrieval
- **Hugging Face embeddings** (`intfloat/multilingual-e5-base`)
- **Gemini Flash 1.5 API** as the large language model
- **LlamaIndex** for orchestration and query handling
- **Gradio** for a clean and simple user interface
---
### 🏗️ **Key Components**
#### 1. **Vector Store: MongoDB Atlas**
- Two collections are created in the `RAG` database:
- `ramayana` for **Valmiki Ramayana**
- `bhagavad_gita` for **Bhagavad Gita**
- Each collection has an associated vector index:
- `ramayana_vector_index`
- `gita_vector_index`
Each document includes:
- **Ramayana**: `kanda`, `sarga`, `shloka`, `shloka_text`, `explanation`
- **Gita**: `Title`, `Chapter`, `Verse`, `explanation`
#### 2. **Vector Embedding: Hugging Face**
- Model used: `intfloat/multilingual-e5-base`
- Text format for embedding: `shloka_text + explanation` or `verse + explanation`
- Indexed into MongoDB for fast semantic retrieval
#### 3. **Language Model: Gemini Flash**
- Model: `gemini-1.5-flash`
- Integrated via `llama_index.llms.gemini.Gemini`
- API key loaded from environment variables
- No user input required for keys—simplifies interface and experience
#### 4. **Prompt Engineering**
Custom **PromptTemplates** for each chatbot to guide structured, scripture-faithful responses.
- **RamayanaGPT Prompt**:
- Intro or overview of the query
- Related Sanskrit shloka(s) with explanation
- Summary of the topic
- **GitaGPT Prompt**:
- Spiritual or contextual introduction
- Relevant verse(s) and meaning
- Reflective conclusion
#### 5. **Index Initialization**
- Vector indices are initialized **once** at app startup:
```python
ramayana_index = get_vector_index("RAG", "ramayana", "ramayana_vector_index")
gita_index = get_vector_index("RAG", "bhagavad_gita", "gita_vector_index")
````
* Shared across sessions for efficiency
#### 6. **User Interface: Gradio**
* Built using `gr.Blocks` with the `Soft` theme and `Roboto Mono` font
* Clean tabbed interface:
* 🕉️ **RamayanaGPT**
* 🕉️ **GitaGPT**
* Each tab features:
* Overview accordion
* Chat window powered by `gr.ChatInterface`
---
### ⚙️ **Technical Stack**
| Component | Technology |
| --------------- | ------------------------------------- |
| Backend LLM | Gemini Flash 1.5 (via API) |
| Embedding Model | Hugging Face (`multilingual-e5-base`) |
| Vector Store | MongoDB Atlas Vector Search |
| Vector Engine | LlamaIndex VectorStoreIndex |
| Prompt Engine | LlamaIndex PromptTemplate |
| Query Engine | LlamaIndex Query Engine |
| UI Framework | Gradio (Blocks + ChatInterface) |
| Deployment | Python app using `app.py` |
---
### ✅ **Features Implemented**
* [x] Vector search using MongoDB Atlas
* [x] Hugging Face embedding integration
* [x] Gemini Flash 1.5 LLM integration
* [x] Structured prompts per scripture
* [x] Tabbed Gradio UI for easy switching
* [x] Collapsible summaries for each section
* [x] Query logging with timestamp
---
"""
groq_api_key = """
### 🔑 How to Get a Groq API Key
1. **Go to** [https://console.groq.com/keys](https://console.groq.com/keys)
2. **Log in or Sign Up** for a Groq account.
3. Click **"API Keys"** from the dashboard.
4. Click **"Create Key"**, name it, and generate.
5. **Copy the API key** and store it securely.
6. **Paste** the key into the RamayanaGPT app to start chatting.
---
⚠️ **Don't share** your API key. Revoke and regenerate if needed.
"""
RamayanaGPT='''
## 🕉️ **RamayanaGPT – Overview and Dataset Summary**
### 📖 **Introduction**
**RamayanaGPT** is a RAG-based chatbot that draws upon the **Valmiki Ramayana**, the original Sanskrit epic, to answer user queries with reference to shlokas and their commentaries. It aims to offer precise, contextual, and respectful responses using advanced retrieval and generation technologies.
### 🗂️ **Dataset Structure**
The uploaded Ramayana dataset includes the following columns:
| Column | Description |
| ------------- | ------------------------------------------------------------------------------ |
| `kanda` | One of the 7 books (kandas) of the Ramayana (e.g., Bala Kanda, Ayodhya Kanda). |
| `sarga` | The chapter number within each kanda. |
| `shloka` | The shloka (verse) number within the sarga. |
| `shloka_text` | Original Sanskrit verse. |
| `explanation` | English explanation or interpretation of the shloka. |
### 🔍 **Example**
```text
kanda: Bala Kanda
sarga: 1
shloka: 1
shloka_text: तपस्स्वाध्यायनिरतं तपस्वी वाग्विदां वरम् ।
explanation: Ascetic Valmiki enquired of Narada, preeminent among sages, who was engaged in penance and study of the Vedas.
```
### 💡 **Insights**
* The data is well-structured with nearly **1,400+** records.
* Each record reflects a deep philosophical or narrative moment from the epic.
* Metadata (`kanda`, `sarga`, `shloka`) allows precise retrieval and organization.
* Used for vector indexing and semantic retrieval.
'''
GitaGPT='''
## 🕉️ **GitaGPT – Overview and Dataset Summary**
### 📖 **Introduction**
**GitaGPT** is a chatbot built to answer spiritual and philosophical questions using the **Bhagavad Gita** as its primary source. It references verses (slokas) directly from the Gita, delivering insights supported by both Sanskrit, Hindi, and English explanations.
### 🗂️ **Dataset Structure**
The uploaded Gita dataset contains the following fields:
| Column | Description |
| --------------------- | --------------------------------------------------- |
| `S.No.` | Serial number of the verse. |
| `Title` | Title of the chapter (e.g., Arjuna's Vishada Yoga). |
| `Chapter` | Gita chapter number (e.g., Chapter 1). |
| `Verse` | Verse ID (e.g., Verse 1.1). |
| `Sanskrit Anuvad` | Original verse in Devanagari Sanskrit. |
| `Hindi Anuvad` | Hindi translation/interpretation. |
| `Enlgish Translation` | English translation/interpretation. |
### 🔍 **Example**
```text
Chapter: Chapter 1
Verse: Verse 1.1
Sanskrit: धृतराष्ट्र उवाच । धर्मक्षेत्रे कुरुक्षेत्रे समवेता युयुत्सवः...
Hindi: धृतराष्ट्र बोले- हे संजय! धर्मभूमि कुरुक्षेत्र में एकत्र हुए युद्ध की इच्छा रखने वाले...
English: Dhrtarashtra asked of Sanjaya: O SANJAYA, what did my sons and the sons of Pandu do?
```
### 💡 **Insights**
* The dataset contains **700+ verses** from all 18 chapters.
* Multilingual representation (Sanskrit, Hindi, English) enhances usability for diverse users.
* The verse structure (`Chapter`, `Verse`) aids in precise referencing and response generation.
* Perfectly suited for semantic search via vector embeddings.
'''
footer = """
<div style="background-color: #1d2938; color: white; padding: 10px; width: 100%; bottom: 0; left: 0; display: flex; justify-content: space-between; align-items: center; padding: .2rem 35px; box-sizing: border-box; font-size: 16px;">
<div style="text-align: left;">
<p style="margin: 0;">&copy; 2025 </p>
</div>
<div style="text-align: center; flex-grow: 1;">
<p style="margin: 0;"> This website is made with ❤ by SARATH CHANDRA</p>
</div>
<div class="social-links" style="display: flex; gap: 20px; justify-content: flex-end; align-items: center;">
<a href="https://github.com/21bq1a4210" target="_blank" style="text-align: center;">
<img src="data:image/png;base64,{}" alt="GitHub" width="40" height="40" style="display: block; margin: 0 auto;">
<span style="font-size: 14px;">GitHub</span>
</a>
<a href="https://www.linkedin.com/in/sarath-chandra-bandreddi-07393b1aa/" target="_blank" style="text-align: center;">
<img src="data:image/png;base64,{}" alt="LinkedIn" width="40" height="40" style="display: block; margin: 0 auto;">
<span style="font-size: 14px;">LinkedIn</span>
</a>
<a href="https://21bq1a4210.github.io/MyPortfolio-/" target="_blank" style="text-align: center;">
<img src="data:image/png;base64,{}" alt="Portfolio" width="40" height="40" style="display: block; margin-right: 40px;">
<span style="font-size: 14px;">Portfolio</span>
</a>
</div>
</div>
"""