atles / tests /test_final_web_fix.py
spartan8806's picture
ATLES codebase - Source code only
99b8067
#!/usr/bin/env python3
"""
Test Final Web Fix - End to End
Test the complete web analysis workflow:
1. URL detection and cleaning
2. Logical continuation (fetch content directly)
3. Intelligent web content summaries
"""
import sys
from pathlib import Path
# Add project root to path
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def test_complete_web_workflow():
"""Test the complete web analysis workflow"""
print("🌐 TESTING COMPLETE WEB WORKFLOW")
print("=" * 40)
try:
from atles_desktop_pyqt import ATLESCommunicationThread
comm_thread = ATLESCommunicationThread()
# Test 1: URL Detection and Function Call Generation
print("1️⃣ Testing URL detection and function call generation...")
user_message = "https://huggingface.co/papers/2508.10874 can you read this and sum it up"
# Extract URLs (simulate the URL detection)
import re
url_pattern = r'https?://[^\s<>"{}|\\^`\[\]]+'
urls = re.findall(url_pattern, user_message)
print(f" Detected URLs: {urls}")
if urls:
print(" βœ… URL detection works")
else:
print(" ❌ URL detection failed")
return False
# Test 2: URL Cleaning
print("\n2️⃣ Testing URL cleaning...")
problematic_url = "https://huggingface.co/papers/2508.10874'"
clean_url = problematic_url.strip("'\"")
print(f" Original: {problematic_url}")
print(f" Cleaned: {clean_url}")
if not clean_url.endswith("'") and not clean_url.endswith('"'):
print(" βœ… URL cleaning works")
else:
print(" ❌ URL cleaning failed")
return False
# Test 3: Logical Continuation Response Generation
print("\n3️⃣ Testing logical continuation response...")
response = comm_thread._create_url_aware_response(
user_message,
"Let me analyze this content",
urls,
False # has_fake_commands
)
print(" Generated response preview:")
print(" " + "-" * 50)
print(" " + response[:200] + "...")
print(" " + "-" * 50)
# Check for logical continuation
if "FUNCTION_CALL:fetch_url_content" in response:
print(" βœ… Uses fetch_url_content (logical continuation)")
elif "FUNCTION_CALL:check_url_accessibility" in response:
print(" ⚠️ Still using check_url_accessibility (partial fix)")
else:
print(" ❌ No function call detected")
return False
# Test 4: Intelligent Web Content Processing
print("\n4️⃣ Testing intelligent web content processing...")
# Simulate successful web content fetch result
function_result = '''Function fetch_url_content executed successfully: {
"success": true,
"url": "https://huggingface.co/papers/2508.10874",
"content": "<html><head><title>Advanced Multimodal Reasoning with Vision-Language Models</title></head><body><h1>Advanced Multimodal Reasoning</h1><p>Abstract: This paper presents novel approaches to multimodal AI systems that can process and reason about both visual and textual information. We introduce new benchmark datasets and evaluation metrics for vision-language models.</p><p>Our research focuses on improving cross-modal understanding and generation capabilities through innovative training techniques and architectural improvements.</p><div>Authors: Research Team</div><div>Published: 2024</div></body></html>",
"content_type": "text/html",
"content_length": 650,
"message": "Successfully fetched content from https://huggingface.co/papers/2508.10874"
}'''
intelligent_response = comm_thread._process_function_result(
function_result,
user_message,
response
)
print(" Intelligent response preview:")
print(" " + "-" * 50)
print(" " + intelligent_response[:300] + "...")
print(" " + "-" * 50)
# Check intelligent processing elements
checks = [
("Web Content Analysis Complete" in intelligent_response, "Analysis header"),
("Hugging Face Paper Analysis" in intelligent_response, "HF-specific analysis"),
("Advanced Multimodal Reasoning" in intelligent_response, "Title extraction"),
("Abstract" in intelligent_response or "multimodal" in intelligent_response, "Content analysis"),
("Ask me anything" in intelligent_response, "Follow-up invitation"),
('"success": true' not in intelligent_response, "Raw JSON hidden")
]
passed_checks = 0
for check, description in checks:
if check:
print(f" βœ… {description}")
passed_checks += 1
else:
print(f" ❌ Missing {description}")
if passed_checks >= 4:
print(" βœ… Intelligent processing works")
else:
print(" ❌ Intelligent processing needs work")
return False
return True
except Exception as e:
print(f"❌ Test failed: {e}")
import traceback
traceback.print_exc()
return False
def main():
"""Main test runner"""
print("🎯 FINAL WEB FIX TEST")
print("=" * 50)
print("""
TESTING COMPLETE WEB ANALYSIS WORKFLOW:
This tests the end-to-end process from URL detection
to intelligent content analysis.
""")
success = test_complete_web_workflow()
# Summary
print(f"\nπŸ“Š FINAL TEST RESULT")
print("=" * 50)
if success:
print(f"πŸŽ‰ COMPLETE WEB ANALYSIS FIX SUCCESSFUL!")
print("βœ… URL detection and cleaning works")
print("βœ… Function calls generated properly")
print("βœ… Intelligent content analysis works")
print("βœ… Hugging Face paper-specific summaries")
print("βœ… Raw JSON hidden from users")
print(f"\nπŸ’‘ ATLES NOW PROVIDES:")
print("πŸ”— Automatic URL detection")
print("🧹 Clean JSON function calls (no syntax errors)")
print("πŸ”„ Logical continuation (fetches content directly)")
print("🧠 Intelligent summaries (not raw HTML)")
print("πŸ“„ Paper-specific analysis for research content")
print("πŸ’¬ User-friendly responses with follow-up invitations")
print(f"\nπŸš€ READY FOR TESTING!")
print("Try asking ATLES: 'https://huggingface.co/papers/2508.10874 can you read this and sum it up'")
print("You should get an intelligent summary, not raw JSON or HTML!")
else:
print(f"⚠️ Web analysis still needs work")
print("Check the test output above for specific issues")
return success
if __name__ == "__main__":
try:
success = main()
if success:
print(f"\n✨ All web analysis fixes are working!")
else:
print(f"\n⚠️ Some issues remain.")
except KeyboardInterrupt:
print(f"\n⏹️ Test interrupted")
except Exception as e:
print(f"\nπŸ’₯ Test error: {e}")
import traceback
traceback.print_exc()