"""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 VERBOSE = True class GirlFriendAIConfig(): elevenlabs_api_key: str = Field( default="", description="Optional API KEY for ElevenLabs Voice Bot" ) elevenlabs_voice_id: str = Field( default="", description="Optional voice_id for ElevenLabs Voice Bot" ) 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 # async def echo(self, update: Update, context: CallbackContext) -> None: # """Echo the user message.""" # await update.message.reply_text(update.message.text) # def voice_tool(self) -> Optional[Tool]: # """Return tool to generate spoken version of output text.""" # # return None # return GenerateSpeechTool( # client=self.client, # voice_id=self.config.elevenlabs_voice_id, # elevenlabs_api_key=self.config.elevenlabs_api_key, # ) # def get_memory(self, chat_id): # if self.context and self.context.invocable_instance_handle: # my_instance_handle = self.context.invocable_instance_handle # else: # my_instance_handle = "local-instance-handle" # memory = ConversationBufferMemory( # memory_key="chat_history", # chat_memory=ChatMessageHistory( # client=self.client, key=f"history-{chat_id}-{my_instance_handle}" # ), # return_messages=True, # ) # return memory