forked from aden-hive/hive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-python.sh
More file actions
executable file
·209 lines (181 loc) · 7.05 KB
/
Copy pathsetup-python.sh
File metadata and controls
executable file
·209 lines (181 loc) · 7.05 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
#
# setup-python.sh - Python Environment Setup for Aden Agent Framework
#
# This script sets up the Python environment with all required packages
# for building and running goal-driven agents.
#
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
echo ""
echo "=================================================="
echo " Aden Agent Framework - Python Setup"
echo "=================================================="
echo ""
# Check for Python
if ! command -v python &> /dev/null && ! command -v python3 &> /dev/null; then
echo -e "${RED}Error: Python is not installed.${NC}"
echo "Please install Python 3.11+ from https://python.org"
exit 1
fi
# Use python3 if available, otherwise python
PYTHON_CMD="python3"
if ! command -v python3 &> /dev/null; then
PYTHON_CMD="python"
fi
# Check Python version
PYTHON_VERSION=$($PYTHON_CMD -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
PYTHON_MAJOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.major)')
PYTHON_MINOR=$($PYTHON_CMD -c 'import sys; print(sys.version_info.minor)')
echo -e "${BLUE}Detected Python:${NC} $PYTHON_VERSION"
if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 11 ]); then
echo -e "${RED}Error: Python 3.11+ is required (found $PYTHON_VERSION)${NC}"
echo "Please upgrade your Python installation"
exit 1
fi
if [ "$PYTHON_MINOR" -lt 11 ]; then
echo -e "${YELLOW}Warning: Python 3.11+ is recommended for best compatibility${NC}"
echo -e "${YELLOW}You have Python $PYTHON_VERSION which may work but is not officially supported${NC}"
echo ""
fi
echo -e "${GREEN}✓${NC} Python version check passed"
echo ""
# Check for pip
if ! $PYTHON_CMD -m pip --version &> /dev/null; then
echo -e "${RED}Error: pip is not installed${NC}"
echo "Please install pip for Python $PYTHON_VERSION"
exit 1
fi
echo -e "${GREEN}✓${NC} pip detected"
echo ""
# Upgrade pip, setuptools, and wheel
echo "Upgrading pip, setuptools, and wheel..."
if ! $PYTHON_CMD -m pip install --upgrade pip setuptools wheel; then
echo "Error: Failed to upgrade pip. Please check your python/venv configuration."
exit 1
fi
echo -e "${GREEN}✓${NC} Core packages upgraded"
echo ""
# Install core framework package
echo "=================================================="
echo "Installing Core Framework Package"
echo "=================================================="
echo ""
cd "$PROJECT_ROOT/core"
if [ -f "pyproject.toml" ]; then
echo "Installing framework from core/ (editable mode)..."
$PYTHON_CMD -m pip install -e . > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "${GREEN}✓${NC} Framework package installed"
else
echo -e "${YELLOW}⚠${NC} Framework installation encountered issues (may be OK if already installed)"
fi
else
echo -e "${YELLOW}⚠${NC} No pyproject.toml found in core/, skipping framework installation"
fi
echo ""
# Install tools package
echo "=================================================="
echo "Installing Tools Package (aden_tools)"
echo "=================================================="
echo ""
cd "$PROJECT_ROOT/tools"
if [ -f "pyproject.toml" ]; then
echo "Installing aden_tools from tools/ (editable mode)..."
$PYTHON_CMD -m pip install -e . > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "${GREEN}✓${NC} Tools package installed"
else
echo -e "${RED}✗${NC} Tools installation failed"
exit 1
fi
else
echo -e "${RED}Error: No pyproject.toml found in tools/${NC}"
exit 1
fi
echo ""
# Fix openai version compatibility with litellm
echo "=================================================="
echo "Fixing Package Compatibility"
echo "=================================================="
echo ""
# Check openai version
OPENAI_VERSION=$($PYTHON_CMD -c "import openai; print(openai.__version__)" 2>/dev/null || echo "not_installed")
if [ "$OPENAI_VERSION" = "not_installed" ]; then
echo "Installing openai package..."
$PYTHON_CMD -m pip install "openai>=1.0.0" > /dev/null 2>&1
echo -e "${GREEN}✓${NC} openai package installed"
elif [[ "$OPENAI_VERSION" =~ ^0\. ]]; then
echo -e "${YELLOW}Found old openai version: $OPENAI_VERSION${NC}"
echo "Upgrading to openai 1.x+ for litellm compatibility..."
$PYTHON_CMD -m pip install --upgrade "openai>=1.0.0" > /dev/null 2>&1
OPENAI_VERSION=$($PYTHON_CMD -c "import openai; print(openai.__version__)" 2>/dev/null)
echo -e "${GREEN}✓${NC} openai upgraded to $OPENAI_VERSION"
else
echo -e "${GREEN}✓${NC} openai $OPENAI_VERSION is compatible"
fi
echo ""
# Verify installations
echo "=================================================="
echo "Verifying Installation"
echo "=================================================="
echo ""
cd "$PROJECT_ROOT"
# Test framework import
if $PYTHON_CMD -c "import framework; print('framework OK')" > /dev/null 2>&1; then
echo -e "${GREEN}✓${NC} framework package imports successfully"
else
echo -e "${RED}✗${NC} framework package import failed"
echo -e "${YELLOW} Note: This may be OK if you don't need the framework${NC}"
fi
# Test aden_tools import
if $PYTHON_CMD -c "import aden_tools; print('aden_tools OK')" > /dev/null 2>&1; then
echo -e "${GREEN}✓${NC} aden_tools package imports successfully"
else
echo -e "${RED}✗${NC} aden_tools package import failed"
exit 1
fi
# Test litellm + openai compatibility
if $PYTHON_CMD -c "import litellm; print('litellm OK')" > /dev/null 2>&1; then
echo -e "${GREEN}✓${NC} litellm package imports successfully"
else
echo -e "${YELLOW}⚠${NC} litellm import had issues (may be OK if not using LLM features)"
fi
echo ""
# Print agent commands
echo "=================================================="
echo " Setup Complete!"
echo "=================================================="
echo ""
echo "Python packages installed:"
echo " • framework (core agent runtime)"
echo " • aden_tools (tools and MCP servers)"
echo " • All dependencies and compatibility fixes applied"
echo ""
echo "To run agents, use:"
echo ""
echo " ${BLUE}# From project root:${NC}"
echo " PYTHONPATH=core:exports python -m agent_name validate"
echo " PYTHONPATH=core:exports python -m agent_name info"
echo " PYTHONPATH=core:exports python -m agent_name run --input '{...}'"
echo ""
echo "Available commands for your new agent:"
echo " PYTHONPATH=core:exports python -m support_ticket_agent validate"
echo " PYTHONPATH=core:exports python -m support_ticket_agent info"
echo " PYTHONPATH=core:exports python -m support_ticket_agent run --input '{\"ticket_content\":\"...\",\"customer_id\":\"...\",\"ticket_id\":\"...\"}'"
echo ""
echo "To build new agents, use Claude Code skills:"
echo " • /building-agents - Build a new agent"
echo " • /testing-agent - Test an existing agent"
echo ""
echo "Documentation: ${PROJECT_ROOT}/README.md"
echo "Agent Examples: ${PROJECT_ROOT}/exports/"
echo ""