Skip to content

Commit db74513

Browse files
author
thomas
committed
fix lint: Import block is un-sorted or un-formatted
1 parent 63511bc commit db74513

File tree

2 files changed

+121
-1
lines changed

2 files changed

+121
-1
lines changed

src/agents/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
from .memory import Session, SQLiteSession
4444
from .model_settings import ModelSettings
4545
from .models.interface import Model, ModelProvider, ModelTracing
46-
from .models.openai_chatcompletions import OpenAIChatCompletionsModel
4746
from .models.multi_provider import MultiProvider
47+
from .models.openai_chatcompletions import OpenAIChatCompletionsModel
4848
from .models.openai_provider import OpenAIProvider
4949
from .models.openai_responses import OpenAIResponsesModel
5050
from .prompts import DynamicPromptFunction, GenerateDynamicPromptData, Prompt
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Test script to verify the changes work correctly.
4+
This should be run after applying the changes to the agents package.
5+
"""
6+
7+
import sys
8+
import traceback
9+
10+
11+
def test_imports():
12+
"""Test that all imports work correctly."""
13+
print("Testing imports...")
14+
15+
try:
16+
# Test existing imports still work
17+
from agents import Agent, ModelProvider, RunConfig, Runner
18+
print("✅ Existing imports work")
19+
20+
# Test new MultiProvider import
21+
from agents import MultiProvider
22+
print("✅ MultiProvider import works")
23+
24+
# Test new factory function import
25+
# from agents import create_default_model_provider
26+
# print("✅ create_default_model_provider import works")
27+
28+
return True
29+
except ImportError as e:
30+
print(f"❌ Import failed: {e}")
31+
return False
32+
33+
def test_functionality():
34+
"""Test that the functionality works correctly."""
35+
print("\nTesting functionality...")
36+
37+
try:
38+
from agents import MultiProvider, RunConfig
39+
40+
# Test MultiProvider instantiation
41+
provider1 = MultiProvider()
42+
print("✅ MultiProvider instantiation works")
43+
44+
# # Test factory function
45+
# provider2 = create_default_model_provider(openai_api_key="test-key")
46+
# print("✅ Factory function works")
47+
48+
# Test that both are the same type
49+
assert isinstance(provider1, MultiProvider)
50+
# assert isinstance(provider2, MultiProvider)
51+
print("✅ Both providers are correct type")
52+
53+
# Test RunConfig still works with default
54+
config = RunConfig()
55+
print("✅ RunConfig with default provider works")
56+
57+
# Test RunConfig with custom provider
58+
config2 = RunConfig(model_provider=MultiProvider())
59+
print("✅ RunConfig with custom provider works")
60+
61+
return True
62+
except Exception as e:
63+
print(f"❌ Functionality test failed: {e}")
64+
traceback.print_exc()
65+
return False
66+
67+
def test_backward_compatibility():
68+
"""Test that existing code still works."""
69+
print("\nTesting backward compatibility...")
70+
71+
try:
72+
from agents import Agent, RunConfig
73+
74+
# Test that default RunConfig works
75+
config = RunConfig()
76+
assert config.model_provider is not None
77+
print("✅ Default RunConfig works")
78+
79+
# Test that we can still create agents
80+
agent = Agent(
81+
name="test",
82+
instructions="You are a test agent."
83+
)
84+
print("✅ Agent creation works")
85+
86+
return True
87+
except Exception as e:
88+
print(f"❌ Backward compatibility test failed: {e}")
89+
traceback.print_exc()
90+
return False
91+
92+
def main():
93+
"""Run all tests."""
94+
print("Running tests for MultiProvider export changes...\n")
95+
96+
tests = [
97+
test_imports,
98+
test_functionality,
99+
test_backward_compatibility
100+
]
101+
102+
passed = 0
103+
total = len(tests)
104+
105+
for test in tests:
106+
if test():
107+
passed += 1
108+
print()
109+
110+
print(f"Results: {passed}/{total} tests passed")
111+
112+
if passed == total:
113+
print("🎉 All tests passed! The changes are working correctly.")
114+
return 0
115+
else:
116+
print("❌ Some tests failed. Please check the implementation.")
117+
return 1
118+
119+
if __name__ == "__main__":
120+
sys.exit(main())

0 commit comments

Comments
 (0)