⚖️ नेपाली कानूनी सहायक
Nepali Legal Assistant with RAG
आफ्नो मुद्दा खोज्नुहोस् र कानूनी सहायताका लागि च्याट गर्नुहोस्
Search for your case and chat for legal assistance
import gradio as gr from chromadb_semantic_search_for_dataset import search_cases, chat_with_cases # Global variables to store current context current_cases_context = "" current_user_case = "" def search_and_store_cases(query): """Search for cases and store context for chat""" global current_cases_context, current_user_case if not query.strip(): return "कृपया केस खोज्नका लागि केही लेख्नुहोस्।", "" formatted_results, context, user_case = search_cases(query) current_cases_context = context current_user_case = user_case return formatted_results, "" def chat_function(message, history): """Main chat function that uses current case context""" global current_cases_context, current_user_case if not message.strip(): return history, "" # Generate response using current case context and user's case bot_response = chat_with_cases(message, current_cases_context, current_user_case) # Add to chat history history.append([message, bot_response]) return history, "" def clear_context(): """Clear the stored case context""" global current_cases_context, current_user_case current_cases_context = "" current_user_case = "" return "केस कन्टेक्स्ट सफा गरियो। अब तपाईं सामान्य च्याट गर्न सक्नुहुन्छ।", [], "" # Custom CSS css = """ .gradio-container { max-width: 1200px !important; margin: auto !important; } .main-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; border-radius: 10px; text-align: center; margin-bottom: 20px; } .section-header { background: #f8f9fa; padding: 15px; border-radius: 8px; border-left: 4px solid #007bff; margin: 10px 0; } .chat-container { border: 2px solid #e9ecef; border-radius: 10px; padding: 10px; } .search-container { border: 2px solid #e9ecef; border-radius: 10px; padding: 10px; background: #f8f9fa; } """ # Create the main interface with gr.Blocks(css=css, title="नेपाली कानूनी सहायक - Legal RAG System") as demo: # Header gr.HTML("""
आफ्नो मुद्दा खोज्नुहोस् र कानूनी सहायताका लागि च्याट गर्नुहोस्
Search for your case and chat for legal assistance
⚠️ चेतावनी: यो केवल जानकारीमूलक सहायता हो। वास्तविक कानूनी सल्लाहका लागि योग्य वकिलसँग सल्लाह लिनुहोस्।