First Commit

This commit is contained in:
marco
2026-09-03 15:34:28 -03:00
commit f97819e551
3005 changed files with 487818 additions and 0 deletions
+122
View File
@@ -0,0 +1,122 @@
import asyncio
import sys
import os
sys.path.insert(0, "/home/marco/MonicaAgentIA/app")
os.environ["TELEGRAM_BOT_TOKEN"] = "test"
os.environ["TELEGRAM_CHAT_ID"] = "123"
from monica_agent import (
ensure_min_lines,
MIN_RESPONSE_LINES,
load_user_profile,
build_system_prompt,
load_all_contexts,
build_messages_for_ai,
AIProvider,
DEFAULT_MODEL,
)
class FakeMessage:
def __init__(self, text):
self.text = text
self.chat_id = 7889499475
async def reply_text(self, text, **kwargs):
print(f"BOT RESPONSE: {text[:300]}")
class FakeUpdate:
def __init__(self, text):
self.message = FakeMessage(text)
self.effective_chat = self
self.effective_user = self
self.effective_message = self.message
@property
def id(self):
return self.message.chat_id
@property
def username(self):
return "test_user"
@property
def first_name(self):
return "Marco"
class FakeContext:
def __init__(self):
self.bot = self
async def send_message(self, **kwargs):
print(f"BOT SEND: {kwargs.get('text', '')[:300]}")
async def test_ensure_min_lines():
print("=== Testando ensure_min_lines ===")
profile = load_user_profile()
all_contexts = load_all_contexts()
recent_context = all_contexts[-10:] if len(all_contexts) > 10 else all_contexts
short_response = "Olá! Tudo bem?"
user_message = "Oi Mônica!"
print(f"Resposta curta original: '{short_response}' ({len(short_response.splitlines())} linhas)")
result = await ensure_min_lines(short_response, user_message, recent_context, profile)
print(f"Resposta após ensure_min_lines: '{result[:200]}...' ({len(result.splitlines())} linhas)")
if len(result.splitlines()) >= MIN_RESPONSE_LINES:
print(f"✅ Resposta expandida para {len(result.splitlines())} linhas (mínimo: {MIN_RESPONSE_LINES})")
else:
print(f"❌ Resposta não atingiu o mínimo de {MIN_RESPONSE_LINES} linhas")
print(f"\nConteúdo completo da resposta expandida:")
print(result)
async def test_get_monica_response():
print("\n=== Testando get_monica_response ===")
from monica_agent import get_monica_response
response = await get_monica_response("Oi Mônica!")
if response:
lines = response.splitlines()
print(f"Resposta de get_monica_response: {len(lines)} linhas")
print(f"Primeiras 3 linhas: {lines[:3]}")
if len(lines) >= MIN_RESPONSE_LINES:
print(f"✅ Resposta tem {len(lines)} linhas (mínimo: {MIN_RESPONSE_LINES})")
else:
print(f"❌ Resposta tem apenas {len(lines)} linhas (mínimo: {MIN_RESPONSE_LINES})")
print("Conteúdo completo:")
print(response)
else:
print("❌ Resposta foi None")
async def test_system_prompt_contains_min_lines():
print("\n=== Verificando se prompt base pede respostas longas ===")
from monica_agent import MONICA_SYSTEM_PROMPT_BASE, build_system_prompt, MIN_RESPONSE_LINES
if "{min_lines}" in MONICA_SYSTEM_PROMPT_BASE:
print("✅ Prompt base usa placeholder {min_lines} (configurável)")
else:
print("❌ Prompt base NÃO usa placeholder configurável")
formatted = build_system_prompt({})
expected_text = f"no mínimo {MIN_RESPONSE_LINES} linhas"
if expected_text in formatted:
print(f"✅ Prompt formatado pede pelo menos {MIN_RESPONSE_LINES} linhas")
else:
print(f"❌ Prompt formatado NÃO menciona {MIN_RESPONSE_LINES} linhas")
print(f"Prompt formatado (início): {formatted[:300]}...")
async def main():
await test_system_prompt_contains_min_lines()
await test_ensure_min_lines()
await test_get_monica_response()
print("\n=== Todos os testes concluídos ===")
if __name__ == "__main__":
asyncio.run(main())