Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,24 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from pipeline import
|
|
|
|
|
3 |
def ask_dailywellness(query: str) -> str:
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
return "
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
16 |
)
|
17 |
-
|
18 |
-
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from pipeline import run_with_chain # Import the updated pipeline function
|
3 |
+
|
4 |
+
# Define a function that connects the Gradio interface to the pipeline
|
5 |
def ask_dailywellness(query: str) -> str:
|
6 |
+
try:
|
7 |
+
# Call the run_with_chain function that processes the query
|
8 |
+
response = run_with_chain(query)
|
9 |
+
return response
|
10 |
+
except Exception as e:
|
11 |
+
return f"Error processing your request: {str(e)}"
|
12 |
+
|
13 |
+
# Define the Gradio interface
|
14 |
+
interface = gr.Interface(
|
15 |
+
fn=ask_dailywellness,
|
16 |
+
inputs=gr.Textbox(lines=2, label="Ask DailyWellnessAI"),
|
17 |
+
outputs=gr.Textbox(label="DailyWellnessAI Answer"),
|
18 |
+
title="DailyWellnessAI",
|
19 |
+
description="Ask about wellness or DailyWellnessAI brand. Out-of-scope queries will be redirected with relevant information."
|
20 |
)
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
# Launch the Gradio interface with a server
|
24 |
+
interface.launch(server_name="0.0.0.0", server_port=7860, share=True)
|