Spaces:
Runtime error
Runtime error
Commit ·
224c593
1
Parent(s): 82583bd
Add 899999999999999999999999
Browse files- check_agentic_docs.py +49 -0
- check_documents.py +49 -0
- config.py +1 -1
- reset_database.py +41 -0
- setup_documents.py +226 -62
- test_search.py +45 -0
check_agentic_docs.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Check documents in the agentic_chatbot LanceDB database
|
| 4 |
+
"""
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
|
| 8 |
+
# Add the path to access lancedb_service
|
| 9 |
+
sys.path.append('/Users/abhishekchoudhary/Abhi Project/Voice_Bot/PensionBot')
|
| 10 |
+
|
| 11 |
+
# Change to agentic_chatbot directory to use its database
|
| 12 |
+
os.chdir('/Users/abhishekchoudhary/Abhi Project/Voice_Bot/agentic_chatbot')
|
| 13 |
+
|
| 14 |
+
import asyncio
|
| 15 |
+
import logging
|
| 16 |
+
import lancedb
|
| 17 |
+
|
| 18 |
+
# Setup logging
|
| 19 |
+
logging.basicConfig(level=logging.INFO)
|
| 20 |
+
logger = logging.getLogger("check_agentic_docs")
|
| 21 |
+
|
| 22 |
+
async def check_agentic_documents():
|
| 23 |
+
"""Check how many documents are in the agentic_chatbot database"""
|
| 24 |
+
try:
|
| 25 |
+
logger.info("🔍 Checking agentic_chatbot LanceDB document count...")
|
| 26 |
+
|
| 27 |
+
# Connect to the local LanceDB
|
| 28 |
+
db = lancedb.connect("lancedb_data")
|
| 29 |
+
table_names = db.table_names()
|
| 30 |
+
|
| 31 |
+
logger.info(f"📊 Found {len(table_names)} tables in agentic_chatbot database:")
|
| 32 |
+
|
| 33 |
+
total_documents = 0
|
| 34 |
+
for table_name in table_names:
|
| 35 |
+
try:
|
| 36 |
+
table = db.open_table(table_name)
|
| 37 |
+
count = table.count_rows()
|
| 38 |
+
logger.info(f" 📄 {table_name}: {count} documents")
|
| 39 |
+
total_documents += count
|
| 40 |
+
except Exception as e:
|
| 41 |
+
logger.error(f" ❌ Error checking table {table_name}: {e}")
|
| 42 |
+
|
| 43 |
+
logger.info(f"📈 Total documents in agentic_chatbot: {total_documents}")
|
| 44 |
+
|
| 45 |
+
except Exception as e:
|
| 46 |
+
logger.error(f"❌ Error checking documents: {e}")
|
| 47 |
+
|
| 48 |
+
if __name__ == "__main__":
|
| 49 |
+
asyncio.run(check_agentic_documents())
|
check_documents.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Check the number of documents in the LanceDB database
|
| 4 |
+
"""
|
| 5 |
+
import asyncio
|
| 6 |
+
import logging
|
| 7 |
+
from lancedb_service import lancedb_service
|
| 8 |
+
|
| 9 |
+
# Setup logging
|
| 10 |
+
logging.basicConfig(level=logging.INFO)
|
| 11 |
+
logger = logging.getLogger("check_docs")
|
| 12 |
+
|
| 13 |
+
async def check_document_count():
|
| 14 |
+
"""Check how many documents are in the database"""
|
| 15 |
+
try:
|
| 16 |
+
logger.info("🔍 Checking LanceDB document count...")
|
| 17 |
+
|
| 18 |
+
# Get all tables in the database
|
| 19 |
+
db = lancedb_service.db
|
| 20 |
+
table_names = await asyncio.to_thread(lambda: db.table_names())
|
| 21 |
+
|
| 22 |
+
logger.info(f"📊 Found {len(table_names)} tables in database:")
|
| 23 |
+
|
| 24 |
+
total_documents = 0
|
| 25 |
+
for table_name in table_names:
|
| 26 |
+
try:
|
| 27 |
+
table = await asyncio.to_thread(lambda: db.open_table(table_name))
|
| 28 |
+
count = await asyncio.to_thread(lambda: table.count_rows())
|
| 29 |
+
logger.info(f" 📄 {table_name}: {count} documents")
|
| 30 |
+
total_documents += count
|
| 31 |
+
except Exception as e:
|
| 32 |
+
logger.error(f" ❌ Error checking table {table_name}: {e}")
|
| 33 |
+
|
| 34 |
+
logger.info(f"📈 Total documents across all tables: {total_documents}")
|
| 35 |
+
|
| 36 |
+
# Also check if we can search the main documents table
|
| 37 |
+
logger.info("\n🔍 Testing document search...")
|
| 38 |
+
from rag_service import search_documents_async
|
| 39 |
+
|
| 40 |
+
test_queries = ["pension", "salary", "leave", "training"]
|
| 41 |
+
for query in test_queries:
|
| 42 |
+
docs = await search_documents_async(query, limit=3)
|
| 43 |
+
logger.info(f" Query '{query}': Found {len(docs) if docs else 0} documents")
|
| 44 |
+
|
| 45 |
+
except Exception as e:
|
| 46 |
+
logger.error(f"❌ Error checking documents: {e}")
|
| 47 |
+
|
| 48 |
+
if __name__ == "__main__":
|
| 49 |
+
asyncio.run(check_document_count())
|
config.py
CHANGED
|
@@ -44,7 +44,7 @@ CHUNK_OVERLAP = int(os.environ.get("CHUNK_OVERLAP", "200"))
|
|
| 44 |
ALLOWED_ORIGINS = os.environ.get("ALLOWED_ORIGINS", "*").split(",") if os.environ.get("ALLOWED_ORIGINS") != "*" else ["*"]
|
| 45 |
|
| 46 |
# LanceDB Configuration
|
| 47 |
-
LANCEDB_PATH = os.environ.get("LANCEDB_PATH", "./lancedb_data")
|
| 48 |
|
| 49 |
# JWT Configuration
|
| 50 |
JWT_SECRET_KEY = os.environ.get("JWT_SECRET_KEY")
|
|
|
|
| 44 |
ALLOWED_ORIGINS = os.environ.get("ALLOWED_ORIGINS", "*").split(",") if os.environ.get("ALLOWED_ORIGINS") != "*" else ["*"]
|
| 45 |
|
| 46 |
# LanceDB Configuration
|
| 47 |
+
LANCEDB_PATH = os.environ.get("LANCEDB_PATH", "../agentic_chatbot/lancedb_data")
|
| 48 |
|
| 49 |
# JWT Configuration
|
| 50 |
JWT_SECRET_KEY = os.environ.get("JWT_SECRET_KEY")
|
reset_database.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Reset the LanceDB database and reload with new diverse content
|
| 4 |
+
"""
|
| 5 |
+
import asyncio
|
| 6 |
+
import logging
|
| 7 |
+
import shutil
|
| 8 |
+
import os
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
# Setup logging
|
| 12 |
+
logging.basicConfig(level=logging.INFO)
|
| 13 |
+
logger = logging.getLogger("reset_db")
|
| 14 |
+
|
| 15 |
+
async def reset_database():
|
| 16 |
+
"""Reset the database and reload with diverse content"""
|
| 17 |
+
try:
|
| 18 |
+
# Path to the database directory
|
| 19 |
+
db_path = Path("lancedb_data")
|
| 20 |
+
|
| 21 |
+
if db_path.exists():
|
| 22 |
+
logger.info("🗑️ Removing existing database...")
|
| 23 |
+
shutil.rmtree(db_path)
|
| 24 |
+
logger.info("✅ Existing database removed")
|
| 25 |
+
|
| 26 |
+
# Recreate the database directory
|
| 27 |
+
db_path.mkdir(exist_ok=True)
|
| 28 |
+
logger.info("📁 Created new database directory")
|
| 29 |
+
|
| 30 |
+
# Now run the setup documents script
|
| 31 |
+
logger.info("📚 Loading new diverse documents...")
|
| 32 |
+
from setup_documents import setup_sample_documents
|
| 33 |
+
await setup_sample_documents()
|
| 34 |
+
|
| 35 |
+
logger.info("🎉 Database reset complete with diverse content!")
|
| 36 |
+
|
| 37 |
+
except Exception as e:
|
| 38 |
+
logger.error(f"❌ Error resetting database: {e}")
|
| 39 |
+
|
| 40 |
+
if __name__ == "__main__":
|
| 41 |
+
asyncio.run(reset_database())
|
setup_documents.py
CHANGED
|
@@ -8,74 +8,238 @@ import logging
|
|
| 8 |
|
| 9 |
logger = logging.getLogger("voicebot")
|
| 10 |
|
| 11 |
-
# Sample government documents content
|
| 12 |
SAMPLE_DOCUMENTS = [
|
| 13 |
{
|
| 14 |
-
"content": """
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
1.
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
-
|
| 24 |
-
-
|
| 25 |
-
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
},
|
| 30 |
{
|
| 31 |
-
"content": """
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
-
|
| 36 |
-
-
|
| 37 |
-
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
-
|
| 42 |
-
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
},
|
| 52 |
{
|
| 53 |
-
"content": """Government
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
1.
|
| 57 |
-
-
|
| 58 |
-
-
|
| 59 |
-
-
|
| 60 |
-
|
| 61 |
-
2.
|
| 62 |
-
-
|
| 63 |
-
-
|
| 64 |
-
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
-
|
| 69 |
-
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
-
|
| 74 |
-
-
|
| 75 |
-
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
}
|
| 80 |
]
|
| 81 |
|
|
|
|
| 8 |
|
| 9 |
logger = logging.getLogger("voicebot")
|
| 10 |
|
| 11 |
+
# Sample government documents content - Diverse content for different queries
|
| 12 |
SAMPLE_DOCUMENTS = [
|
| 13 |
{
|
| 14 |
+
"content": """Government employees are entitled to various types of leave during their service period. The leave rules are governed by the Central Civil Services (Leave) Rules and state-specific adaptations.
|
| 15 |
+
|
| 16 |
+
Types of Leave Available:
|
| 17 |
+
1. Casual Leave (CL): 8 days per calendar year
|
| 18 |
+
- Can be taken for urgent personal work
|
| 19 |
+
- No medical certificate required
|
| 20 |
+
- Cannot be carried forward to next year
|
| 21 |
+
|
| 22 |
+
2. Earned Leave (EL): 30 days per year
|
| 23 |
+
- Can be accumulated up to 300 days
|
| 24 |
+
- Encashment allowed at retirement
|
| 25 |
+
- Advance grant possible for valid reasons
|
| 26 |
+
|
| 27 |
+
3. Medical Leave: As per medical requirements
|
| 28 |
+
- Medical certificate mandatory
|
| 29 |
+
- Can be combined with EL
|
| 30 |
+
- Special provisions for chronic illnesses
|
| 31 |
+
|
| 32 |
+
4. Maternity/Paternity Leave:
|
| 33 |
+
- Maternity: 180 days (6 months)
|
| 34 |
+
- Paternity: 15 days within 6 months of child birth
|
| 35 |
+
|
| 36 |
+
Application Process:
|
| 37 |
+
- Submit leave application in advance
|
| 38 |
+
- Get approval from competent authority
|
| 39 |
+
- Maintain proper leave records
|
| 40 |
+
- Emergency leave can be regularized later""",
|
| 41 |
+
"filename": "leave_rules.txt",
|
| 42 |
+
"source": "Government Leave Manual 2024"
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"content": """Government employee salary structure consists of multiple components designed to provide comprehensive compensation and benefits.
|
| 46 |
+
|
| 47 |
+
Salary Components:
|
| 48 |
+
1. Basic Pay: Core salary amount based on pay scale and grade
|
| 49 |
+
2. Dearness Allowance (DA): Currently 50% of basic pay (as of 2024)
|
| 50 |
+
3. House Rent Allowance (HRA): Varies by city classification
|
| 51 |
+
- X Class cities: 24% of basic pay
|
| 52 |
+
- Y Class cities: 16% of basic pay
|
| 53 |
+
- Z Class cities: 8% of basic pay
|
| 54 |
+
|
| 55 |
+
4. Transport Allowance: ₹3,600 per month for most employees
|
| 56 |
+
5. Medical Allowance: ₹1,000 per month
|
| 57 |
+
|
| 58 |
+
Special Allowances:
|
| 59 |
+
- City Compensatory Allowance (CCA)
|
| 60 |
+
- Special Allowance for difficult postings
|
| 61 |
+
- Overtime Allowance (where applicable)
|
| 62 |
+
|
| 63 |
+
Deductions:
|
| 64 |
+
- Income Tax (as per IT rules)
|
| 65 |
+
- Provident Fund: 12% of basic pay
|
| 66 |
+
- Group Insurance Scheme (GIS)
|
| 67 |
+
- Professional Tax (state-specific)
|
| 68 |
+
|
| 69 |
+
Pay Revision:
|
| 70 |
+
- Pay Commission recommendations every 10 years
|
| 71 |
+
- Annual increment: Usually 3% of basic pay
|
| 72 |
+
- Promotion-based pay upgrades as per rules""",
|
| 73 |
+
"filename": "salary_structure.txt",
|
| 74 |
+
"source": "Pay Commission Guidelines 2024"
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"content": """Transfer and posting policies for government employees are designed to ensure fair distribution of work, prevent corruption, and provide career development opportunities.
|
| 78 |
+
|
| 79 |
+
Transfer Rules:
|
| 80 |
+
1. Tenure-based Transfers:
|
| 81 |
+
- Minimum tenure: 3 years in sensitive posts
|
| 82 |
+
- Maximum tenure: 5 years in one location (general rule)
|
| 83 |
+
- Cooling off period: 2 years before returning to same post
|
| 84 |
+
|
| 85 |
+
2. Request Transfers:
|
| 86 |
+
- Can apply after completing minimum tenure
|
| 87 |
+
- Valid grounds: medical, family, educational needs
|
| 88 |
+
- Subject to administrative approval and replacement availability
|
| 89 |
+
|
| 90 |
+
3. Administrative Transfers:
|
| 91 |
+
- Based on service requirements
|
| 92 |
+
- Immediate transfer in case of disciplinary issues
|
| 93 |
+
- Mutual transfers allowed with proper approvals
|
| 94 |
+
|
| 95 |
+
Posting Guidelines:
|
| 96 |
+
- Home district posting: After 5 years of service
|
| 97 |
+
- Difficult area posting: Incentives and allowances provided
|
| 98 |
+
- Border area posting: Special security clearance required
|
| 99 |
+
|
| 100 |
+
Transfer Process:
|
| 101 |
+
1. Issue of transfer order by competent authority
|
| 102 |
+
2. Relieving formalities at current posting
|
| 103 |
+
3. Journey time allowance as per rules
|
| 104 |
+
4. Joining at new posting within prescribed time
|
| 105 |
+
5. Handing/taking over of charge properly
|
| 106 |
+
|
| 107 |
+
Benefits:
|
| 108 |
+
- Transfer TA/DA as per entitlement
|
| 109 |
+
- Family accommodation assistance
|
| 110 |
+
- School transfer certificates for children""",
|
| 111 |
+
"filename": "transfer_posting_rules.txt",
|
| 112 |
+
"source": "Administrative Transfer Policy 2024"
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"content": """Training and skill development programs are essential for government employees to enhance their capabilities and stay updated with modern administrative practices.
|
| 116 |
+
|
| 117 |
+
Training Categories:
|
| 118 |
+
1. Induction Training:
|
| 119 |
+
- Mandatory for all new recruits
|
| 120 |
+
- Duration: 3-6 months depending on service
|
| 121 |
+
- Covers service rules, conduct rules, and job-specific skills
|
| 122 |
+
|
| 123 |
+
2. In-Service Training:
|
| 124 |
+
- Periodic skill upgradation programs
|
| 125 |
+
- Leadership development courses
|
| 126 |
+
- Technology and digital literacy training
|
| 127 |
+
|
| 128 |
+
3. Specialized Training:
|
| 129 |
+
- Domain-specific technical training
|
| 130 |
+
- Foreign training opportunities for senior officers
|
| 131 |
+
- Research and innovation workshops
|
| 132 |
+
|
| 133 |
+
Training Institutes:
|
| 134 |
+
- National Academy of Administration (NAAN) - for IAS officers
|
| 135 |
+
- State Administrative Training Institutes
|
| 136 |
+
- Sector-specific training centers
|
| 137 |
+
- Online learning platforms (iGOT Karmayogi)
|
| 138 |
+
|
| 139 |
+
Benefits of Training:
|
| 140 |
+
1. Career advancement opportunities
|
| 141 |
+
2. Better performance and efficiency
|
| 142 |
+
3. Exposure to best practices
|
| 143 |
+
4. Networking with peers
|
| 144 |
+
5. Personal and professional development
|
| 145 |
+
|
| 146 |
+
Training Leave:
|
| 147 |
+
- Special training leave with full pay
|
| 148 |
+
- Study leave for higher education
|
| 149 |
+
- Deputation opportunities to training institutes
|
| 150 |
+
|
| 151 |
+
Digital Learning Initiative:
|
| 152 |
+
- Mission Karmayogi for capacity building
|
| 153 |
+
- Online certification courses
|
| 154 |
+
- Competency-based training modules
|
| 155 |
+
- Performance-linked training requirements
|
| 156 |
+
|
| 157 |
+
Training is considered essential for promotion to higher grades and is often a mandatory requirement for career progression in government service.""",
|
| 158 |
+
"filename": "training_development.txt",
|
| 159 |
+
"source": "Government Training Policy 2024"
|
| 160 |
},
|
| 161 |
{
|
| 162 |
+
"content": """Retirement benefits for government employees include multiple components to ensure financial security post-retirement.
|
| 163 |
+
|
| 164 |
+
Retirement Benefits Package:
|
| 165 |
+
1. Pension: Monthly payment based on last drawn salary and service years
|
| 166 |
+
- Calculation: (Last drawn basic pay + DA) × service years ÷ 70
|
| 167 |
+
- Minimum pension: ₹9,000 per month
|
| 168 |
+
- Maximum pension: No upper limit
|
| 169 |
+
|
| 170 |
+
2. Gratuity: Lump sum payment at retirement
|
| 171 |
+
- Formula: (Basic pay + DA) × 15/26 × years of service
|
| 172 |
+
- Maximum: ₹20 lakh (as of 2024)
|
| 173 |
+
- Tax exemption available
|
| 174 |
+
|
| 175 |
+
3. Provident Fund (GPF/CPF):
|
| 176 |
+
- Employee + Government contribution throughout service
|
| 177 |
+
- Withdrawal allowed at retirement
|
| 178 |
+
- Interest rate: Currently 8% per annum
|
| 179 |
+
|
| 180 |
+
4. Commutation of Pension:
|
| 181 |
+
- Option to convert part of pension to lump sum
|
| 182 |
+
- Up to 50% of pension can be commuted
|
| 183 |
+
- Restoration after 15 years
|
| 184 |
+
|
| 185 |
+
5. Medical Benefits:
|
| 186 |
+
- Continued medical facility post-retirement
|
| 187 |
+
- Central Government Health Scheme (CGHS) coverage
|
| 188 |
+
- Reimbursement of medical expenses
|
| 189 |
+
|
| 190 |
+
Retirement Process:
|
| 191 |
+
- Apply 6 months before retirement date
|
| 192 |
+
- Complete all service formalities
|
| 193 |
+
- Obtain clearances from all departments
|
| 194 |
+
- Submit required documents and forms
|
| 195 |
+
|
| 196 |
+
The retirement package is designed to provide comprehensive financial support and maintain dignity of life for retired government employees.""",
|
| 197 |
+
"filename": "retirement_benefits.txt",
|
| 198 |
+
"source": "Retirement Benefits Manual 2024"
|
| 199 |
},
|
| 200 |
{
|
| 201 |
+
"content": """Government procurement policies and procedures ensure transparency, fairness, and value for money in public purchases.
|
| 202 |
+
|
| 203 |
+
Procurement Methods:
|
| 204 |
+
1. Open Tender:
|
| 205 |
+
- Public advertisement required
|
| 206 |
+
- Minimum 21 days for bid submission
|
| 207 |
+
- Used for high-value procurements above ₹25 lakh
|
| 208 |
+
|
| 209 |
+
2. Limited Tender:
|
| 210 |
+
- Invitation to selected vendors
|
| 211 |
+
- For specialized items or urgent requirements
|
| 212 |
+
- Proper justification required
|
| 213 |
+
|
| 214 |
+
3. Single Tender:
|
| 215 |
+
- Direct negotiation with one vendor
|
| 216 |
+
- Only in exceptional circumstances
|
| 217 |
+
- Requires special approval
|
| 218 |
+
|
| 219 |
+
Key Procurement Rules:
|
| 220 |
+
- Preference to Make in India products
|
| 221 |
+
- MSME reservation: 25% of procurement
|
| 222 |
+
- Minimum 50% local content requirement
|
| 223 |
+
- GeM (Government e-Marketplace) mandatory for routine items
|
| 224 |
+
|
| 225 |
+
Tender Process:
|
| 226 |
+
1. Preparation of tender documents
|
| 227 |
+
2. Advertisement and bidder registration
|
| 228 |
+
3. Pre-bid meetings for clarifications
|
| 229 |
+
4. Bid submission and opening
|
| 230 |
+
5. Technical and financial evaluation
|
| 231 |
+
6. Contract award to lowest compliant bidder
|
| 232 |
+
|
| 233 |
+
Documentation Required:
|
| 234 |
+
- Technical specifications
|
| 235 |
+
- Terms and conditions
|
| 236 |
+
- Evaluation criteria
|
| 237 |
+
- Approval for procurement
|
| 238 |
+
- Committee formations for evaluation
|
| 239 |
+
|
| 240 |
+
This system ensures competitive pricing, quality products, and supports domestic manufacturing while maintaining complete transparency in government spending.""",
|
| 241 |
+
"filename": "procurement_policy.txt",
|
| 242 |
+
"source": "Government Procurement Guidelines 2024"
|
| 243 |
}
|
| 244 |
]
|
| 245 |
|
test_search.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Test script to verify that diverse documents are being returned for different queries
|
| 4 |
+
"""
|
| 5 |
+
import asyncio
|
| 6 |
+
import logging
|
| 7 |
+
from rag_service import search_documents_async
|
| 8 |
+
|
| 9 |
+
# Setup logging
|
| 10 |
+
logging.basicConfig(level=logging.INFO)
|
| 11 |
+
logger = logging.getLogger("test_search")
|
| 12 |
+
|
| 13 |
+
async def test_diverse_responses():
|
| 14 |
+
"""Test that different queries return different, relevant documents"""
|
| 15 |
+
|
| 16 |
+
test_queries = [
|
| 17 |
+
"pension rules",
|
| 18 |
+
"leave policy",
|
| 19 |
+
"salary structure",
|
| 20 |
+
"training programs",
|
| 21 |
+
"retirement benefits",
|
| 22 |
+
"procurement policy",
|
| 23 |
+
"get out", # This was giving generic response before
|
| 24 |
+
"what about transfers"
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
logger.info("🧪 Testing diverse document responses...")
|
| 28 |
+
|
| 29 |
+
for query in test_queries:
|
| 30 |
+
logger.info(f"\n🔍 Testing query: '{query}'")
|
| 31 |
+
try:
|
| 32 |
+
docs = await search_documents_async(query, limit=2)
|
| 33 |
+
if docs:
|
| 34 |
+
for i, doc in enumerate(docs):
|
| 35 |
+
title = doc.get('source_title', 'Unknown')
|
| 36 |
+
content_preview = doc.get('clause_text', '')[:100] + "..."
|
| 37 |
+
logger.info(f" 📄 Document {i+1}: {title}")
|
| 38 |
+
logger.info(f" Preview: {content_preview}")
|
| 39 |
+
else:
|
| 40 |
+
logger.warning(f" ⚠️ No documents found for: {query}")
|
| 41 |
+
except Exception as e:
|
| 42 |
+
logger.error(f" ❌ Error searching for '{query}': {e}")
|
| 43 |
+
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
asyncio.run(test_diverse_responses())
|