Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -83,26 +83,34 @@ def handle_query(query):
|
|
83 |
print("Processing PDF ingestion from directory:", PDF_DIRECTORY)
|
84 |
data_ingestion_from_directory()
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
# Function to handle queries
|
87 |
def chatbot_handler(query):
|
88 |
response = handle_query(query)
|
89 |
return response
|
90 |
|
91 |
-
# Create the Gradio interface with
|
92 |
interface = gr.Interface(
|
93 |
fn=chatbot_handler,
|
94 |
-
inputs=
|
95 |
-
outputs=
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
theme="compact", # Change the theme if desired
|
100 |
-
examples=[
|
101 |
-
["What are the benefits of using Python for data analysis?"],
|
102 |
-
["How can I improve my website's performance?"],
|
103 |
-
["Tell me about the latest trends in AI."]
|
104 |
-
]
|
105 |
)
|
106 |
|
107 |
# Launch the Gradio interface
|
108 |
-
interface.launch(
|
|
|
83 |
print("Processing PDF ingestion from directory:", PDF_DIRECTORY)
|
84 |
data_ingestion_from_directory()
|
85 |
|
86 |
+
# Define the input and output components for the Gradio interface
|
87 |
+
input_component = gr.Textbox(
|
88 |
+
label="User:",
|
89 |
+
placeholder="Type your message...",
|
90 |
+
lines=2
|
91 |
+
)
|
92 |
+
|
93 |
+
output_component = gr.Textbox(
|
94 |
+
label="Bot:",
|
95 |
+
placeholder="Bot's response will appear here...",
|
96 |
+
readonly=True,
|
97 |
+
lines=2
|
98 |
+
)
|
99 |
+
|
100 |
# Function to handle queries
|
101 |
def chatbot_handler(query):
|
102 |
response = handle_query(query)
|
103 |
return response
|
104 |
|
105 |
+
# Create the Gradio interface with chat-like settings
|
106 |
interface = gr.Interface(
|
107 |
fn=chatbot_handler,
|
108 |
+
inputs=input_component,
|
109 |
+
outputs=output_component,
|
110 |
+
title="RedfernsTech Chatbot",
|
111 |
+
theme="compact",
|
112 |
+
live=True # Enables real-time updates
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
)
|
114 |
|
115 |
# Launch the Gradio interface
|
116 |
+
interface.launch()
|