-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_env.sh
More file actions
executable file
·70 lines (59 loc) · 2.51 KB
/
setup_env.sh
File metadata and controls
executable file
·70 lines (59 loc) · 2.51 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
#!/bin/bash
# Setup script for creating a root .venv directory for the entire project
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "Setting up virtual environment in root directory..."
# Create virtual environment if it doesn't exist
if [ ! -d ".venv" ]; then
python3.13 -m venv .venv
echo "Created new virtual environment in .venv"
else
echo "Virtual environment already exists in .venv"
fi
# Activate virtual environment and install dependencies
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
# Temporarily rename pyproject.toml files to avoid conflicts with setup.py
echo "Temporarily moving pyproject.toml files..."
if [ -f "$SCRIPT_DIR/agents/pyproject.toml" ]; then
mv "$SCRIPT_DIR/agents/pyproject.toml" "$SCRIPT_DIR/agents/pyproject.toml.bak"
fi
if [ -f "$SCRIPT_DIR/swarms/pyproject.toml" ]; then
mv "$SCRIPT_DIR/swarms/pyproject.toml" "$SCRIPT_DIR/swarms/pyproject.toml.bak"
fi
# Install the local packages in development mode
echo "Installing local packages in development mode..."
cd "$SCRIPT_DIR/agents"
pip install -e .
# Uncomment this to install swarms
#cd "$SCRIPT_DIR/swarms"
#pip install -e .
cd "$SCRIPT_DIR"
# Restore pyproject.toml files for reference
echo "Restoring pyproject.toml files..."
if [ -f "$SCRIPT_DIR/agents/pyproject.toml.bak" ]; then
mv "$SCRIPT_DIR/agents/pyproject.toml.bak" "$SCRIPT_DIR/agents/pyproject.toml"
fi
if [ -f "$SCRIPT_DIR/swarms/pyproject.toml.bak" ]; then
mv "$SCRIPT_DIR/swarms/pyproject.toml.bak" "$SCRIPT_DIR/swarms/pyproject.toml"
fi
# Ask user if they want to fix smolagents code blob parsing
echo ""
read -p "Do you want to fix smolagents code blob parsing to handle python code blocks to fix the persistent code block parsing error (highly recommended)? (y/N): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Fixing smolagents code blob parsing..."
SMOLAGENTS_UTILS=".venv/lib/python3.12/site-packages/smolagents/utils.py"
if [ -f "$SMOLAGENTS_UTILS" ]; then
# Replace the regex pattern for better code block parsing
sed -i 's/pattern = r"<code>(.*?)<\/code>"/pattern = r"Code:\\n*```(?:py|python)?\\n(.*?)\\n```<end_code>"/' "$SMOLAGENTS_UTILS"
echo "Successfully fixed smolagents code blob parsing pattern"
else
echo "Warning: smolagents utils.py not found at expected location"
fi
else
echo "Skipping smolagents code blob parsing fix"
fi
echo "Setup complete! To activate the environment, run: source .venv/bin/activate"