Abid Ali Awan commited on
Commit
65923fa
·
1 Parent(s): 5f3bedf

revert back

Browse files
Files changed (1) hide show
  1. app.py +1 -15
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import os
2
- import threading
3
 
4
  import gradio as gr
5
  from langchain_chroma import Chroma
@@ -51,24 +50,10 @@ rag_chain = (
51
  | StrOutputParser()
52
  )
53
 
54
- # Global variable to store the current input text
55
- current_text = ""
56
-
57
- # Lock to synchronize access to current_text
58
- text_lock = threading.Lock()
59
-
60
-
61
  # Define the function to stream the RAG memory
62
  def rag_memory_stream(text):
63
- global current_text
64
- with text_lock:
65
- current_text = text # Update the current text input
66
  partial_text = ""
67
  for new_text in rag_chain.stream(text):
68
- with text_lock:
69
- # If the input text has changed, reset the generation
70
- if text != current_text:
71
- break
72
  partial_text += new_text
73
  # Yield the updated conversation history
74
  yield partial_text
@@ -91,6 +76,7 @@ demo = gr.Interface(
91
  live=True,
92
  allow_flagging="never",
93
  theme=gr.themes.Soft(),
 
94
  )
95
 
96
  # Launch the Gradio interface
 
1
  import os
 
2
 
3
  import gradio as gr
4
  from langchain_chroma import Chroma
 
50
  | StrOutputParser()
51
  )
52
 
 
 
 
 
 
 
 
53
  # Define the function to stream the RAG memory
54
  def rag_memory_stream(text):
 
 
 
55
  partial_text = ""
56
  for new_text in rag_chain.stream(text):
 
 
 
 
57
  partial_text += new_text
58
  # Yield the updated conversation history
59
  yield partial_text
 
76
  live=True,
77
  allow_flagging="never",
78
  theme=gr.themes.Soft(),
79
+ stop_btn=True,
80
  )
81
 
82
  # Launch the Gradio interface