File size: 3,236 Bytes
6a3de9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python3
"""
Simple test to verify the ModelSettings fix in the AI agent
"""

import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), '.'))

def test_model_settings_fix():
    """Test that the ModelSettings configuration is fixed"""
    print("Testing ModelSettings configuration fix...")

    try:
        # Import the agent
        from ai.agents.todo_agent import todo_agent

        # Check that it exists and has proper configuration
        assert todo_agent is not None
        print("✓ AI Agent imported successfully")

        # If we reach this point, the ModelSettings issue is fixed
        print("✓ ModelSettings configuration is correct")
        return True

    except TypeError as e:
        if "model_settings must be a ModelSettings instance" in str(e):
            print(f"✗ ModelSettings configuration error still exists: {e}")
            return False
        else:
            print(f"✗ Unexpected error: {e}")
            return False
    except ImportError as e:
        print(f"✗ Import error: {e}")
        return False
    except Exception as e:
        print(f"✗ Unexpected error: {e}")
        import traceback
        traceback.print_exc()
        return False

def test_mcp_server_import():
    """Test that MCP server can be imported without experimental tasks error"""
    print("\nTesting MCP server import...")

    try:
        import importlib.util
        import sys

        # Load the server module dynamically to avoid import conflicts
        spec = importlib.util.spec_from_file_location("mcp_server",
                                                     "ai/mcp/server.py")
        mcp_module = importlib.util.module_from_spec(spec)

        # Check if the experimental tasks import exists in the file
        with open("ai/mcp/server.py", 'r') as f:
            content = f.read()

        if "from mcp.server.experimental.tasks import ServerTaskContext" in content:
            print("✓ Experimental tasks import exists in server")
        else:
            print("✓ Experimental tasks import not found (may have been fixed)")

        # Try importing the server module normally
        from ai.mcp import server
        print("✓ MCP server imported successfully")
        return True

    except ImportError as e:
        print(f"✗ MCP server import error: {e}")
        return False
    except Exception as e:
        print(f"✗ Unexpected error importing MCP server: {e}")
        import traceback
        traceback.print_exc()
        return False

if __name__ == "__main__":
    print("Verifying AI chatbot MCP server fixes...\n")

    test1_passed = test_model_settings_fix()
    test2_passed = test_mcp_server_import()

    print(f"\nResults:")
    print(f"ModelSettings fix: {'✓ PASSED' if test1_passed else '✗ FAILED'}")
    print(f"MCP Server import: {'✓ PASSED' if test2_passed else '✗ FAILED'}")

    all_passed = test1_passed and test2_passed

    if all_passed:
        print("\n🎉 All verification tests passed!")
        print("The AI chatbot with MCP server fixes are working correctly.")
    else:
        print("\n❌ Some tests failed. Please review the errors above.")

    exit(0 if all_passed else 1)