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

added break

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -1,12 +1,13 @@
1
  import os
 
 
2
  import gradio as gr
 
3
  from langchain_core.output_parsers import StrOutputParser
 
4
  from langchain_core.runnables import RunnablePassthrough
5
  from langchain_groq import ChatGroq
6
  from langchain_huggingface import HuggingFaceEmbeddings
7
- from langchain_chroma import Chroma
8
- from langchain_core.prompts import PromptTemplate
9
- import threading
10
 
11
  # Load the API key from environment variables
12
  groq_api_key = os.getenv("Groq_API_Key")
@@ -67,7 +68,7 @@ def rag_memory_stream(text):
67
  with text_lock:
68
  # If the input text has changed, reset the generation
69
  if text != current_text:
70
- return # Exit the generator if new input is detected
71
  partial_text += new_text
72
  # Yield the updated conversation history
73
  yield partial_text
@@ -88,9 +89,6 @@ demo = gr.Interface(
88
  inputs="text",
89
  outputs="text",
90
  live=True,
91
- batch=False, # Disable batching to handle each input separately
92
- max_batch_size=1, # Set batch size to 1 to process inputs one by one
93
- concurrency_limit=12,
94
  allow_flagging="never",
95
  theme=gr.themes.Soft(),
96
  )
 
1
  import os
2
+ import threading
3
+
4
  import gradio as gr
5
+ from langchain_chroma import Chroma
6
  from langchain_core.output_parsers import StrOutputParser
7
+ from langchain_core.prompts import PromptTemplate
8
  from langchain_core.runnables import RunnablePassthrough
9
  from langchain_groq import ChatGroq
10
  from langchain_huggingface import HuggingFaceEmbeddings
 
 
 
11
 
12
  # Load the API key from environment variables
13
  groq_api_key = os.getenv("Groq_API_Key")
 
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
 
89
  inputs="text",
90
  outputs="text",
91
  live=True,
 
 
 
92
  allow_flagging="never",
93
  theme=gr.themes.Soft(),
94
  )