Add Ollama connection check and better error messages
This commit is contained in:
17
bot_logic.py
17
bot_logic.py
@@ -257,8 +257,23 @@ async def llm_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
|
||||
if not args:
|
||||
# Sem argumentos: mostra status atual
|
||||
ollama_status = ""
|
||||
if current == "OLLAMA":
|
||||
try:
|
||||
from llm_providers import check_ollama_connection
|
||||
status = check_ollama_connection()
|
||||
if status.get("status") == "ok":
|
||||
models = status.get("models", [])
|
||||
ollama_status = f"\n\n🔷 Ollama: ✅ Online\n Modelos: {', '.join(models[:3]) if models else 'Nenhum'}"
|
||||
elif status.get("status") == "timeout":
|
||||
ollama_status = "\n\n🔷 Ollama: ⏱️ Timeout - não respondeu"
|
||||
else:
|
||||
ollama_status = f"\n\n🔷 Ollama: ❌ {status.get('status', 'Erro desconhecido')}"
|
||||
except Exception as e:
|
||||
ollama_status = f"\n\n🔷 Ollama: ❌ Erro ao verificar"
|
||||
|
||||
await update.message.reply_text(
|
||||
f"🤖 LLM Atual: *{current}*\n\n"
|
||||
f"🤖 LLM Atual: *{current}*{ollama_status}\n\n"
|
||||
f"Para mudar: /llm gemini ou /llm ollama"
|
||||
)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user