|
|
|
|
|
""" |
|
|
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 |
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
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" |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
print("\n3οΈβ£ Testing logical continuation response...") |
|
|
|
|
|
response = comm_thread._create_url_aware_response( |
|
|
user_message, |
|
|
"Let me analyze this content", |
|
|
urls, |
|
|
False |
|
|
) |
|
|
|
|
|
print(" Generated response preview:") |
|
|
print(" " + "-" * 50) |
|
|
print(" " + response[:200] + "...") |
|
|
print(" " + "-" * 50) |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
print("\n4οΈβ£ Testing intelligent web content processing...") |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
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() |
|
|
|