Download chatbot/src/predict.py from Vivekkrishu/Chatbot: direct link, hf CLI and curl.
- Browser
- Download file 399 Bytes
-
https://huggingface.co/Vivekkrishu/Chatbot/resolve/main/chatbot/src/predict.py
- Command line
-
hf download hf://Vivekkrishu/Chatbot/chatbot/src/predict.py
-
curl -L -o predict.py https://huggingface.co/Vivekkrishu/Chatbot/resolve/main/chatbot/src/predict.py
399 Bytes
| import joblib | |
| from preprocess import clean_text | |
| import random | |
| # Load model & responses | |
| model = joblib.load("models/lms_chatbot.joblib") | |
| responses = joblib.load("models/responses.joblib") | |
| def chatbot_response(user_input: str) -> str: | |
| cleaned = clean_text(user_input) | |
| tag = model.predict([cleaned])[0] | |
| return random.choice(responses.get(tag, ["Sorry, I don't understand."])) | |