From 9ba76e53551e44e793ad3d62e7fad9f263ff726d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 4 Jan 2026 10:07:59 +0000 Subject: [PATCH] feat: Add smart widgets ILM slow model configuration This commit introduces the necessary files and configurations to enable smart widgets with ILM support, prioritizing slow and cost-optimized models. It includes JSON configuration, environment variables, a Python script for customization, a shell script for enabling, documentation, and a GitHub Actions workflow. Co-authored-by: jcjamilo --- .cursor/smart-widgets-config.json | 28 ++++ .cursor/smart-widgets.env | 9 ++ .github/workflows/smart-widgets-ilm.yml | 62 +++++++++ docs/SMART_WIDGETS_ILM.md | 174 ++++++++++++++++++++++++ scripts/configure-slow-models.py | 133 ++++++++++++++++++ scripts/enable-smart-widgets-ilm.sh | 78 +++++++++++ 6 files changed, 484 insertions(+) create mode 100644 .cursor/smart-widgets-config.json create mode 100644 .cursor/smart-widgets.env create mode 100644 .github/workflows/smart-widgets-ilm.yml create mode 100644 docs/SMART_WIDGETS_ILM.md create mode 100755 scripts/configure-slow-models.py create mode 100755 scripts/enable-smart-widgets-ilm.sh diff --git a/.cursor/smart-widgets-config.json b/.cursor/smart-widgets-config.json new file mode 100644 index 000000000..c1b1fb660 --- /dev/null +++ b/.cursor/smart-widgets-config.json @@ -0,0 +1,28 @@ +{ + "smartWidgets": { + "enabled": true, + "native": true, + "ilm": { + "enabled": true, + "available": true, + "modelType": "slow", + "modelConfig": { + "useSlowModels": true, + "modelSpeed": "slow", + "costOptimized": true, + "timeout": 30000, + "retryAttempts": 3, + "modelOptions": { + "preferCheaper": true, + "allowLongerWait": true, + "batchProcessing": true + } + } + }, + "settings": { + "autoEnable": true, + "fallbackToFast": false, + "preferSlowModels": true + } + } +} \ No newline at end of file diff --git a/.cursor/smart-widgets.env b/.cursor/smart-widgets.env new file mode 100644 index 000000000..7395c3092 --- /dev/null +++ b/.cursor/smart-widgets.env @@ -0,0 +1,9 @@ +# Smart Widgets Configuration +# Generated by enable-smart-widgets-ilm.sh +SMART_WIDGETS_ENABLED=true +SMART_WIDGETS_NATIVE=true +ILM_ENABLED=true +ILM_AVAILABLE=true +ILM_MODEL_TYPE=slow +ILM_USE_SLOW_MODELS=true +ILM_COST_OPTIMIZED=true diff --git a/.github/workflows/smart-widgets-ilm.yml b/.github/workflows/smart-widgets-ilm.yml new file mode 100644 index 000000000..737aa4a40 --- /dev/null +++ b/.github/workflows/smart-widgets-ilm.yml @@ -0,0 +1,62 @@ +name: Smart Widgets Ilm Configuration + +on: + workflow_dispatch: + inputs: + useSlowModels: + description: 'Use slow models' + required: false + default: 'true' + type: boolean + costOptimized: + description: 'Cost optimized mode' + required: false + default: 'true' + type: boolean + push: + branches: + - 'cursor/**' + paths: + - '.cursor/smart-widgets-config.json' + - 'scripts/enable-smart-widgets-ilm.sh' + - 'scripts/configure-slow-models.py' + +jobs: + configure-smart-widgets: + runs-on: ubuntu-latest + name: Configure Smart Widgets with Ilm + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Configure Smart Widgets with Ilm (Slow Models) + run: | + python3 scripts/configure-slow-models.py \ + useSlowModels=${{ github.event.inputs.useSlowModels || 'true' }} \ + costOptimized=${{ github.event.inputs.costOptimized || 'true' }} + + - name: Enable Smart Widgets + run: | + chmod +x scripts/enable-smart-widgets-ilm.sh + bash scripts/enable-smart-widgets-ilm.sh + + - name: Validate Configuration + run: | + if [ -f .cursor/smart-widgets-config.json ]; then + python3 -m json.tool .cursor/smart-widgets-config.json > /dev/null + echo "āœ… Configuration is valid" + else + echo "āŒ Configuration file not found" + exit 1 + fi + + - name: Display Configuration + run: | + echo "šŸ“‹ Final Configuration:" + cat .cursor/smart-widgets-config.json | python3 -m json.tool diff --git a/docs/SMART_WIDGETS_ILM.md b/docs/SMART_WIDGETS_ILM.md new file mode 100644 index 000000000..adb6980da --- /dev/null +++ b/docs/SMART_WIDGETS_ILM.md @@ -0,0 +1,174 @@ +# Smart Widgets Native with Ilm (Slow Models) + +This document describes the process for enabling and configuring Smart Widgets with Ilm support using slow models. + +## Overview + +Smart Widgets Native with Ilm provides an intelligent widget system that uses slower, cost-optimized models for processing. This configuration is ideal for scenarios where cost optimization is prioritized over speed. + +## Features + +- āœ… Native Smart Widgets support +- āœ… Ilm integration available +- āœ… Slow model configuration for cost optimization +- āœ… Configurable timeout and retry settings +- āœ… Automated workflow support + +## Quick Start + +### Option 1: Using the Shell Script + +```bash +# Make the script executable +chmod +x scripts/enable-smart-widgets-ilm.sh + +# Run the script +bash scripts/enable-smart-widgets-ilm.sh + +# Source the environment variables +source .cursor/smart-widgets.env +``` + +### Option 2: Using the Python Script + +```bash +# Configure with default slow model settings +python3 scripts/configure-slow-models.py + +# Or customize settings +python3 scripts/configure-slow-models.py timeout=60000 retryAttempts=5 +``` + +### Option 3: Manual Configuration + +1. Ensure the `.cursor` directory exists: + ```bash + mkdir -p .cursor + ``` + +2. Create or update `.cursor/smart-widgets-config.json`: + ```json + { + "smartWidgets": { + "enabled": true, + "native": true, + "ilm": { + "enabled": true, + "available": true, + "modelType": "slow", + "modelConfig": { + "useSlowModels": true, + "modelSpeed": "slow", + "costOptimized": true, + "timeout": 30000, + "retryAttempts": 3 + } + }, + "settings": { + "autoEnable": true, + "fallbackToFast": false, + "preferSlowModels": true + } + } + } + ``` + +3. Source the environment file: + ```bash + source .cursor/smart-widgets.env + ``` + +## Configuration Options + +### Model Configuration + +- `useSlowModels`: Enable slow model usage (default: `true`) +- `modelSpeed`: Model speed setting (default: `"slow"`) +- `costOptimized`: Enable cost optimization (default: `true`) +- `timeout`: Request timeout in milliseconds (default: `30000`) +- `retryAttempts`: Number of retry attempts (default: `3`) + +### Smart Widgets Settings + +- `enabled`: Enable Smart Widgets (default: `true`) +- `native`: Enable native mode (default: `true`) +- `autoEnable`: Automatically enable widgets (default: `true`) +- `fallbackToFast`: Fallback to fast models on failure (default: `false`) +- `preferSlowModels`: Prefer slow models over fast ones (default: `true`) + +## Environment Variables + +The following environment variables are set when using the enable script: + +- `SMART_WIDGETS_ENABLED=true` +- `SMART_WIDGETS_NATIVE=true` +- `ILM_ENABLED=true` +- `ILM_AVAILABLE=true` +- `ILM_MODEL_TYPE=slow` +- `ILM_USE_SLOW_MODELS=true` +- `ILM_COST_OPTIMIZED=true` + +## GitHub Actions Workflow + +A GitHub Actions workflow is available at `.github/workflows/smart-widgets-ilm.yml` that can be triggered manually or automatically on configuration changes. + +To trigger manually: +1. Go to Actions tab in GitHub +2. Select "Smart Widgets Ilm Configuration" +3. Click "Run workflow" +4. Configure options and run + +## Troubleshooting + +### Configuration Not Applied + +If settings aren't being applied: + +1. Verify the configuration file exists: + ```bash + cat .cursor/smart-widgets-config.json + ``` + +2. Validate JSON syntax: + ```bash + python3 -m json.tool .cursor/smart-widgets-config.json + ``` + +3. Ensure environment variables are set: + ```bash + source .cursor/smart-widgets.env + env | grep ILM + ``` + +### Slow Model Timeouts + +If you're experiencing timeouts with slow models: + +1. Increase the timeout value: + ```python + python3 scripts/configure-slow-models.py timeout=60000 + ``` + +2. Increase retry attempts: + ```python + python3 scripts/configure-slow-models.py retryAttempts=5 + ``` + +## Best Practices + +1. **Cost Optimization**: Use slow models for non-time-critical operations +2. **Timeout Settings**: Set appropriate timeouts based on your use case +3. **Retry Logic**: Configure retry attempts for unreliable network conditions +4. **Monitoring**: Monitor model performance and adjust settings as needed + +## Files + +- `.cursor/smart-widgets-config.json` - Main configuration file +- `.cursor/smart-widgets.env` - Environment variables file +- `scripts/enable-smart-widgets-ilm.sh` - Shell script for enabling +- `scripts/configure-slow-models.py` - Python script for configuration +- `.github/workflows/smart-widgets-ilm.yml` - GitHub Actions workflow + +## Support + +For issues or questions, please refer to the project's issue tracker or documentation. diff --git a/scripts/configure-slow-models.py b/scripts/configure-slow-models.py new file mode 100755 index 000000000..d5debd41a --- /dev/null +++ b/scripts/configure-slow-models.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python3 +""" +Configure slow models for Smart Widgets with Ilm. +This script manages the configuration for using slow/cost-optimized models. +""" + +import json +import os +import sys +from pathlib import Path + +CONFIG_DIR = Path(".cursor") +CONFIG_FILE = CONFIG_DIR / "smart-widgets-config.json" + +# Default slow model configuration +SLOW_MODEL_CONFIG = { + "smartWidgets": { + "enabled": True, + "native": True, + "ilm": { + "enabled": True, + "available": True, + "modelType": "slow", + "modelConfig": { + "useSlowModels": True, + "modelSpeed": "slow", + "costOptimized": True, + "timeout": 30000, + "retryAttempts": 3, + "modelOptions": { + "preferCheaper": True, + "allowLongerWait": True, + "batchProcessing": True + } + } + }, + "settings": { + "autoEnable": True, + "fallbackToFast": False, + "preferSlowModels": True + } + } +} + + +def load_config(): + """Load existing configuration or return default.""" + if CONFIG_FILE.exists(): + try: + with open(CONFIG_FILE, 'r') as f: + return json.load(f) + except json.JSONDecodeError as e: + print(f"āš ļø Warning: Invalid JSON in config file: {e}") + return SLOW_MODEL_CONFIG.copy() + return SLOW_MODEL_CONFIG.copy() + + +def save_config(config): + """Save configuration to file.""" + CONFIG_DIR.mkdir(exist_ok=True) + with open(CONFIG_FILE, 'w') as f: + json.dump(config, f, indent=2) + print(f"āœ… Configuration saved to: {CONFIG_FILE}") + + +def update_model_config(config, **kwargs): + """Update model configuration with provided parameters.""" + ilm_config = config.setdefault("smartWidgets", {}).setdefault("ilm", {}) + model_config = ilm_config.setdefault("modelConfig", {}) + + for key, value in kwargs.items(): + if key == "timeout": + model_config["timeout"] = int(value) + elif key == "retryAttempts": + model_config["retryAttempts"] = int(value) + elif key == "modelSpeed": + model_config["modelSpeed"] = value + elif key == "costOptimized": + model_config["costOptimized"] = bool(value) + elif key == "useSlowModels": + model_config["useSlowModels"] = bool(value) + + return config + + +def main(): + """Main function to configure slow models.""" + print("šŸ”§ Configuring Smart Widgets with Ilm (Slow Models)") + print("=" * 60) + + # Load existing config + config = load_config() + + # Parse command line arguments + if len(sys.argv) > 1: + # Custom configuration via command line + for arg in sys.argv[1:]: + if "=" in arg: + key, value = arg.split("=", 1) + update_model_config(config, **{key: value}) + else: + # Use default slow model configuration + config = SLOW_MODEL_CONFIG.copy() + + # Ensure Ilm is enabled + config.setdefault("smartWidgets", {}).setdefault("ilm", {})["enabled"] = True + config.setdefault("smartWidgets", {}).setdefault("ilm", {})["available"] = True + config.setdefault("smartWidgets", {}).setdefault("ilm", {})["modelType"] = "slow" + + # Save configuration + save_config(config) + + # Display summary + print("\nšŸ“‹ Configuration Summary:") + print(f" Smart Widgets: {'āœ… Enabled' if config['smartWidgets']['enabled'] else 'āŒ Disabled'}") + print(f" Native Mode: {'āœ… Enabled' if config['smartWidgets']['native'] else 'āŒ Disabled'}") + print(f" Ilm Enabled: {'āœ… Yes' if config['smartWidgets']['ilm']['enabled'] else 'āŒ No'}") + print(f" Ilm Available: {'āœ… Yes' if config['smartWidgets']['ilm']['available'] else 'āŒ No'}") + print(f" Model Type: {config['smartWidgets']['ilm']['modelType']}") + print(f" Use Slow Models: {'āœ… Yes' if config['smartWidgets']['ilm']['modelConfig']['useSlowModels'] else 'āŒ No'}") + print(f" Cost Optimized: {'āœ… Yes' if config['smartWidgets']['ilm']['modelConfig']['costOptimized'] else 'āŒ No'}") + print(f" Timeout: {config['smartWidgets']['ilm']['modelConfig']['timeout']}ms") + print(f" Retry Attempts: {config['smartWidgets']['ilm']['modelConfig']['retryAttempts']}") + + print("\n✨ Configuration complete!") + print("\nTo apply these settings, run:") + print(" source .cursor/smart-widgets.env") + print("\nOr use the enable script:") + print(" bash scripts/enable-smart-widgets-ilm.sh") + + +if __name__ == "__main__": + main() diff --git a/scripts/enable-smart-widgets-ilm.sh b/scripts/enable-smart-widgets-ilm.sh new file mode 100755 index 000000000..502dfcd16 --- /dev/null +++ b/scripts/enable-smart-widgets-ilm.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Process to enable smart widgets native with Ilm using slow models +# This script configures the environment for smart widgets with Ilm support + +set -e + +echo "šŸš€ Enabling Smart Widgets Native with Ilm (Slow Models)" +echo "========================================================" + +# Configuration directory +CONFIG_DIR=".cursor" +CONFIG_FILE="${CONFIG_DIR}/smart-widgets-config.json" + +# Create .cursor directory if it doesn't exist +if [ ! -d "$CONFIG_DIR" ]; then + echo "šŸ“ Creating .cursor directory..." + mkdir -p "$CONFIG_DIR" +fi + +# Check if config file exists +if [ ! -f "$CONFIG_FILE" ]; then + echo "āŒ Configuration file not found: $CONFIG_FILE" + echo "Please ensure the configuration file exists." + exit 1 +fi + +echo "āœ… Configuration file found: $CONFIG_FILE" + +# Validate JSON configuration +if command -v python3 &> /dev/null; then + echo "šŸ” Validating configuration..." + python3 -m json.tool "$CONFIG_FILE" > /dev/null + if [ $? -eq 0 ]; then + echo "āœ… Configuration is valid JSON" + else + echo "āŒ Invalid JSON configuration" + exit 1 + fi +fi + +# Set environment variables for Ilm +export SMART_WIDGETS_ENABLED=true +export SMART_WIDGETS_NATIVE=true +export ILM_ENABLED=true +export ILM_AVAILABLE=true +export ILM_MODEL_TYPE=slow +export ILM_USE_SLOW_MODELS=true +export ILM_COST_OPTIMIZED=true + +echo "" +echo "šŸ“‹ Configuration Summary:" +echo " - Smart Widgets: Enabled (Native)" +echo " - Ilm: Available" +echo " - Model Type: Slow" +echo " - Cost Optimized: Yes" +echo "" + +# Create environment file for persistence +ENV_FILE="${CONFIG_DIR}/smart-widgets.env" +cat > "$ENV_FILE" << EOF +# Smart Widgets Configuration +# Generated by enable-smart-widgets-ilm.sh +SMART_WIDGETS_ENABLED=true +SMART_WIDGETS_NATIVE=true +ILM_ENABLED=true +ILM_AVAILABLE=true +ILM_MODEL_TYPE=slow +ILM_USE_SLOW_MODELS=true +ILM_COST_OPTIMIZED=true +EOF + +echo "šŸ’¾ Environment variables saved to: $ENV_FILE" +echo "" +echo "✨ Smart Widgets Native with Ilm (Slow Models) is now enabled!" +echo "" +echo "To use these settings in your shell, run:" +echo " source $ENV_FILE" +echo ""