We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The agent repeats itself when messaged on telegram. Im not able to replicate the bug, it repeats itself randomly.
import os import json from telegram import Update from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes from game_sdk.hosted_game.agent import Agent from game_sdk.hosted_game.functions.telegram import TelegramClient class TelegramAgent: def __init__(self, token: str): self.token = token self.api_key = os.environ.get("VIRTUALS_API_KEY") self.tg_client = TelegramClient(bot_token=self.token) # Load the JSON file for agent configuration with open('agent_simple.json') as f: agent_json = json.load(f) self.agent = Agent( api_key=self.api_key, goal=agent_json['goal'], description=agent_json['description'], world_info=agent_json['worldInfo'] ) self.reply_message_fn = self.tg_client.get_function("send_message") self.agent.add_custom_function(self.reply_message_fn) self.application = Application.builder().token(self.token).build() async def start(self, update: Update, context: ContextTypes.DEFAULT_TYPE): pass async def handle_message(self, update: Update, context: ContextTypes.DEFAULT_TYPE): user_message = update.message.text chat_id = update.message.chat_id user_id = update.message.from_user.id # React/respond to a certain event response = self.agent.react( session_id=str(user_id), # string identifier that you decide task="Reply to the user", event=f"chat_id: {chat_id} user_message: {user_message}", platform="telegram", ) def setup_handlers(self): self.application.add_handler(CommandHandler("start", self.start)) self.application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.handle_message)) def run(self): self.setup_handlers() print("Starting agent...") self.application.run_polling(drop_pending_updates=True) if __name__ == "__main__": bot_token = os.environ.get("BOT_TOKEN") if not bot_token: raise ValueError("BOT_TOKEN environment variable is not set") bot = TelegramAgent(token=bot_token) bot.run()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The agent repeats itself when messaged on telegram. Im not able to replicate the bug, it repeats itself randomly.
The text was updated successfully, but these errors were encountered: