bezaime commited on
Commit
8cb130c
·
verified ·
1 Parent(s): 7eb9f14

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -70,6 +70,22 @@ 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 = ""
@@ -107,7 +123,7 @@ with gr.Blocks(theme=custom_theme) as demo:
107
  with gr.Tabs():
108
  # Chat Tab
109
  with gr.Tab("Chat"):
110
- chat_interface = gr.ChatInterface(
111
  fn=rag_memory_stream,
112
  type="messages",
113
  examples=examples,
@@ -173,4 +189,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
+ # Mock implementation of `rag_chain.stream` (replace with your actual implementation)
74
+ class MockRAGChain:
75
+ @staticmethod
76
+ def stream(message):
77
+ # Mock response stream
78
+ responses = [
79
+ f"Processing your message: '{message}'...",
80
+ "Analyzing your preferences...",
81
+ "Here are some recommendations for you!"
82
+ ]
83
+ for response in responses:
84
+ yield response # Simulate streaming by yielding responses
85
+
86
+ # Replace with the actual RAG chain if available
87
+ rag_chain = MockRAGChain()
88
+
89
  # Function for the chatbot response stream
90
  def rag_memory_stream(message, history):
91
  partial_text = ""
 
123
  with gr.Tabs():
124
  # Chat Tab
125
  with gr.Tab("Chat"):
126
+ gr.ChatInterface(
127
  fn=rag_memory_stream,
128
  type="messages",
129
  examples=examples,
 
189
 
190
  # Launch the app
191
  if __name__ == "__main__":
192
+ demo.launch()