import gradio as gr from difflib import get_close_matches # ----------------------------------------------------- # Ultra Fast NIELIT Knowledge Base # ----------------------------------------------------- FAQ = { "courses": """ NIELIT Major Courses: • CCC, BCC (Digital Literacy) • O Level (Diploma Equivalent) • A Level (Advanced Diploma) • B Level (MCA Equivalent) • C Level (M.Tech Equivalent) • Diploma – Hardware, Software, AI, ML, IoT, Cyber Security • Short Courses – Python, Java, C, C++, Web Designing, Data Science • B.Tech Engineering Programs (CS, IT, Electronics) – Center Wise """, "fees": """ NIELIT Fee Structure (Approx): • CCC: ₹500–800 • O Level: ₹14,000–17,000 • A Level: ₹20,000–35,000 • Diploma: ₹18,000–45,000 • Short Courses (Python/Java/AI): ₹1500–6000 • B.Tech Fee: ₹50,000 per semester """, "btech": """ NIELIT B.Tech Fee & Details: • Fee: ₹50,000 per semester • Courses: B.Tech in CSE, IT, ECE (center-specific) • Duration: 4 Years • Admission: JEE / Institute Entrance • Facilities: Labs, Project Work, Industry Training """, "ccc": """ CCC Details: • Duration: 80 Hours • Syllabus: Basics, MS Office, Internet • Exam Every Month • Registration: https://student.nielit.gov.in """, "o level": """ O Level Details: • Duration: 1 Year • Eligibility: 12th / ITI / Computer Course • Syllabus: IT Tools, Web Design, Python/C Programming • Fee: ~ ₹15,000 """, "a level": """ A Level Details: • Duration: 1.5 Years • Eligibility: O Level / Graduation • Fee: ₹20,000–35,000 """, "ropar": """ NIELIT Ropar Courses: • Diploma in CS • AI, ML, IoT • Embedded Systems • Cyber Security • Python, Java, C, C++ """, "admission": """ NIELIT Admission Process: 1. Choose Course 2. Register Online 3. Upload Documents 4. Pay Fees 5. Attend Classes / Exams """, "syllabus": """ NIELIT Syllabus: • CCC – Computer Basics, MS Office • O Level – IT Tools, Python, Web Dev • A Level – OS, DBMS, AI, ML Basics """, "certificate": """ NIELIT Certificates are: ✔ Government Recognized ✔ Valid for Government Jobs ✔ PSU Eligible """, "placement": """ NIELIT Placement Support: • IT Companies • Digital India Projects • Technical Support Roles • Skill India Programs """, "contact": """ Visit: https://nielit.ac.in Student Portal: https://student.nielit.gov.in """ } KEYS = list(FAQ.keys()) # ----------------------------------------------------- # Ultra Fast Chatbot Logic # ----------------------------------------------------- def fast_bot(message, history): text = message.lower() # Direct keyword match for key in KEYS: if key in text: answer = FAQ[key] history.append((message, answer)) return history, history # Fuzzy match match = get_close_matches(text, KEYS, n=1, cutoff=0.3) if match: answer = FAQ[match[0]] history.append((message, answer)) return history, history # Default fallback fallback = "Please check the official website for more details: https://nielit.ac.in" history.append((message, fallback)) return history, history # ----------------------------------------------------- # UI # ----------------------------------------------------- with gr.Blocks() as demo: gr.Markdown(""" # ⚡ Ultra-Fast NIELIT Chatbot ### Instant Response | Full Course + Fees Info | Includes B.Tech Fees """) chat = gr.Chatbot() state = gr.State([]) box = gr.Textbox(placeholder="Ask anything about NIELIT (Hindi/English)...") box.submit(fast_bot, [box, state], [chat, state]) box.submit(lambda: "", None, box) demo.launch()