Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,7 +30,7 @@ if os.environ["HUGGINGFACEHUB_API_TOKEN"] == "default-token":
|
|
| 30 |
# Model and embedding options
|
| 31 |
LLM_MODELS = {
|
| 32 |
"High Accuracy (Mixtral-8x7B)": "mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 33 |
-
"Balanced (Gemma-2-
|
| 34 |
"Lightweight (Mistral-7B)": "mistralai/Mistral-7B-Instruct-v0.2"
|
| 35 |
}
|
| 36 |
|
|
@@ -188,7 +188,7 @@ def initialize_qa_chain(llm_model, temperature):
|
|
| 188 |
if "503" in str(e):
|
| 189 |
return f"Error: Hugging Face API temporarily unavailable for {llm_model}. Try 'High Accuracy (Mixtral-8x7B)' or wait and retry.", None
|
| 190 |
elif "403" in str(e):
|
| 191 |
-
return f"Error: Access denied for {llm_model}.
|
| 192 |
return f"Error initializing QA chain: {str(e)}.", None
|
| 193 |
except Exception as e:
|
| 194 |
logger.error(f"Error initializing QA chain for {llm_model}: {str(e)}")
|
|
@@ -220,7 +220,7 @@ def answer_question(question, llm_model, embedding_model, temperature, chunk_siz
|
|
| 220 |
if "503" in str(e):
|
| 221 |
return f"Error: Hugging Face API temporarily unavailable for {llm_model}. Try 'High Accuracy (Mixtral-8x7B)' or wait and retry.", chat_history
|
| 222 |
elif "403" in str(e):
|
| 223 |
-
return f"Error: Access denied for {llm_model}.
|
| 224 |
return f"Error answering question: {str(e)}", chat_history
|
| 225 |
except Exception as e:
|
| 226 |
logger.error(f"Error answering question: {str(e)}")
|
|
@@ -301,7 +301,6 @@ with gr.Blocks(theme=gr.themes.Soft(), title="DocTalk: Document Q&A Chatbot") as
|
|
| 301 |
inputs=[llm_model, temperature],
|
| 302 |
outputs=[status, chat_display]
|
| 303 |
)
|
| 304 |
-
question里的
|
| 305 |
question.submit(
|
| 306 |
fn=answer_question,
|
| 307 |
inputs=[question, llm_model, embedding_model, temperature, chunk_size, chunk_overlap],
|
|
|
|
| 30 |
# Model and embedding options
|
| 31 |
LLM_MODELS = {
|
| 32 |
"High Accuracy (Mixtral-8x7B)": "mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 33 |
+
"Balanced (Gemma-2-2B)": "google/gemma-2-2b-it",
|
| 34 |
"Lightweight (Mistral-7B)": "mistralai/Mistral-7B-Instruct-v0.2"
|
| 35 |
}
|
| 36 |
|
|
|
|
| 188 |
if "503" in str(e):
|
| 189 |
return f"Error: Hugging Face API temporarily unavailable for {llm_model}. Try 'High Accuracy (Mixtral-8x7B)' or wait and retry.", None
|
| 190 |
elif "403" in str(e):
|
| 191 |
+
return f"Error: Access denied for {llm_model}. Free-tier API limits models >10GB. Try 'High Accuracy (Mixtral-8x7B)' or upgrade to Pro at https://huggingface.co/settings/billing.", None
|
| 192 |
return f"Error initializing QA chain: {str(e)}.", None
|
| 193 |
except Exception as e:
|
| 194 |
logger.error(f"Error initializing QA chain for {llm_model}: {str(e)}")
|
|
|
|
| 220 |
if "503" in str(e):
|
| 221 |
return f"Error: Hugging Face API temporarily unavailable for {llm_model}. Try 'High Accuracy (Mixtral-8x7B)' or wait and retry.", chat_history
|
| 222 |
elif "403" in str(e):
|
| 223 |
+
return f"Error: Access denied for {llm_model}. Free-tier API limits models >10GB. Try 'High Accuracy (Mixtral-8x7B)' or upgrade to Pro at https://huggingface.co/settings/billing.", chat_history
|
| 224 |
return f"Error answering question: {str(e)}", chat_history
|
| 225 |
except Exception as e:
|
| 226 |
logger.error(f"Error answering question: {str(e)}")
|
|
|
|
| 301 |
inputs=[llm_model, temperature],
|
| 302 |
outputs=[status, chat_display]
|
| 303 |
)
|
|
|
|
| 304 |
question.submit(
|
| 305 |
fn=answer_question,
|
| 306 |
inputs=[question, llm_model, embedding_model, temperature, chunk_size, chunk_overlap],
|