bezaime commited on
Commit
338a544
·
verified ·
1 Parent(s): bf16a97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -70,12 +70,16 @@ rag_chain = (
70
 
71
  import gradio as gr
72
 
73
- # Function for the chatbot response stream
74
  def rag_memory_stream(message, history):
75
  partial_text = ""
76
- for new_text in rag_chain.stream(message):
77
- partial_text += new_text
78
- yield partial_text
 
 
 
 
79
 
80
  # Function to process car preferences
81
  def process_preferences(make, budget, fuel_type):
@@ -173,4 +177,4 @@ with gr.Blocks(theme=custom_theme) as demo:
173
 
174
  # Launch the app
175
  if __name__ == "__main__":
176
- demo.launch()
 
70
 
71
  import gradio as gr
72
 
73
+ # Function for the chatbot response stream with error handling
74
  def rag_memory_stream(message, history):
75
  partial_text = ""
76
+ try:
77
+ for new_text in rag_chain.stream(message):
78
+ print(f"Processing: {new_text}") # Debugging output
79
+ partial_text += new_text
80
+ yield partial_text
81
+ except Exception as e:
82
+ yield f"An error occurred: {str(e)}"
83
 
84
  # Function to process car preferences
85
  def process_preferences(make, budget, fuel_type):
 
177
 
178
  # Launch the app
179
  if __name__ == "__main__":
180
+ demo.launch()