chatbot / app.py
kartik100's picture
Update app.py
1ae25d2 verified
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()