Spaces:
Sleeping
Sleeping
Download logged_in_bot/handler.py from ucGroupProj/Agentic-Chat-bot: direct link, hf CLI and curl.
- Browser
- Download file 633 Bytes
-
https://huggingface.co/spaces/ucGroupProj/Agentic-Chat-bot/resolve/main/logged_in_bot/handler.py
- Command line
-
hf download hf://spaces/ucGroupProj/Agentic-Chat-bot/logged_in_bot/handler.py
-
curl -L -o handler.py https://huggingface.co/spaces/ucGroupProj/Agentic-Chat-bot/resolve/main/logged_in_bot/handler.py
633 Bytes
| # /logged_in_bot/handler.py | |
| from agenticcore.chatbot.services import ChatBot | |
| _bot = ChatBot() | |
| def handle_turn(message, history, user): | |
| history = history or [] | |
| try: | |
| res = _bot.reply(message) | |
| reply = res.get("reply") or "Noted." | |
| label = res.get("sentiment") | |
| conf = res.get("confidence") | |
| if label is not None and conf is not None: | |
| reply = f"{reply} (sentiment: {label}, confidence: {float(conf):.2f})" | |
| except Exception as e: | |
| reply = f"Sorry—error in ChatBot: {type(e).__name__}. Using fallback." | |
| history = history + [[message, reply]] | |
| return history | |