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
This commit is contained in:
parent
82aeeab094
commit
0f06772afb
3 changed files with 11 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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]):
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue