From 0f06772afb088967eb5b12b3425c114a93fd0610 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 8 Nov 2025 19:38:15 +0000 Subject: [PATCH] Fix critical model name issue and validator warning Critical fix for guarded_ai.py: - Add MODEL_NAME_{n} environment variable support - Fixes hard-coded "model" string that breaks Azure OpenAI and other endpoints - Falls back to "model" if MODEL_NAME_{n} not specified - Some endpoints require actual deployment name in model parameter Validator improvement: - Allow feedback_prompts as alternative to feedback_tokens_for_ai - Prevents false warning when using metadata_feedback_filter with new prompt system Documentation: - Added MODEL_NAME_{n} examples to CLAUDE.md - Documented that Azure and similar endpoints need this variable All 8 activities validated: 0 errors, 0 warnings --- CLAUDE.md | 5 +++++ activity_yaml_validator.py | 6 +++--- research/guarded_ai.py | 5 +++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 0bd165c..5e1bde3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -128,16 +128,21 @@ Models are configured via environment variables in `vars.sh`: # MODEL_1 - Hermes (always available, default) export MODEL_ENDPOINT_1=http://localhost:8080/v1 export MODEL_API_KEY_1=your-api-key +export MODEL_NAME_1=model # Optional: actual model name for the endpoint # MODEL_2 - Additional model (optional) export MODEL_ENDPOINT_2=http://localhost:8081/v1 export MODEL_API_KEY_2=your-api-key +export MODEL_NAME_2=gpt-4 # Optional: specify deployment/model name # MODEL_3 - Qwen3-Coder (recommended for programming) export MODEL_ENDPOINT_3=http://localhost:8082/v1 export MODEL_API_KEY_3=your-api-key +export MODEL_NAME_3=model # Optional: defaults to "model" if not specified ``` +**Note**: `MODEL_NAME_{n}` is optional and defaults to `"model"`. Some endpoints (like Azure OpenAI) require the actual deployment name - set this variable for those cases. + **Example: Programming Activity** ```yaml diff --git a/activity_yaml_validator.py b/activity_yaml_validator.py index d760143..c7c50e5 100644 --- a/activity_yaml_validator.py +++ b/activity_yaml_validator.py @@ -687,10 +687,10 @@ class ActivityYAMLValidator: for bucket, transition in step["transitions"].items(): if "metadata_feedback_filter" in transition: - # Check if step has feedback_tokens_for_ai - if "feedback_tokens_for_ai" not in step: + # Check if step has feedback_tokens_for_ai or feedback_prompts + if "feedback_tokens_for_ai" not in step and "feedback_prompts" not in step: self.warnings.append( - f"Section {section_id}, step {step_id}: metadata_feedback_filter used but no feedback_tokens_for_ai defined" + f"Section {section_id}, step {step_id}: metadata_feedback_filter used but no feedback_tokens_for_ai or feedback_prompts defined" ) def _validate_pre_scripts(self, data: Dict[str, Any]): diff --git a/research/guarded_ai.py b/research/guarded_ai.py index 228ea1c..1b5bfca 100644 --- a/research/guarded_ai.py +++ b/research/guarded_ai.py @@ -48,14 +48,15 @@ def get_openai_client_and_model(model_name=None): model_num = model_name.split("_")[1] endpoint_key = f"MODEL_ENDPOINT_{model_num}" api_key_key = f"MODEL_API_KEY_{model_num}" + model_name_key = f"MODEL_NAME_{model_num}" endpoint = os.getenv(endpoint_key) api_key = os.getenv(api_key_key) if endpoint and api_key: client = get_client_for_endpoint(endpoint, api_key) - # Use a simple default model name for the endpoint - actual_model = "model" # Most endpoints use "model" or ignore this + # Get the actual model name from environment, or use sensible default + actual_model = os.getenv(model_name_key) or "model" return client, actual_model except Exception as e: print(f"Warning: Failed to load {model_name}: {e}, falling back to default")