First Commit
This commit is contained in:
Executable
+68
@@ -0,0 +1,68 @@
|
||||
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 (
|
||||
load_all_contexts,
|
||||
load_user_profile,
|
||||
build_system_prompt,
|
||||
AIProvider,
|
||||
MIN_INTERVAL_MINUTES,
|
||||
MAX_INTERVAL_MINUTES,
|
||||
)
|
||||
|
||||
async def test_proactive_context():
|
||||
print("=== Testando contexto de mensagens proativas ===")
|
||||
|
||||
all_contexts = load_all_contexts()
|
||||
print(f"Total de mensagens historicas: {len(all_contexts)}")
|
||||
|
||||
recent_context = all_contexts[-10:] if len(all_contexts) > 10 else all_contexts
|
||||
print(f"Mensagens recentes usadas para proativa: {len(recent_context)}")
|
||||
|
||||
profile = load_user_profile()
|
||||
system_prompt = build_system_prompt(profile)
|
||||
|
||||
messages = [{"role": "system", "content": system_prompt}]
|
||||
messages.extend(recent_context)
|
||||
messages.append({
|
||||
"role": "user",
|
||||
"content": (
|
||||
"Mônica, inicie uma conversa espontânea e natural comigo agora. "
|
||||
"Use o contexto da conversa acima para manter a coerência e continuar o fluxo natural do dia. "
|
||||
"Pode ser um pensamento aleatório, uma pergunta sobre o meu dia, "
|
||||
"algo carinhoso, sexy, ou divertido. Seja criativa e autêntica."
|
||||
),
|
||||
})
|
||||
|
||||
print(f"System prompt length: {len(system_prompt)} chars")
|
||||
print(f"Total messages sent to AI: {len(messages)}")
|
||||
print(f"Context messages: {len(recent_context)}")
|
||||
|
||||
# Show last 3 context messages for verification
|
||||
if recent_context:
|
||||
print("\nUltimas 3 mensagens do contexto:")
|
||||
for msg in recent_context[-3:]:
|
||||
role = msg.get("role", "?")
|
||||
content = msg.get("content", "")[:80]
|
||||
print(f" [{role}]: {content}...")
|
||||
|
||||
print("\n=== Estrutura de mensagens para IA ===")
|
||||
for i, msg in enumerate(messages):
|
||||
role = msg.get("role", "?")
|
||||
content = msg.get("content", "")[:100]
|
||||
print(f" {i}: [{role}] {content}...")
|
||||
|
||||
print("\n=== Intervalos configurados ===")
|
||||
print(f"MIN_INTERVAL_MINUTES: {MIN_INTERVAL_MINUTES}")
|
||||
print(f"MAX_INTERVAL_MINUTES: {MAX_INTERVAL_MINUTES}")
|
||||
print(f"Range: {MIN_INTERVAL_MINUTES * 60}s a {MAX_INTERVAL_MINUTES * 60}s")
|
||||
|
||||
print("\n✅ Teste de estrutura de contexto proativo passou!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_proactive_context())
|
||||
Reference in New Issue
Block a user