chatbot fix3 sherika
Browse files
phase/Student_view/chatbot.py
CHANGED
|
@@ -68,9 +68,15 @@ def _reply_with_hf():
|
|
| 68 |
prompt,
|
| 69 |
max_new_tokens=220,
|
| 70 |
temperature=0.2,
|
| 71 |
-
return_full_text=False
|
|
|
|
| 72 |
)
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
except Exception as e:
|
| 75 |
err_text = ''.join(traceback.format_exception_only(type(e), e)).strip()
|
| 76 |
raise RuntimeError(f"Hugging Face API Error: {err_text}")
|
|
|
|
| 68 |
prompt,
|
| 69 |
max_new_tokens=220,
|
| 70 |
temperature=0.2,
|
| 71 |
+
return_full_text=False,
|
| 72 |
+
stream=False, # 👈 force non-streaming
|
| 73 |
)
|
| 74 |
+
if isinstance(response, str):
|
| 75 |
+
return response.strip()
|
| 76 |
+
elif isinstance(response, dict) and "generated_text" in response:
|
| 77 |
+
return response["generated_text"].strip()
|
| 78 |
+
else:
|
| 79 |
+
return str(response).strip()
|
| 80 |
except Exception as e:
|
| 81 |
err_text = ''.join(traceback.format_exception_only(type(e), e)).strip()
|
| 82 |
raise RuntimeError(f"Hugging Face API Error: {err_text}")
|