Spaces:
Runtime error
Runtime error
| import telebot | |
| import google.generativeai as genai | |
| import os | |
| TELEGRAM_TOKEN = os.environ.get('TELEGRAM_TOKEN') | |
| GEMINI_KEY = os.environ.get('GEMINI_KEY') | |
| SEU_ID_TELEGRAM = int(os.environ.get('SEU_ID')) | |
| genai.configure(api_key=GEMINI_KEY) | |
| model = genai.GenerativeModel('gemini-pro') | |
| bot = telebot.TeleBot(TELEGRAM_TOKEN) | |
| def responder(message): | |
| if message.from_user.id != SEU_ID_TELEGRAM: | |
| return | |
| try: | |
| # Tenta gerar a resposta | |
| response = model.generate_content(message.text) | |
| bot.reply_to(message, response.text) | |
| except Exception as e: | |
| # ISSO AQUI VAI TE DIZER O ERRO REAL | |
| bot.reply_to(message, f"Erro na IA: {str(e)}") | |
| if __name__ == "__main__": | |
| bot.infinity_polling() | |