Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,17 +2,15 @@ import telebot
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
# Pega as chaves dos Secrets
|
| 6 |
TELEGRAM_TOKEN = os.environ.get('TELEGRAM_TOKEN')
|
| 7 |
GEMINI_KEY = os.environ.get('GEMINI_KEY')
|
| 8 |
SEU_ID_TELEGRAM = int(os.environ.get('SEU_ID'))
|
| 9 |
|
| 10 |
-
# Configurando a Inteligência
|
| 11 |
genai.configure(api_key=GEMINI_KEY)
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
system_instruction="Você é o assistente pessoal do Vitor. Seja inteligente e rápido."
|
| 15 |
-
)
|
| 16 |
|
| 17 |
bot = telebot.TeleBot(TELEGRAM_TOKEN)
|
| 18 |
|
|
@@ -21,11 +19,14 @@ def responder(message):
|
|
| 21 |
if message.from_user.id != SEU_ID_TELEGRAM:
|
| 22 |
return
|
| 23 |
try:
|
|
|
|
| 24 |
response = model.generate_content(message.text)
|
| 25 |
bot.reply_to(message, response.text)
|
| 26 |
except Exception as e:
|
|
|
|
| 27 |
bot.reply_to(message, f"Erro: {str(e)}")
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
| 30 |
print("Assistente Online!")
|
| 31 |
bot.infinity_polling()
|
|
|
|
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# Pega as chaves dos Secrets
|
| 6 |
TELEGRAM_TOKEN = os.environ.get('TELEGRAM_TOKEN')
|
| 7 |
GEMINI_KEY = os.environ.get('GEMINI_KEY')
|
| 8 |
SEU_ID_TELEGRAM = int(os.environ.get('SEU_ID'))
|
| 9 |
|
| 10 |
+
# Configurando a Inteligência (Jeito atualizado)
|
| 11 |
genai.configure(api_key=GEMINI_KEY)
|
| 12 |
+
# Mudamos aqui para o nome simples que a biblioteca nova exige
|
| 13 |
+
model = genai.GenerativeModel('gemini-1.5-flash')
|
|
|
|
|
|
|
| 14 |
|
| 15 |
bot = telebot.TeleBot(TELEGRAM_TOKEN)
|
| 16 |
|
|
|
|
| 19 |
if message.from_user.id != SEU_ID_TELEGRAM:
|
| 20 |
return
|
| 21 |
try:
|
| 22 |
+
# A IA processa a sua mensagem
|
| 23 |
response = model.generate_content(message.text)
|
| 24 |
bot.reply_to(message, response.text)
|
| 25 |
except Exception as e:
|
| 26 |
+
# Se der erro, ele vai te falar exatamente o que é
|
| 27 |
bot.reply_to(message, f"Erro: {str(e)}")
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
| 30 |
print("Assistente Online!")
|
| 31 |
bot.infinity_polling()
|
| 32 |
+
|