Spaces:
Runtime error
Runtime error
File size: 1,511 Bytes
9f99fe2 7c3e9f4 9f99fe2 ac8786f 9f99fe2 7c3e9f4 9f99fe2 ac8786f 7c3e9f4 ac8786f 9f99fe2 7c3e9f4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
"""Scaffolding to host your LangChain Chatbot on Steamship and connect it to Telegram."""
from typing import List, Optional, Type
from pydantic import Field
from agent.base import LangChainAgentBot
from telegram.ext import Updater, CommandHandler, CallbackContext, Application, ContextTypes
from telegram import Update
from telegram.ext import (
CommandHandler,
ConversationHandler,
CallbackContext,
MessageHandler,
filters
)
VERBOSE = True
async def hello(update: Update, context: CallbackContext) -> None:
intro_text = f"🤖 Greetings human!🤗\nI'm a bot built by Rexthecoder\n🦾 I can do a lot of things"
await update.message.reply_text(intro_text)
class GirlfriendGPT(LangChainAgentBot, ):
"""Deploy LangChain chatbots and connect them to Telegram."""
token: str
application: Application
def __init__(self, token, application):
super().__init__()
self.application = application
# application.add_handler(CommandHandler('start', hello))
# Run the bot until the user presses Ctrl-C
# self.application.run_polling()
self.token = token
def handlers(self):
summary_handler = self.conversation_summary_handler()
self.application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.process_conversation))
self.application.add_handler(summary_handler)
self.application.add_handler(CommandHandler('start', hello))
self.application.run_polling()
|