File size: 722 Bytes
0276b0d 5f1c81b a16d353 0276b0d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import gradio as gr
from db.database import Database
from nlp.query_processor import QueryProcessor
# Initialize Database and Query Processor
db = Database(db_name="chat_assistant.db")
query_processor = QueryProcessor(db)
def respond(message, history):
"""Processes user queries, fetches results from the database, and returns responses."""
response = query_processor.process_query(message)
return response
# Gradio Chat UI
demo = gr.ChatInterface(
respond,
additional_inputs=[],
title="SQL Chat Assistant",
description="Ask any database-related question, and I will generate an SQL query and fetch the relevant data.",
)
if __name__ == "__main__":
demo.launch()
|