Skip to content

Commit e78f248

Browse files
authored
Merge pull request #4 from AG2AI-Admin/migrate-pyautogen-to-ag2-f3e2f178
Migrate from pyautogen to ag2 Library
2 parents d57b4ec + 4b1c7a7 commit e78f248

13 files changed

+51
-51
lines changed

APPLE_SILICON_SETUP.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ If you encounter errors related to code analysis tools like radon or flake8:
242242

243243
### Autogen/Pyautogen Issues
244244

245-
If you encounter errors related to autogen or pyautogen:
245+
If you encounter errors related to autogen or ag2:
246246

247247
1. Make sure both packages are installed:
248248
```bash
249-
poetry run pip install autogen==0.2.35 pyautogen==0.2.35
249+
poetry run pip install autogen==0.2.35 ag2==0.2.35
250250
```
251251
2. The codebase uses autogen, so make sure to use the correct import statements:
252252
```python
@@ -259,7 +259,7 @@ If you encounter errors related to autogen or pyautogen:
259259
# Check if autogen is installed
260260
poetry run pip list | grep autogen
261261
```
262-
4. Note that autogen and pyautogen are different packages with similar functionality. The project uses autogen.
262+
4. Note that autogen and ag2 are different packages with similar functionality. The project uses autogen.
263263

264264
### Streamlit Extensions Issues
265265

@@ -339,7 +339,7 @@ If Ollama server checks fail:
339339
- flake8: 7.1.1
340340
- streamlit-extras: 0.3.6
341341
- autogen: 0.2.35
342-
- pyautogen: 0.2.35
342+
- ag2: 0.2.35
343343

344344
### Architecture Changes
345345

AUTOGEN_FIX_README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@ ERROR: No matching distribution found for autogen==0.2.35
1111

1212
### Root Causes
1313

14-
1. **Package Name Confusion**: The project is trying to install `autogen==0.2.35`, but this version doesn't exist in PyPI. The correct package name for version 0.2.35 is `pyautogen`.
14+
1. **Package Name Confusion**: The project is trying to install `autogen==0.2.35`, but this version doesn't exist in PyPI. The correct package name for version 0.2.35 is `ag2`.
1515

1616
2. **Import Namespace Mismatch**: The code imports from the `autogen` namespace:
1717
```python
1818
from autogen import ConversableAgent, UserProxyAgent, GroupChat, GroupChatManager
1919
```
20-
But when installing `pyautogen`, the imports need to be from the `pyautogen` namespace.
20+
But when installing `ag2`, the imports need to be from the `ag2` namespace.
2121

2222
3. **Strict Version Requirements**: The requirements.txt file specifies exact versions for many packages, which can cause compatibility issues across different systems.
2323

2424
## Solution
2525

2626
This fix addresses these issues by:
2727

28-
1. **Updating requirements.txt**: Using more flexible version specifications and correcting the package name from `autogen` to `pyautogen`.
28+
1. **Updating requirements.txt**: Using more flexible version specifications and correcting the package name from `autogen` to `ag2`.
2929

30-
2. **Creating a Compatibility Layer**: A Python module that redirects imports from `autogen` to `pyautogen`, allowing the code to work without modifications.
30+
2. **Creating a Compatibility Layer**: A Python module that redirects imports from `autogen` to `ag2`, allowing the code to work without modifications.
3131

3232
3. **Providing a Helper Script**: A shell script that sets up the environment correctly to use the compatibility layer.
3333

@@ -74,19 +74,19 @@ Run your application using the compatibility layer:
7474

7575
The compatibility layer creates a Python module named `autogen_compat` that:
7676

77-
1. Imports `pyautogen` when code tries to import `autogen`
78-
2. Adds the imported `pyautogen` module to `sys.modules['autogen']`
79-
3. Also redirects submodule imports (e.g., `autogen.oai``pyautogen.oai`)
77+
1. Imports `ag2` when code tries to import `autogen`
78+
2. Adds the imported `ag2` module to `sys.modules['autogen']`
79+
3. Also redirects submodule imports (e.g., `autogen.oai``ag2.oai`)
8080

8181
This allows your code to continue using `import autogen` statements without modification.
8282

8383
## Troubleshooting
8484

8585
If you encounter issues:
8686

87-
1. **Verify pyautogen is installed**:
87+
1. **Verify ag2 is installed**:
8888
```bash
89-
pip show pyautogen
89+
pip show ag2
9090
```
9191

9292
2. **Check PYTHONPATH**: Make sure the current directory is in your PYTHONPATH:
@@ -108,7 +108,7 @@ If you encounter issues:
108108

109109
While this compatibility layer provides an immediate fix, consider these long-term solutions:
110110

111-
1. **Update imports**: Gradually update your codebase to import from `pyautogen` directly
111+
1. **Update imports**: Gradually update your codebase to import from `ag2` directly
112112
2. **Use Poetry**: Consider using Poetry for dependency management, which handles these issues more gracefully
113113
3. **Loosen version requirements**: Use version ranges (e.g., `>=0.2.0,<0.3.0`) instead of exact versions
114114

autogen_compat/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Compatibility layer for autogen imports.
3-
This module redirects imports from 'autogen' to 'pyautogen'.
3+
This module redirects imports from 'autogen' to 'ag2'.
44
"""
55

66
import sys
@@ -9,21 +9,21 @@
99

1010
# Show a warning about the compatibility layer
1111
warnings.warn(
12-
"Using autogen_compat layer: 'autogen' package is not available, redirecting to 'pyautogen'",
12+
"Using autogen_compat layer: 'autogen' package is not available, redirecting to 'ag2'",
1313
ImportWarning
1414
)
1515

16-
# Try to import pyautogen
16+
# Try to import ag2
1717
try:
18-
import pyautogen
18+
import ag2
1919
except ImportError:
2020
raise ImportError(
21-
"Neither 'autogen' nor 'pyautogen' package is installed. "
22-
"Please install pyautogen with: pip install pyautogen>=0.2.0"
21+
"Neither 'autogen' nor 'ag2' package is installed. "
22+
"Please install ag2 with: pip install ag2>=0.2.0"
2323
)
2424

2525
# Add the module to sys.modules
26-
sys.modules['autogen'] = pyautogen
26+
sys.modules['autogen'] = ag2
2727

2828
# Also make submodules available
2929
for submodule_name in [
@@ -32,8 +32,8 @@
3232
'function_utils', 'graph_utils', 'retrieve_utils', 'runtime_logging', 'types'
3333
]:
3434
try:
35-
submodule = importlib.import_module(f'pyautogen.{submodule_name}')
35+
submodule = importlib.import_module(f'ag2.{submodule_name}')
3636
sys.modules[f'autogen.{submodule_name}'] = submodule
3737
except ImportError:
38-
# If the submodule doesn't exist in pyautogen, just skip it
38+
# If the submodule doesn't exist in ag2, just skip it
3939
pass

backup_files/APPLE_SILICON_SETUP.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ If you encounter errors related to code analysis tools like radon or flake8:
242242

243243
### Autogen/Pyautogen Issues
244244

245-
If you encounter errors related to autogen or pyautogen:
245+
If you encounter errors related to autogen or ag2:
246246

247247
1. Make sure both packages are installed:
248248
```bash
249-
poetry run pip install autogen==0.2.35 pyautogen==0.2.35
249+
poetry run pip install autogen==0.2.35 ag2==0.2.35
250250
```
251251
2. The codebase uses autogen, so make sure to use the correct import statements:
252252
```python
@@ -259,7 +259,7 @@ If you encounter errors related to autogen or pyautogen:
259259
# Check if autogen is installed
260260
poetry run pip list | grep autogen
261261
```
262-
4. Note that autogen and pyautogen are different packages with similar functionality. The project uses autogen.
262+
4. Note that autogen and ag2 are different packages with similar functionality. The project uses autogen.
263263

264264
### Streamlit Extensions Issues
265265

@@ -339,7 +339,7 @@ If Ollama server checks fail:
339339
- flake8: 7.1.1
340340
- streamlit-extras: 0.3.6
341341
- autogen: 0.2.35
342-
- pyautogen: 0.2.35
342+
- ag2: 0.2.35
343343

344344
### Architecture Changes
345345

backup_files/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
langchain-community==0.2.15
22
langchain==0.2.15
3-
pyautogen==0.2.35
3+
ag2==0.2.35
44
Flask-Cors==5.0.0
55
Flask==3.0.3
66
Requests==2.32.3

backup_files/setup.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ if [ $? -ne 0 ]; then
205205
$POETRY_CMD run pip install "langchain==0.2.15"
206206
# Install missing dependencies from requirements.txt
207207
echo "Debug: Installing missing dependencies"
208-
$POETRY_CMD run pip install "ollama==0.2.0" "chromadb==0.5.5" "psutil==6.0.0" "pdfkit==1.0.0" "matplotlib==3.9.2" "beautifulsoup4==4.12.3" "bs4==0.0.2" "selenium==4.24.0" "webdriver-manager==4.0.2" "PyPDF2==3.0.1" "streamlit-extras==0.3.6" "autogen==0.2.35" "pyautogen==0.2.35" "fpdf==1.7.2" "radon==6.0.1" "flake8==7.1.1"
208+
$POETRY_CMD run pip install "ollama==0.2.0" "chromadb==0.5.5" "psutil==6.0.0" "pdfkit==1.0.0" "matplotlib==3.9.2" "beautifulsoup4==4.12.3" "bs4==0.0.2" "selenium==4.24.0" "webdriver-manager==4.0.2" "PyPDF2==3.0.1" "streamlit-extras==0.3.6" "autogen==0.2.35" "ag2==0.2.35" "fpdf==1.7.2" "radon==6.0.1" "flake8==7.1.1"
209209

210210
# Install additional dependencies from requirements.txt that might be missing
211211
echo "Debug: Installing additional dependencies from requirements.txt"
@@ -307,12 +307,12 @@ dependencies = [
307307
"streamlit", "langchain", "transformers", "ollama",
308308
"chromadb", "pandas", "psutil", "requests", "matplotlib",
309309
"beautifulsoup4", "bs4", "selenium", "webdriver_manager", "PyPDF2",
310-
"streamlit_extras", "autogen", "pyautogen", "fpdf", "radon", "flake8"
310+
"streamlit_extras", "autogen", "ag2", "fpdf", "radon", "flake8"
311311
]
312312
313313
# Add detailed error checking for critical dependencies
314314
print("\n=== Critical Dependencies Check ===")
315-
critical_deps = ["ollama", "chromadb", "psutil", "pdfkit", "matplotlib", "bs4", "selenium", "webdriver_manager", "PyPDF2", "streamlit_extras", "autogen", "pyautogen", "fpdf", "radon", "flake8"]
315+
critical_deps = ["ollama", "chromadb", "psutil", "pdfkit", "matplotlib", "bs4", "selenium", "webdriver_manager", "PyPDF2", "streamlit_extras", "autogen", "ag2", "fpdf", "radon", "flake8"]
316316
for dep in critical_deps:
317317
try:
318318
module = __import__(dep)

fix_anaconda.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ PACKAGES=(
5959
"gtts==2.5.4"
6060
"pygame==2.6.1"
6161
"autogen==0.2.35"
62-
"pyautogen==0.2.35"
62+
"ag2==0.2.35"
6363
"fake-useragent==1.5.1"
6464
)
6565

fix_autogen_dependency.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ mkdir -p autogen_compat
5858
cat > autogen_compat/__init__.py << 'EOL'
5959
"""
6060
Compatibility layer for autogen imports.
61-
This module redirects imports from 'autogen' to 'pyautogen'.
61+
This module redirects imports from 'autogen' to 'ag2'.
6262
"""
6363
6464
import sys
@@ -67,21 +67,21 @@ import warnings
6767
6868
# Show a warning about the compatibility layer
6969
warnings.warn(
70-
"Using autogen_compat layer: 'autogen' package is not available, redirecting to 'pyautogen'",
70+
"Using autogen_compat layer: 'autogen' package is not available, redirecting to 'ag2'",
7171
ImportWarning
7272
)
7373
74-
# Try to import pyautogen
74+
# Try to import ag2
7575
try:
76-
import pyautogen
76+
import ag2
7777
except ImportError:
7878
raise ImportError(
79-
"Neither 'autogen' nor 'pyautogen' package is installed. "
80-
"Please install pyautogen with: pip install pyautogen>=0.2.0"
79+
"Neither 'autogen' nor 'ag2' package is installed. "
80+
"Please install ag2 with: pip install ag2>=0.2.0"
8181
)
8282
8383
# Add the module to sys.modules
84-
sys.modules['autogen'] = pyautogen
84+
sys.modules['autogen'] = ag2
8585
8686
# Also make submodules available
8787
for submodule_name in [
@@ -90,10 +90,10 @@ for submodule_name in [
9090
'function_utils', 'graph_utils', 'retrieve_utils', 'runtime_logging', 'types'
9191
]:
9292
try:
93-
submodule = importlib.import_module(f'pyautogen.{submodule_name}')
93+
submodule = importlib.import_module(f'ag2.{submodule_name}')
9494
sys.modules[f'autogen.{submodule_name}'] = submodule
9595
except ImportError:
96-
# If the submodule doesn't exist in pyautogen, just skip it
96+
# If the submodule doesn't exist in ag2, just skip it
9797
pass
9898
EOL
9999

@@ -129,4 +129,4 @@ fi
129129
print_header "Fix Complete"
130130
print_info "To run your application with the compatibility layer, use:"
131131
echo -e "${YELLOW}./use_autogen_compat.sh streamlit run main.py${NC}"
132-
print_info "This will ensure that 'import autogen' statements are redirected to 'pyautogen'"
132+
print_info "This will ensure that 'import autogen' statements are redirected to 'ag2'"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ torch>=2.0.0
2424
transformers>=4.30.0
2525

2626
# Language Models & AI
27-
pyautogen>=0.2.0 # Using pyautogen which provides the autogen namespace
27+
ag2>=0.2.0 # Using ag2 which provides the autogen namespace
2828
groq>=0.9.0
2929
langchain>=0.2.0
3030
langchain-community>=0.2.0

setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ print_info "Installing development and testing packages..."
381381

382382
# Install autogen packages
383383
print_info "Installing autogen packages..."
384-
"$VENV_PIP" install autogen==0.2.35 pyautogen==0.2.35
384+
"$VENV_PIP" install autogen==0.2.35 ag2==0.2.35
385385

386386
# Install audio packages
387387
print_info "Installing audio packages..."

0 commit comments

Comments
 (0)