Spaces:
Runtime error
Runtime error
"""Define your LangChain chatbot.""" | |
import re | |
from abc import abstractmethod | |
from telegram import Update | |
from telegram.ext import ( | |
ConversationHandler, | |
CallbackContext, | |
) | |
from agent.tools.text_summary import ConversationSummary | |
from agent.tools.conversation import Conversation | |
SELECT_COMMAND, GET_TEXT = range(2) | |
class BuddyAgentBot(ConversationSummary, Conversation): | |
def is_verbose_logging_enabled(self): | |
return True | |
def send_message(self, message: str, update: Update) -> str: | |
"""Send a message to Telegram. | |
Note: This is a private endpoint that requires authentication.""" | |
update.message.reply_text(message) | |
return "ok" | |
def _invoke_later(self, delay_ms: int, message: str, chat_id: str): | |
self.invoke_later( | |
"send_message", | |
delay_ms=delay_ms, | |
arguments={ | |
"message": message, | |
"chat_id": chat_id, | |
}, | |
) | |
async def cancel(update: Update, context: CallbackContext) -> int: | |
"""Cancel the conversation.""" | |
await update.message.reply_text("Oops, glad to help you.") | |
return ConversationHandler.END | |