Update app.py
Browse files
app.py
CHANGED
|
@@ -77,9 +77,10 @@ model_config = {
|
|
| 77 |
|
| 78 |
# Initialize the language model with enhanced error handling
|
| 79 |
try:
|
|
|
|
| 80 |
llm = HuggingFaceHub(
|
| 81 |
repo_id=model_config[language]["repo_id"],
|
| 82 |
-
huggingfacehub_api_token=HF_TOKEN,
|
| 83 |
model_kwargs=model_config[language]["params"]
|
| 84 |
)
|
| 85 |
|
|
@@ -164,8 +165,8 @@ if prompt:
|
|
| 164 |
|
| 165 |
except Exception as e:
|
| 166 |
error_response = {
|
| 167 |
-
"English": "Sorry, I encountered an error. Please try again later.",
|
| 168 |
-
"العربية": "عذرًا، حدث
|
| 169 |
}
|
| 170 |
st.error(error_response[language])
|
| 171 |
st.session_state.messages.append({
|
|
@@ -194,4 +195,10 @@ with st.sidebar:
|
|
| 194 |
"""
|
| 195 |
}
|
| 196 |
|
| 197 |
-
st.markdown(about_text[language])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
# Initialize the language model with enhanced error handling
|
| 79 |
try:
|
| 80 |
+
# This is the corrected line - using the proper parameter name
|
| 81 |
llm = HuggingFaceHub(
|
| 82 |
repo_id=model_config[language]["repo_id"],
|
| 83 |
+
huggingfacehub_api_token=HF_TOKEN,
|
| 84 |
model_kwargs=model_config[language]["params"]
|
| 85 |
)
|
| 86 |
|
|
|
|
| 165 |
|
| 166 |
except Exception as e:
|
| 167 |
error_response = {
|
| 168 |
+
"English": f"Sorry, I encountered an error: {str(e)}. Please try again later.",
|
| 169 |
+
"العربية": f"عذرًا، حدث خطأ: {str(e)}. يرجى المحاولة مرة أخرى لاحقًا."
|
| 170 |
}
|
| 171 |
st.error(error_response[language])
|
| 172 |
st.session_state.messages.append({
|
|
|
|
| 195 |
"""
|
| 196 |
}
|
| 197 |
|
| 198 |
+
st.markdown(about_text[language])
|
| 199 |
+
|
| 200 |
+
# Add reset button to clear conversation
|
| 201 |
+
if st.button("Reset Conversation" if language == "English" else "إعادة ضبط المحادثة"):
|
| 202 |
+
st.session_state.messages = []
|
| 203 |
+
st.session_state.memory.clear()
|
| 204 |
+
st.experimental_rerun()
|