Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions APPLE_SILICON_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ If you encounter errors related to code analysis tools like radon or flake8:

### Autogen/Pyautogen Issues

If you encounter errors related to autogen or pyautogen:
If you encounter errors related to autogen or ag2:

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

### Streamlit Extensions Issues

Expand Down Expand Up @@ -339,7 +339,7 @@ If Ollama server checks fail:
- flake8: 7.1.1
- streamlit-extras: 0.3.6
- autogen: 0.2.35
- pyautogen: 0.2.35
- ag2: 0.2.35

### Architecture Changes

Expand Down
20 changes: 10 additions & 10 deletions AUTOGEN_FIX_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ ERROR: No matching distribution found for autogen==0.2.35

### Root Causes

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`.
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`.

2. **Import Namespace Mismatch**: The code imports from the `autogen` namespace:
```python
from autogen import ConversableAgent, UserProxyAgent, GroupChat, GroupChatManager
```
But when installing `pyautogen`, the imports need to be from the `pyautogen` namespace.
But when installing `ag2`, the imports need to be from the `ag2` namespace.

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

## Solution

This fix addresses these issues by:

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

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

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

Expand Down Expand Up @@ -74,19 +74,19 @@ Run your application using the compatibility layer:

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

1. Imports `pyautogen` when code tries to import `autogen`
2. Adds the imported `pyautogen` module to `sys.modules['autogen']`
3. Also redirects submodule imports (e.g., `autogen.oai` β†’ `pyautogen.oai`)
1. Imports `ag2` when code tries to import `autogen`
2. Adds the imported `ag2` module to `sys.modules['autogen']`
3. Also redirects submodule imports (e.g., `autogen.oai` β†’ `ag2.oai`)

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

## Troubleshooting

If you encounter issues:

1. **Verify pyautogen is installed**:
1. **Verify ag2 is installed**:
```bash
pip show pyautogen
pip show ag2
```

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

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

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

Expand Down
18 changes: 9 additions & 9 deletions autogen_compat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Compatibility layer for autogen imports.
This module redirects imports from 'autogen' to 'pyautogen'.
This module redirects imports from 'autogen' to 'ag2'.
"""

import sys
Expand All @@ -9,21 +9,21 @@

# Show a warning about the compatibility layer
warnings.warn(
"Using autogen_compat layer: 'autogen' package is not available, redirecting to 'pyautogen'",
"Using autogen_compat layer: 'autogen' package is not available, redirecting to 'ag2'",
ImportWarning
)

# Try to import pyautogen
# Try to import ag2
try:
import pyautogen
import ag2
except ImportError:
raise ImportError(
"Neither 'autogen' nor 'pyautogen' package is installed. "
"Please install pyautogen with: pip install pyautogen>=0.2.0"
"Neither 'autogen' nor 'ag2' package is installed. "
"Please install ag2 with: pip install ag2>=0.2.0"
)

# Add the module to sys.modules
sys.modules['autogen'] = pyautogen
sys.modules['autogen'] = ag2

# Also make submodules available
for submodule_name in [
Expand All @@ -32,8 +32,8 @@
'function_utils', 'graph_utils', 'retrieve_utils', 'runtime_logging', 'types'
]:
try:
submodule = importlib.import_module(f'pyautogen.{submodule_name}')
submodule = importlib.import_module(f'ag2.{submodule_name}')
sys.modules[f'autogen.{submodule_name}'] = submodule
except ImportError:
# If the submodule doesn't exist in pyautogen, just skip it
# If the submodule doesn't exist in ag2, just skip it
pass
8 changes: 4 additions & 4 deletions backup_files/APPLE_SILICON_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ If you encounter errors related to code analysis tools like radon or flake8:

### Autogen/Pyautogen Issues

If you encounter errors related to autogen or pyautogen:
If you encounter errors related to autogen or ag2:

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

### Streamlit Extensions Issues

Expand Down Expand Up @@ -339,7 +339,7 @@ If Ollama server checks fail:
- flake8: 7.1.1
- streamlit-extras: 0.3.6
- autogen: 0.2.35
- pyautogen: 0.2.35
- ag2: 0.2.35

### Architecture Changes

Expand Down
2 changes: 1 addition & 1 deletion backup_files/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
langchain-community==0.2.15
langchain==0.2.15
pyautogen==0.2.35
ag2==0.2.35
Flask-Cors==5.0.0
Flask==3.0.3
Requests==2.32.3
Expand Down
6 changes: 3 additions & 3 deletions backup_files/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ if [ $? -ne 0 ]; then
$POETRY_CMD run pip install "langchain==0.2.15"
# Install missing dependencies from requirements.txt
echo "Debug: Installing missing dependencies"
$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"
$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"

# Install additional dependencies from requirements.txt that might be missing
echo "Debug: Installing additional dependencies from requirements.txt"
Expand Down Expand Up @@ -307,12 +307,12 @@ dependencies = [
"streamlit", "langchain", "transformers", "ollama",
"chromadb", "pandas", "psutil", "requests", "matplotlib",
"beautifulsoup4", "bs4", "selenium", "webdriver_manager", "PyPDF2",
"streamlit_extras", "autogen", "pyautogen", "fpdf", "radon", "flake8"
"streamlit_extras", "autogen", "ag2", "fpdf", "radon", "flake8"
]

# Add detailed error checking for critical dependencies
print("\n=== Critical Dependencies Check ===")
critical_deps = ["ollama", "chromadb", "psutil", "pdfkit", "matplotlib", "bs4", "selenium", "webdriver_manager", "PyPDF2", "streamlit_extras", "autogen", "pyautogen", "fpdf", "radon", "flake8"]
critical_deps = ["ollama", "chromadb", "psutil", "pdfkit", "matplotlib", "bs4", "selenium", "webdriver_manager", "PyPDF2", "streamlit_extras", "autogen", "ag2", "fpdf", "radon", "flake8"]
for dep in critical_deps:
try:
module = __import__(dep)
Expand Down
2 changes: 1 addition & 1 deletion fix_anaconda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ PACKAGES=(
"gtts==2.5.4"
"pygame==2.6.1"
"autogen==0.2.35"
"pyautogen==0.2.35"
"ag2==0.2.35"
"fake-useragent==1.5.1"
)

Expand Down
20 changes: 10 additions & 10 deletions fix_autogen_dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mkdir -p autogen_compat
cat > autogen_compat/__init__.py << 'EOL'
"""
Compatibility layer for autogen imports.
This module redirects imports from 'autogen' to 'pyautogen'.
This module redirects imports from 'autogen' to 'ag2'.
"""

import sys
Expand All @@ -67,21 +67,21 @@ import warnings

# Show a warning about the compatibility layer
warnings.warn(
"Using autogen_compat layer: 'autogen' package is not available, redirecting to 'pyautogen'",
"Using autogen_compat layer: 'autogen' package is not available, redirecting to 'ag2'",
ImportWarning
)

# Try to import pyautogen
# Try to import ag2
try:
import pyautogen
import ag2
except ImportError:
raise ImportError(
"Neither 'autogen' nor 'pyautogen' package is installed. "
"Please install pyautogen with: pip install pyautogen>=0.2.0"
"Neither 'autogen' nor 'ag2' package is installed. "
"Please install ag2 with: pip install ag2>=0.2.0"
)

# Add the module to sys.modules
sys.modules['autogen'] = pyautogen
sys.modules['autogen'] = ag2

# Also make submodules available
for submodule_name in [
Expand All @@ -90,10 +90,10 @@ for submodule_name in [
'function_utils', 'graph_utils', 'retrieve_utils', 'runtime_logging', 'types'
]:
try:
submodule = importlib.import_module(f'pyautogen.{submodule_name}')
submodule = importlib.import_module(f'ag2.{submodule_name}')
sys.modules[f'autogen.{submodule_name}'] = submodule
except ImportError:
# If the submodule doesn't exist in pyautogen, just skip it
# If the submodule doesn't exist in ag2, just skip it
pass
EOL

Expand Down Expand Up @@ -129,4 +129,4 @@ fi
print_header "Fix Complete"
print_info "To run your application with the compatibility layer, use:"
echo -e "${YELLOW}./use_autogen_compat.sh streamlit run main.py${NC}"
print_info "This will ensure that 'import autogen' statements are redirected to 'pyautogen'"
print_info "This will ensure that 'import autogen' statements are redirected to 'ag2'"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ torch>=2.0.0
transformers>=4.30.0

# Language Models & AI
pyautogen>=0.2.0 # Using pyautogen which provides the autogen namespace
ag2>=0.2.0 # Using ag2 which provides the autogen namespace
groq>=0.9.0
langchain>=0.2.0
langchain-community>=0.2.0
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ print_info "Installing development and testing packages..."

# Install autogen packages
print_info "Installing autogen packages..."
"$VENV_PIP" install autogen==0.2.35 pyautogen==0.2.35
"$VENV_PIP" install autogen==0.2.35 ag2==0.2.35

# Install audio packages
print_info "Installing audio packages..."
Expand Down
2 changes: 1 addition & 1 deletion setup_implementation_details.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ authors = ["Your Name <[email protected]>"]
python = "^3.11"
langchain-community = "0.2.15"
langchain = "0.2.15"
pyautogen = "0.2.35"
ag2 = "0.2.35"
Flask-Cors = "5.0.0"
Flask = "3.0.3"
Requests = "2.32.3"
Expand Down
10 changes: 5 additions & 5 deletions test_autogen_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def check_environment():
print(f"Python version: {sys.version}")
print(f"PYTHONPATH: {os.environ.get('PYTHONPATH', 'Not set')}")

# Check if pyautogen is installed
# Check if ag2 is installed
try:
import pyautogen
print(f"βœ“ pyautogen is installed (version: {pyautogen.__version__ if hasattr(pyautogen, '__version__') else 'unknown'})")
import ag2
print(f"βœ“ ag2 is installed (version: {ag2.__version__ if hasattr(ag2, '__version__') else 'unknown'})")
except ImportError:
print("βœ— pyautogen is not installed")
print("βœ— ag2 is not installed")

# Check if the compatibility layer directory is in the path
current_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -91,7 +91,7 @@ def check_environment():

if not success:
print("\nTo fix this issue:")
print("1. Make sure pyautogen is installed: pip install pyautogen>=0.2.0")
print("1. Make sure ag2 is installed: pip install ag2>=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)
2 changes: 1 addition & 1 deletion test_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ print_info "Installing development and testing packages..."

# Install autogen packages
print_info "Installing autogen packages..."
"$VENV_PIP" install autogen==0.2.35 pyautogen==0.2.35
"$VENV_PIP" install autogen==0.2.35 ag2==0.2.35

# Install audio packages
print_info "Installing audio packages..."
Expand Down