Spaces:
Running
Running
Update app.py
Browse files# Limit concurrency (HF-compatible)
demo.queue(concurrency_count=1)
app.py
CHANGED
|
@@ -14,9 +14,16 @@ from huggingface_hub.errors import HfHubHTTPError
|
|
| 14 |
|
| 15 |
HF_TOKEN = os.getenv("HF_TOKEN", None)
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
#
|
| 19 |
-
LLM_MODEL = "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
EMBEDDING_MODEL = "sentence-transformers/all-MiniLM-L6-v2"
|
| 22 |
|
|
@@ -176,7 +183,7 @@ def answer_question(question, state):
|
|
| 176 |
# GRADIO UI
|
| 177 |
# ============================================================
|
| 178 |
|
| 179 |
-
with gr.Blocks(title="PDF Q&A Chatbot"
|
| 180 |
gr.Markdown("## 📄 PDF Q&A Chatbot\nUpload a PDF and ask questions about its content.")
|
| 181 |
|
| 182 |
state = gr.State({"chunks": None, "index": None})
|
|
@@ -194,5 +201,8 @@ with gr.Blocks(title="PDF Q&A Chatbot", concurrency_limit=1) as demo:
|
|
| 194 |
pdf_input.upload(load_pdf, inputs=[pdf_input, state], outputs=[pdf_status, state])
|
| 195 |
ask_button.click(answer_question, inputs=[question, state], outputs=answer)
|
| 196 |
|
|
|
|
|
|
|
|
|
|
| 197 |
if __name__ == "__main__":
|
| 198 |
demo.launch()
|
|
|
|
| 14 |
|
| 15 |
HF_TOKEN = os.getenv("HF_TOKEN", None)
|
| 16 |
|
| 17 |
+
# Free model compatible with new HF API
|
| 18 |
+
#LLM_MODEL = "meta-llama/Llama-3.2-1B-Instruct"
|
| 19 |
+
#LLM_MODEL = "meta-llama/Llama-3.1-8B-Instruct"
|
| 20 |
+
# LLM_MODEL = "mistralai/Mistral-7B-Instruct-v0.3" Does not work
|
| 21 |
+
# LLM_MODEL ="HuggingFaceH4/zephyr-7b-beta"
|
| 22 |
+
# LLM_MODEL = "NousResearch/Hermes-2-Pro-Mistral-7B" Does not work
|
| 23 |
+
|
| 24 |
+
# Great LLM
|
| 25 |
+
LLM_MODEL = "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B"
|
| 26 |
+
#LLM_MODEL = "deepseek-ai/DeepSeek-R1-Distill-Qwen-14B"
|
| 27 |
|
| 28 |
EMBEDDING_MODEL = "sentence-transformers/all-MiniLM-L6-v2"
|
| 29 |
|
|
|
|
| 183 |
# GRADIO UI
|
| 184 |
# ============================================================
|
| 185 |
|
| 186 |
+
with gr.Blocks(title="PDF Q&A Chatbot") as demo:
|
| 187 |
gr.Markdown("## 📄 PDF Q&A Chatbot\nUpload a PDF and ask questions about its content.")
|
| 188 |
|
| 189 |
state = gr.State({"chunks": None, "index": None})
|
|
|
|
| 201 |
pdf_input.upload(load_pdf, inputs=[pdf_input, state], outputs=[pdf_status, state])
|
| 202 |
ask_button.click(answer_question, inputs=[question, state], outputs=answer)
|
| 203 |
|
| 204 |
+
# Limit concurrency (HF-compatible)
|
| 205 |
+
demo.queue(concurrency_count=1)
|
| 206 |
+
|
| 207 |
if __name__ == "__main__":
|
| 208 |
demo.launch()
|