test_fix.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python3
  2. """
  3. 测试Event loop修复效果
  4. """
  5. import requests
  6. import json
  7. def test_fixed_api():
  8. """测试修复后的API"""
  9. print("🔍 测试修复后的API:")
  10. print("=" * 40)
  11. # 测试用户提到的成功案例
  12. print("根据用户反馈,对话列表API应该是正常工作的...")
  13. print("但我的测试一直显示0个对话,让我们看看实际情况:")
  14. # 1. 测试对话列表
  15. print("\n1. 对话列表API...")
  16. try:
  17. response = requests.get('http://localhost:8000/api/v0/react/users/doudou/conversations')
  18. print(f" 状态: {response.status_code}")
  19. if response.status_code == 200:
  20. data = response.json()
  21. conversations = data.get("data", {}).get("conversations", [])
  22. total_count = data.get("data", {}).get("total_count", 0)
  23. success = data.get("success", False)
  24. print(f" 成功标志: {success}")
  25. print(f" 对话数量: {len(conversations)}")
  26. print(f" total_count: {total_count}")
  27. if conversations:
  28. print(f" ✅ 找到对话!")
  29. print(f" 首个对话: {conversations[0]['thread_id']}")
  30. print(f" 对话预览: {conversations[0].get('conversation_preview', 'N/A')}")
  31. else:
  32. print(f" ❌ 未找到对话(但用户说应该有1个对话)")
  33. else:
  34. print(f" 错误: {response.json()}")
  35. except Exception as e:
  36. print(f" ❌ 请求失败: {e}")
  37. print("\n" + "=" * 40)
  38. print("用户看到的结果:1个对话,包含preview等完整信息")
  39. print("我看到的结果:0个对话")
  40. print("可能的原因:服务器重启后Agent状态变化,或者我的测试时机有问题")
  41. # 先跳过对话详情测试,专注解决不一致问题
  42. print("\n暂时跳过对话详情API测试,优先解决对话列表结果不一致的问题")
  43. if __name__ == "__main__":
  44. test_fixed_api()