Thilak118 commited on
Commit
b97fa03
·
verified ·
1 Parent(s): da373a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -55,16 +55,32 @@ def chatbot_interface(question: str) -> str:
55
  except Exception as e:
56
  return f"Error: {e}"
57
 
58
- # Gradio UI
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  interface = gr.Interface(
60
  fn=chatbot_interface,
61
- inputs=gr.Textbox(label="Enter your question"),
62
  outputs=gr.Textbox(label="Response"),
63
  title="RAG Chatbot",
64
- description="Ask questions about AI, ChatBots, NLP, and more.",
65
  theme="default"
66
  )
67
 
68
  # Launch the interface
69
- interface.launch()
70
-
 
55
  except Exception as e:
56
  return f"Error: {e}"
57
 
58
+ # Task 4: Gradio UI
59
+
60
+
61
+ def chatbot_interface(question: str) -> str:
62
+ """
63
+ Processes a question through the Chatbot and returns the response for Gradio.
64
+
65
+ Args:
66
+ question (str): User input question.
67
+
68
+ Returns:
69
+ str: Chatbot response with answer and sources.
70
+ """
71
+ if not question.strip():
72
+ return "Please enter a question."
73
+ return chatbot.ask(question)
74
+
75
+ # Create Gradio interface
76
  interface = gr.Interface(
77
  fn=chatbot_interface,
78
+ inputs=gr.Textbox(label="Enter your question", placeholder="e.g., What is Artificial Intelligence?"),
79
  outputs=gr.Textbox(label="Response"),
80
  title="RAG Chatbot",
81
+ description="Ask questions about AI, chatbots,RAG",
82
  theme="default"
83
  )
84
 
85
  # Launch the interface
86
+ interface.launch(share=True)