forked from marc-shade/Ollama-Workbench
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_autogen_compat.py
More file actions
executable file
·97 lines (78 loc) · 3.31 KB
/
test_autogen_compat.py
File metadata and controls
executable file
·97 lines (78 loc) · 3.31 KB
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
97
#!/usr/bin/env python3
"""
Test script to verify the autogen compatibility layer works correctly.
"""
import sys
import os
def test_autogen_import():
"""Test importing autogen modules through the compatibility layer."""
try:
print("Attempting to import autogen...")
import autogen
print(f"✓ Successfully imported autogen (actual package: {autogen.__name__})")
# Try to import some common submodules
print("\nTesting submodule imports:")
try:
from autogen import ConversableAgent
print(f"✓ Successfully imported ConversableAgent")
except ImportError as e:
print(f"✗ Failed to import ConversableAgent: {e}")
try:
from autogen import UserProxyAgent
print(f"✓ Successfully imported UserProxyAgent")
except ImportError as e:
print(f"✗ Failed to import UserProxyAgent: {e}")
try:
from autogen.oai import openai_utils
print(f"✓ Successfully imported autogen.oai.openai_utils")
except ImportError as e:
print(f"✗ Failed to import autogen.oai.openai_utils: {e}")
# Print version information
if hasattr(autogen, '__version__'):
print(f"\nAutogen version: {autogen.__version__}")
else:
print("\nAutogen version information not available")
return True
except ImportError as e:
print(f"✗ Failed to import autogen: {e}")
return False
def check_environment():
"""Check if the environment is set up correctly."""
print("Environment Information:")
print(f"Python version: {sys.version}")
print(f"PYTHONPATH: {os.environ.get('PYTHONPATH', 'Not set')}")
# Check if pyautogen is installed
try:
import pyautogen
print(f"✓ pyautogen is installed (version: {pyautogen.__version__ if hasattr(pyautogen, '__version__') else 'unknown'})")
except ImportError:
print("✗ pyautogen is not installed")
# Check if the compatibility layer directory is in the path
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir in sys.path or '' in sys.path:
print("✓ Current directory is in sys.path")
else:
print("✗ Current directory is not in sys.path")
# Check if the compatibility layer exists
compat_path = os.path.join(current_dir, 'autogen_compat', '__init__.py')
if os.path.exists(compat_path):
print(f"✓ Compatibility layer found at {compat_path}")
else:
print(f"✗ Compatibility layer not found at {compat_path}")
if __name__ == "__main__":
print("=" * 60)
print("AUTOGEN COMPATIBILITY LAYER TEST")
print("=" * 60)
check_environment()
print("\n" + "=" * 60)
print("TESTING AUTOGEN IMPORT")
print("=" * 60)
success = test_autogen_import()
print("\n" + "=" * 60)
print("TEST RESULT: " + ("SUCCESS" if success else "FAILURE"))
print("=" * 60)
if not success:
print("\nTo fix this issue:")
print("1. Make sure pyautogen is installed: pip install pyautogen>=0.2.0")
print("2. Run the script with the compatibility layer: ./use_autogen_compat.sh python test_autogen_compat.py")
sys.exit(0 if success else 1)