nlp2cmd

Examples Guide

This guide provides a comprehensive overview of all NLP2CMD examples, organized by category and complexity.

πŸ—‚οΈ Examples Structure

examples/
β”œβ”€β”€ 01_basics/                     # Fundamental examples and getting started
β”‚   β”œβ”€β”€ app2schema/               # AppSpec generation from applications
β”‚   β”œβ”€β”€ docker_basics/            # Docker command examples
β”‚   └── kubernetes_basics/        # Kubernetes basics
β”œβ”€β”€ 02_benchmarks/                # Performance testing and benchmarking
β”‚   β”œβ”€β”€ performance_testing/      # Performance measurement tools
β”‚   └── sequential_testing/       # Sequential test execution
β”œβ”€β”€ 03_integrations/              # Integration with external systems
β”‚   β”œβ”€β”€ pipelines/                # Pipeline integrations
β”‚   β”œβ”€β”€ toon_format/              # Toon format examples
β”‚   └── validation/               # Validation integrations
β”œβ”€β”€ 04_domain_specific/           # Domain-specific use cases
β”‚   β”œβ”€β”€ bioinformatics/           # Bioinformatics workflows
β”‚   β”œβ”€β”€ data_science/             # Data science examples
β”‚   β”œβ”€β”€ debugging/                # Debugging workflows
β”‚   └── [10 more domains...]      # Various specialized domains
β”œβ”€β”€ 05_advanced_features/         # Advanced features and experimental
β”‚   β”œβ”€β”€ thermodynamic/            # Thermodynamic optimization
β”‚   └── [other features...]       # Advanced capabilities
β”œβ”€β”€ 06_desktop_automation/        # Desktop GUI automation
β”‚   β”œβ”€β”€ 04_browser_tabs/          # Browser tab management
β”‚   β”œβ”€β”€ 05_email_client/          # Email automation
β”‚   β”œβ”€β”€ 06_env_extract/           # API key extraction
β”‚   β”œβ”€β”€ 07_canvas_drawing/        # Canvas drawing automation
β”‚   β”œβ”€β”€ 08_captcha_solver/        # CAPTCHA solving
β”‚   └── 09_complex_commands/      # Complex command planning
β”œβ”€β”€ 07_browser_automation/        # Browser automation examples
β”‚   └── [browser examples...]     # Web automation workflows
β”œβ”€β”€ 08_api_key_management/        # API key management tools
β”‚   └── [key management...]       # Secure key handling
β”œβ”€β”€ 09_online_drawing/            # Online drawing automation
β”‚   β”œβ”€β”€ 01_draw_chat/             # Draw.chat automation
β”‚   β”œβ”€β”€ 02_picsart/               # Picsart drawing
β”‚   β”œβ”€β”€ 03_adaptive/              # Adaptive drawing
β”‚   β”œβ”€β”€ 04_object_database/       # Object database usage
β”‚   β”œβ”€β”€ 05_autonomous/            # Autonomous drawing
β”‚   β”œβ”€β”€ 06_visual_validator/      # Visual validation
β”‚   β”œβ”€β”€ 07_shape_gallery/         # Shape gallery demo
β”‚   └── [more drawing examples...] # Advanced drawing features
β”œβ”€β”€ 10_online_code_editors/       # Online code editor automation
β”‚   β”œβ”€β”€ 01_codepen_live/          # CodePen automation
β”‚   β”œβ”€β”€ 02_mycompiler_run/        # MyCompiler.io automation
β”‚   β”œβ”€β”€ 03_adaptive_code/         # Adaptive code generation
β”‚   β”œβ”€β”€ 04_jsfiddle_frontend/     # JSFiddle automation
β”‚   └── 05_dynamic_executor/      # Dynamic code execution
β”œβ”€β”€ _dynamic_orchestrator.py      # Dynamic orchestrator demo
β”œβ”€β”€ run_examples.sh               # Script to run all examples
└── README.md                     # This file

πŸš€ Quick Start Examples

1. Basics - Getting Started

Location: examples/01_basics/

# AppSpec generation
cd examples/01_basics/app2schema
python appspec_demo.py

# Docker basics
cd examples/01_basics/docker_basics
python docker_demo.py

# Kubernetes basics
cd examples/01_basics/kubernetes_basics
python k8s_demo.py

What you’ll learn:

2. Desktop Automation

Location: examples/06_desktop_automation/

# Browser tab management
cd examples/06_desktop_automation/04_browser_tabs
bash run.sh

# Canvas drawing
cd examples/06_desktop_automation/07_canvas_drawing
python canvas_demo.py

# Complex command planning
cd examples/06_desktop_automation/09_complex_commands
python complex_planner.py

What you’ll learn:

3. Online Drawing

Location: examples/09_online_drawing/

# Run all drawing examples
cd examples/09_online_drawing
./run.sh

# Individual examples
./run.sh 01_draw_chat
./run.sh 02_picsart
./run.sh 03_adaptive

What you’ll learn:

4. Online Code Editors

Location: examples/10_online_code_editors/

# CodePen automation
cd examples/10_online_code_editors/01_codepen_live
python run.py

# Dynamic code execution
cd examples/10_online_code_editors/05_dynamic_executor
python run.py --prompt "Write fibonacci in python"

What you’ll learn:

5. Dynamic Orchestrator

File: examples/_dynamic_orchestrator.py

python examples/_dynamic_orchestrator.py --prompt "Create a dashboard with charts"

What you’ll learn:

πŸ“Š Performance Benchmarks

Lightweight examples: examples/02_benchmarks/

Canonical benchmark suite: benchmarks/

# Run lightweight performance examples
python3 examples/02_benchmarks/performance_testing/benchmark.py

# Sequential testing
python3 examples/02_benchmarks/sequential_testing/benchmark.py

# Run canonical benchmark scripts
PYTHONPATH=src python3 benchmarks/llm_benchmark.py
PYTHONPATH=src python3 benchmarks/learning_benchmark.py
PYTHONPATH=src python3 benchmarks/thermodynamic_benchmark.py

πŸ”§ Domain-Specific Examples

Location: examples/04_domain_specific/

Available domains:

🎯 Running Examples

Prerequisites

  1. Install NLP2CMD:
    pip install nlp2cmd
    
  2. Configure environment:
    export NLP2CMD_MODEL="ollama/qwen2.5:7b"
    export NLP2CMD_API_BASE="http://localhost:11434"
    

Running Individual Examples

# Navigate to example directory
cd examples/[category]/[specific_example]

# Run the example
python example.py

# Or use the run script
./run.sh

Running All Examples

# Run all examples with the master script
cd examples
./run_examples.sh

# Run specific category
./run_examples.sh --category 09_online_drawing

# Run with specific options
./run_examples.sh --headless --verbose

πŸ› οΈ Configuration

Most examples support configuration via:

  1. Command line arguments:
    python example.py --model gpt-4 --headless --verbose
    
  2. Environment variables:
    export NLP2CMD_MODEL="gpt-4"
    export NLP2CMD_HEADLESS="true"
    export NLP2CMD_VERBOSE="true"
    
  3. Configuration files:
    # config.yaml
    model: "gpt-4"
    headless: true
    verbose: true
    timeout: 30000
    

πŸ“ Example Categories Explained

01_basics

Fundamental examples for beginners. Learn the core concepts of NLP2CMD.

02_benchmarks

Performance measurement and testing tools. Evaluate system performance.

03_integrations

Integration examples with external systems and APIs.

04_domain_specific

Specialized examples for specific domains and industries.

05_advanced_features

Advanced and experimental features. Cutting-edge capabilities.

06_desktop_automation

Desktop GUI automation examples. Automate desktop applications.

07_browser_automation

Browser automation examples. Web scraping and automation.

08_api_key_management

Tools for managing API keys and credentials securely.

09_online_drawing

Online drawing automation. Create art on web-based drawing tools.

10_online_code_editors

Online code editor automation. Write and execute code in web editors.

πŸ” Troubleshooting

Common Issues

  1. Model not available:
    # Pull the model
    ollama pull qwen2.5:7b
    
  2. Permission denied:
    # Make scripts executable
    chmod +x examples/**/*.sh
    
  3. Missing dependencies:
    # Install additional dependencies
    pip install playwright
    playwright install chromium
    

Getting Help

πŸš€ Next Steps

  1. Start with basics in 01_basics/
  2. Explore your domain in 04_domain_specific/
  3. Try advanced features in 05_advanced_features/
  4. Build your own examples using the patterns shown

πŸ“š Additional Resources