chahah commited on
Commit
b38713e
1 Parent(s): a58b402

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -71,12 +71,7 @@ def initialize(arxivcode):
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
82
  out=""
@@ -90,15 +85,13 @@ def handle_prompt(message, history, arxivcode):
90
  greetingsmessage = "Hi, I'm your personal arXiv reader. Ask me questions about the arXiv paper above"
91
 
92
  with gr.Blocks() as demo:
93
-
94
  arxiv_code = gr.Textbox("", label="arxiv.number")
95
-
 
96
  gr.ChatInterface(handle_prompt, type="messages", theme=gr.themes.Soft(),
97
  description=greetingsmessage,
98
- additional_inputs=[arxiv_code]
99
  )
100
 
101
  if __name__=='__main__':
102
- global rag_chain
103
- rag_chain = None
104
  demo.launch()
 
71
 
72
  return RAG(llm, docs, embeddings)
73
 
74
+ def handle_prompt(message, history, arxivcode, rag_chain):
 
 
 
 
 
75
  try:
76
  # Stream output
77
  out=""
 
85
  greetingsmessage = "Hi, I'm your personal arXiv reader. Ask me questions about the arXiv paper above"
86
 
87
  with gr.Blocks() as demo:
 
88
  arxiv_code = gr.Textbox("", label="arxiv.number")
89
+ rag_chain = initialize(arxiv_code)
90
+
91
  gr.ChatInterface(handle_prompt, type="messages", theme=gr.themes.Soft(),
92
  description=greetingsmessage,
93
+ additional_inputs=[arxiv_code, rag_chain]
94
  )
95
 
96
  if __name__=='__main__':
 
 
97
  demo.launch()