chahah commited on
Commit
c4e05f8
1 Parent(s): 73c9b3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -71,16 +71,11 @@ def initialize(arxivcode):
71
 
72
  return RAG(llm, docs, embeddings)
73
 
74
- rag_chain = None
75
-
76
  def handle_prompt(message, history, arxivcode):
77
- try:
78
- rag_chain
79
- except UnboundLocalError:
80
  # initialize RAG chain
81
- # RAG chain
82
  rag_chain = initialize(arxivcode)
83
- global rag_chain
84
 
85
  try:
86
  # Stream output
@@ -103,5 +98,7 @@ with gr.Blocks() as demo:
103
  additional_inputs=[arxiv_code]
104
  )
105
 
 
 
106
 
107
- demo.launch()
 
71
 
72
  return RAG(llm, docs, embeddings)
73
 
 
 
74
  def handle_prompt(message, history, arxivcode):
75
+ if rag_chain is None:
 
 
76
  # initialize RAG chain
 
77
  rag_chain = initialize(arxivcode)
78
+
79
 
80
  try:
81
  # Stream output
 
98
  additional_inputs=[arxiv_code]
99
  )
100
 
101
+ if __name__=='__main__':
102
+ rag_chain = None
103
 
104
+ demo.launch()