File size: 1,861 Bytes
9f99fe2
 
 
 
 
 
0c384f5
 
9f99fe2
7c3e9f4
 
 
 
 
 
9f99fe2
 
 
 
 
ac8786f
d86afc2
ac8786f
9f99fe2
d86afc2
0c384f5
9f99fe2
 
 
 
 
 
 
 
 
 
 
 
d86afc2
ac8786f
 
d86afc2
 
ac8786f
 
9f99fe2
0c384f5
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
48
"""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 BuddyAgentBot
from telegram.ext import CommandHandler, CallbackContext, Application, ContextTypes
from telegram import Update
from telegram.ext import (
    CommandHandler,
    CallbackContext,
    MessageHandler,
    filters
)


VERBOSE = True


async def hello(update: Update, context: CallbackContext) -> None:
    intro_text = "🤖 Welcome to BearBuddy, crafted by rexthecoder! I'm your extraordinary AI companion capable of accomplishing the impossible!\n\n💬 Feel free to ask me about anything, whether it's mouthwatering 🍔 recipes, exciting ✈️ travel destinations, effective 🏋️‍♀️ fitness routines, strategic 📱 marketing tips, or any other topic you can think of.\n\nDon't worry about the language barrier—I'm here to assist you in any language!\nHow can I assist you today?"
    await update.message.reply_text(intro_text)


class BuddyPanda(BuddyAgentBot, ):
    """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()