Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -158,9 +158,7 @@ def conversation(qa_chain, message, history):
|
|
158 |
|
159 |
def initialize_llm_no_doc(llm_model, temperature, max_tokens, top_k, initial_prompt, progress=gr.Progress()):
|
160 |
progress(0.1, desc="Initializing HF tokenizer...")
|
161 |
-
|
162 |
progress(0.5, desc="Initializing HF Hub...")
|
163 |
-
|
164 |
llm = HuggingFaceEndpoint(
|
165 |
repo_id=llm_model,
|
166 |
huggingfacehub_api_token=api_token,
|
@@ -168,7 +166,6 @@ def initialize_llm_no_doc(llm_model, temperature, max_tokens, top_k, initial_pro
|
|
168 |
max_new_tokens=max_tokens,
|
169 |
top_k=top_k,
|
170 |
)
|
171 |
-
|
172 |
progress(0.75, desc="Defining buffer memory...")
|
173 |
memory = ConversationBufferMemory(
|
174 |
memory_key="chat_history",
|
@@ -302,16 +299,6 @@ def demo():
|
|
302 |
outputs=[chatbot, doc_source1, source1_page, doc_source2, source2_page, doc_source3, source3_page],
|
303 |
queue=False)
|
304 |
|
305 |
-
# Chatbot events without document
|
306 |
-
submit_btn_no_doc.click(conversation_no_doc,
|
307 |
-
inputs=[llm_no_doc, msg_no_doc, chatbot_no_doc],
|
308 |
-
outputs=[llm_no_doc, msg_no_doc, chatbot_no_doc],
|
309 |
-
queue=False)
|
310 |
-
clear_btn_no_doc.click(lambda:[None,""],
|
311 |
-
inputs=None,
|
312 |
-
outputs=[chatbot_no_doc, msg_no_doc],
|
313 |
-
queue=False)
|
314 |
-
|
315 |
# Initialize LLM without document for conversation
|
316 |
with gr.Tab("Initialize LLM for Chatbot without document"):
|
317 |
with gr.Row():
|
@@ -328,11 +315,25 @@ def demo():
|
|
328 |
llm_no_doc_progress = gr.Textbox(value="None", label="LLM initialization for chatbot without document")
|
329 |
with gr.Row():
|
330 |
llm_no_doc_init_btn = gr.Button("Initialize LLM for Chatbot without document")
|
|
|
|
|
|
|
|
|
|
|
331 |
|
332 |
llm_no_doc_init_btn.click(initialize_llm_no_doc,
|
333 |
inputs=[llm_no_doc_btn, slider_temperature_no_doc, slider_maxtokens_no_doc, slider_topk_no_doc, initial_prompt],
|
334 |
outputs=[llm_no_doc, llm_no_doc_progress])
|
335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
demo.queue().launch(debug=True, share=True)
|
337 |
|
338 |
if __name__ == "__main__":
|
|
|
158 |
|
159 |
def initialize_llm_no_doc(llm_model, temperature, max_tokens, top_k, initial_prompt, progress=gr.Progress()):
|
160 |
progress(0.1, desc="Initializing HF tokenizer...")
|
|
|
161 |
progress(0.5, desc="Initializing HF Hub...")
|
|
|
162 |
llm = HuggingFaceEndpoint(
|
163 |
repo_id=llm_model,
|
164 |
huggingfacehub_api_token=api_token,
|
|
|
166 |
max_new_tokens=max_tokens,
|
167 |
top_k=top_k,
|
168 |
)
|
|
|
169 |
progress(0.75, desc="Defining buffer memory...")
|
170 |
memory = ConversationBufferMemory(
|
171 |
memory_key="chat_history",
|
|
|
299 |
outputs=[chatbot, doc_source1, source1_page, doc_source2, source2_page, doc_source3, source3_page],
|
300 |
queue=False)
|
301 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
# Initialize LLM without document for conversation
|
303 |
with gr.Tab("Initialize LLM for Chatbot without document"):
|
304 |
with gr.Row():
|
|
|
315 |
llm_no_doc_progress = gr.Textbox(value="None", label="LLM initialization for chatbot without document")
|
316 |
with gr.Row():
|
317 |
llm_no_doc_init_btn = gr.Button("Initialize LLM for Chatbot without document")
|
318 |
+
with gr.Row():
|
319 |
+
msg_no_doc = gr.Textbox(placeholder="Type message to chat with lucIAna", container=True)
|
320 |
+
with gr.Row():
|
321 |
+
submit_btn_no_doc = gr.Button("Submit message")
|
322 |
+
clear_btn_no_doc = gr.ClearButton([msg_no_doc, chatbot_no_doc], value="Clear conversation")
|
323 |
|
324 |
llm_no_doc_init_btn.click(initialize_llm_no_doc,
|
325 |
inputs=[llm_no_doc_btn, slider_temperature_no_doc, slider_maxtokens_no_doc, slider_topk_no_doc, initial_prompt],
|
326 |
outputs=[llm_no_doc, llm_no_doc_progress])
|
327 |
|
328 |
+
submit_btn_no_doc.click(conversation_no_doc,
|
329 |
+
inputs=[llm_no_doc, msg_no_doc, chatbot_no_doc],
|
330 |
+
outputs=[llm_no_doc, msg_no_doc, chatbot_no_doc],
|
331 |
+
queue=False)
|
332 |
+
clear_btn_no_doc.click(lambda:[None,""],
|
333 |
+
inputs=None,
|
334 |
+
outputs=[chatbot_no_doc, msg_no_doc],
|
335 |
+
queue=False)
|
336 |
+
|
337 |
demo.queue().launch(debug=True, share=True)
|
338 |
|
339 |
if __name__ == "__main__":
|