Buckets:
| set -e | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| BLUE='\033[0;34m' | |
| PURPLE='\033[0;35m' | |
| CYAN='\033[0;36m' | |
| NC='\033[0m' | |
| PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| VENV_DIR="$PROJECT_DIR/venv" | |
| RESULTS_DIR="$PROJECT_DIR/results" | |
| LOG_FILE="$PROJECT_DIR/pipeline.log" | |
| print_status() { | |
| echo -e "${BLUE}[INFO]${NC} $1" | |
| } | |
| print_success() { | |
| echo -e "${GREEN}[SUCCESS]${NC} $1" | |
| } | |
| print_warning() { | |
| echo -e "${YELLOW}[WARNING]${NC} $1" | |
| } | |
| print_error() { | |
| echo -e "${RED}[ERROR]${NC} $1" | |
| } | |
| print_header() { | |
| echo -e "${PURPLE}================================${NC}" | |
| echo -e "${PURPLE}$1${NC}" | |
| echo -e "${PURPLE}================================${NC}" | |
| } | |
| command_exists() { | |
| command -v "$1" >/dev/null 2>&1 | |
| } | |
| setup_venv() { | |
| print_status "Setting up Python virtual environment..." | |
| if [ ! -d "$VENV_DIR" ]; then | |
| python3 -m venv "$VENV_DIR" | |
| print_success "Virtual environment created" | |
| else | |
| print_status "Virtual environment already exists" | |
| fi | |
| source "$VENV_DIR/bin/activate" | |
| print_success "Virtual environment activated" | |
| pip install --upgrade pip | |
| print_success "Pip upgraded" | |
| } | |
| install_dependencies() { | |
| print_status "Installing Python dependencies..." | |
| if [ ! -f "$PROJECT_DIR/requirements.txt" ]; then | |
| print_error "requirements.txt not found!" | |
| exit 1 | |
| fi | |
| pip install -r "$PROJECT_DIR/requirements.txt" | |
| print_success "Dependencies installed successfully" | |
| } | |
| setup_results_dir() { | |
| print_status "Setting up results directory..." | |
| if [ ! -d "$RESULTS_DIR" ]; then | |
| mkdir -p "$RESULTS_DIR" | |
| print_success "Results directory created: $RESULTS_DIR" | |
| else | |
| print_status "Results directory already exists: $RESULTS_DIR" | |
| fi | |
| mkdir -p "$RESULTS_DIR/logs" | |
| mkdir -p "$RESULTS_DIR/data" | |
| mkdir -p "$RESULTS_DIR/plots" | |
| mkdir -p "$RESULTS_DIR/reports" | |
| print_success "Results subdirectories created" | |
| } | |
| run_pipeline() { | |
| print_status "Running Language Agent Architecture Pipeline..." | |
| if [ ! -f "$PROJECT_DIR/main.py" ]; then | |
| print_error "main.py not found!" | |
| exit 1 | |
| fi | |
| print_status "Running ReAct demonstration..." | |
| python "$PROJECT_DIR/main.py" \ | |
| --config "$PROJECT_DIR/config.json" \ | |
| --output "$RESULTS_DIR/react" \ | |
| --verbose \ | |
| 2>&1 | tee "$RESULTS_DIR/logs/react.log" | |
| if [ $? -eq 0 ]; then | |
| print_success "ReAct demonstration completed successfully" | |
| else | |
| print_error "ReAct demonstration failed" | |
| exit 1 | |
| fi | |
| } | |
| generate_analysis() { | |
| print_status "Generating additional analysis..." | |
| cat > "$PROJECT_DIR/analyze_results.py" << 'EOF' | |
| """ | |
| Results Analysis Script | |
| ======================= | |
| Generates additional analysis and visualizations from pipeline results. | |
| """ | |
| import json | |
| import os | |
| import sys | |
| from pathlib import Path | |
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| import pandas as pd | |
| def load_results(results_dir): | |
| """Load all results from the results directory""" | |
| results = {} | |
| for arch_dir in Path(results_dir).glob("*/"): | |
| if arch_dir.is_dir(): | |
| arch_name = arch_dir.name | |
| results_file = arch_dir / "demonstration_results.json" | |
| if results_file.exists(): | |
| with open(results_file, 'r') as f: | |
| results[arch_name] = json.load(f) | |
| return results | |
| def generate_performance_plots(results, output_dir): | |
| """Generate performance comparison plots""" | |
| architectures = [] | |
| success_rates = [] | |
| execution_times = [] | |
| reasoning_qualities = [] | |
| for arch_name, arch_results in results.items(): | |
| if "performance_summary" in arch_results: | |
| perf = arch_results["performance_summary"] | |
| architectures.append(arch_name) | |
| success_rates.append(perf["success_rate"]) | |
| execution_times.append(perf["avg_execution_time"]) | |
| reasoning_qualities.append(perf["avg_reasoning_quality"]) | |
| fig, axes = plt.subplots(2, 2, figsize=(15, 10)) | |
| fig.suptitle('Language Agent Architecture Performance Comparison', fontsize=16) | |
| axes[0, 0].bar(architectures, success_rates, color='skyblue') | |
| axes[0, 0].set_title('Success Rate') | |
| axes[0, 0].set_ylabel('Success Rate') | |
| axes[0, 0].set_ylim(0, 1) | |
| axes[0, 1].bar(architectures, execution_times, color='lightcoral') | |
| axes[0, 1].set_title('Average Execution Time') | |
| axes[0, 1].set_ylabel('Time (seconds)') | |
| axes[1, 0].bar(architectures, reasoning_qualities, color='lightgreen') | |
| axes[1, 0].set_title('Average Reasoning Quality') | |
| axes[1, 0].set_ylabel('Quality Score') | |
| axes[1, 0].set_ylim(0, 1) | |
| x = range(len(architectures)) | |
| width = 0.25 | |
| axes[1, 1].bar([i - width for i in x], success_rates, width, label='Success Rate', alpha=0.8) | |
| axes[1, 1].bar(x, [q for q in reasoning_qualities], width, label='Reasoning Quality', alpha=0.8) | |
| axes[1, 1].set_title('Combined Performance Metrics') | |
| axes[1, 1].set_ylabel('Score') | |
| axes[1, 1].set_xticks(x) | |
| axes[1, 1].set_xticklabels(architectures) | |
| axes[1, 1].legend() | |
| plt.tight_layout() | |
| plt.savefig(output_dir / 'performance_comparison.png', dpi=300, bbox_inches='tight') | |
| plt.close() | |
| print(f"Performance plots saved to {output_dir / 'performance_comparison.png'}") | |
| def generate_summary_report(results, output_dir): | |
| """Generate a summary report""" | |
| report = { | |
| "summary": { | |
| "total_architectures": len(results), | |
| "timestamp": pd.Timestamp.now().isoformat() | |
| }, | |
| "architectures": {} | |
| } | |
| for arch_name, arch_results in results.items(): | |
| if "performance_summary" in arch_results: | |
| perf = arch_results["performance_summary"] | |
| report["architectures"][arch_name] = { | |
| "success_rate": perf["success_rate"], | |
| "avg_execution_time": perf["avg_execution_time"], | |
| "avg_reasoning_quality": perf["avg_reasoning_quality"], | |
| "total_tests": perf["total_tests"] | |
| } | |
| with open(output_dir / 'summary_report.json', 'w') as f: | |
| json.dump(report, f, indent=2) | |
| print(f"Summary report saved to {output_dir / 'summary_report.json'}") | |
| def main(): | |
| results_dir = Path("results") | |
| plots_dir = results_dir / "plots" | |
| reports_dir = results_dir / "reports" | |
| plots_dir.mkdir(exist_ok=True) | |
| reports_dir.mkdir(exist_ok=True) | |
| results = load_results(results_dir) | |
| if not results: | |
| print("No results found!") | |
| return | |
| generate_performance_plots(results, plots_dir) | |
| generate_summary_report(results, reports_dir) | |
| print("Analysis completed successfully!") | |
| if __name__ == "__main__": | |
| main() | |
| EOF | |
| python "$PROJECT_DIR/analyze_results.py" | |
| print_success "Additional analysis completed" | |
| } | |
| create_html_report() { | |
| print_status "Creating HTML report..." | |
| cat > "$RESULTS_DIR/reports/index.html" << EOF | |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Language Agent Architecture Pipeline Results</title> | |
| <style> | |
| body { font-family: Arial, sans-serif; margin: 40px; } | |
| .header { background: | |
| .section { margin: 20px 0; } | |
| .metric { display: inline-block; margin: 10px; padding: 10px; background: | |
| .success { color: green; } | |
| .error { color: red; } | |
| .warning { color: orange; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="header"> | |
| <h1>๐ค Language Agent Architecture Pipeline Results</h1> | |
| <p>Generated on: $(date)</p> | |
| </div> | |
| <div class="section"> | |
| <h2>๐ Performance Summary</h2> | |
| <p>This report contains the results of testing modern language agent architectures including ReAct, Reflexion, HippoRAG, and Nexus systems.</p> | |
| </div> | |
| <div class="section"> | |
| <h2>๐ Files Generated</h2> | |
| <ul> | |
| <li><a href="../react/demonstration_results.json">ReAct Results</a></li> | |
| <li><a href="../plots/performance_comparison.png">Performance Plots</a></li> | |
| <li><a href="summary_report.json">Summary Report</a></li> | |
| </ul> | |
| </div> | |
| <div class="section"> | |
| <h2>๐ง Configuration</h2> | |
| <p>The pipeline was run with the following configuration:</p> | |
| <ul> | |
| <li>Primary LLM Provider: Mock (for demonstration)</li> | |
| <li>Fallback Providers: Local, Mock</li> | |
| <li>Test Cases: 4 different travel planning scenarios</li> | |
| <li>Environment: Simulated travel booking system</li> | |
| </ul> | |
| </div> | |
| <div class="section"> | |
| <h2>๐ Key Findings</h2> | |
| <p>The demonstration successfully showcases the evolution of language agent architectures from simple tool usage to complex multi-agent collaboration.</p> | |
| </div> | |
| </body> | |
| </html> | |
| EOF | |
| print_success "HTML report created: $RESULTS_DIR/reports/index.html" | |
| } | |
| cleanup() { | |
| print_status "Cleaning up temporary files..." | |
| find "$PROJECT_DIR" -name "*.pyc" -delete | |
| find "$PROJECT_DIR" -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true | |
| print_success "Cleanup completed" | |
| } | |
| main() { | |
| print_header "Language Agent Architecture Pipeline" | |
| print_status "Starting complete pipeline execution..." | |
| if ! command_exists python3; then | |
| print_error "Python 3 is required but not installed!" | |
| exit 1 | |
| fi | |
| if ! command_exists pip; then | |
| print_error "pip is required but not installed!" | |
| exit 1 | |
| fi | |
| cd "$PROJECT_DIR" | |
| setup_venv | |
| install_dependencies | |
| setup_results_dir | |
| run_pipeline | |
| generate_analysis | |
| create_html_report | |
| cleanup | |
| print_header "Pipeline Execution Completed Successfully!" | |
| print_success "All components executed successfully" | |
| print_status "Results saved to: $RESULTS_DIR" | |
| print_status "Logs saved to: $LOG_FILE" | |
| print_status "HTML report: $RESULTS_DIR/reports/index.html" | |
| echo "" | |
| print_status "To view results:" | |
| echo " - Open $RESULTS_DIR/reports/index.html in your browser" | |
| echo " - Check $RESULTS_DIR/ for detailed JSON results" | |
| echo " - View $LOG_FILE for execution logs" | |
| echo "" | |
| print_success "๐ Language Agent Architecture Pipeline completed successfully!" | |
| } | |
| main "$@" | |
Xet Storage Details
- Size:
- 10.7 kB
- Xet hash:
- 3ec4084fff24bae4edde7d2d337cb522c1c4907fe862bf28f72ad63dee28972a
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.