Phoenix21 commited on
Commit
7dfc5f5
·
verified ·
1 Parent(s): 19fdb92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -16
app.py CHANGED
@@ -1,18 +1,24 @@
1
- import gradio as gr
2
- from pipeline import run_pipeline
 
 
3
  def ask_dailywellness(query: str) -> str:
4
- # Ensure that the query passed to run_with_chain is a valid string
5
- if isinstance(query, str):
6
- return run_pipeline(query)
7
- else:
8
- # If for some reason the query is not a string, return an error message
9
- return "Invalid input. Please enter a valid query."
10
- interface = gr. Interface (
11
- fn=ask_dailywellness,
12
- inputs=gr.Textbox(lines=2, label="Ask DailyWellnessAI"),
13
- outputs=gr.Textbox(label="DailyWellnessAI Answer"),
14
- title="DailyWellnessAI",
15
- description="Ask about wellness or DailyWellnessAI brand. Out-of-scope"
 
 
16
  )
17
- if __name__=="__main__":
18
- interface. launch(server_name="0.0.0.0", server_port=7860)
 
 
 
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)