Skip to content

Commit 4c23343

Browse files
committed
feat: Make CDP token optional for CAII endpoints
- Changed cdp_token from required to optional in CustomCAIIEndpoint model - Added fallback logic in CAII handler to use CDP_TOKEN env var or /tmp/jwt if not provided - UI can now add CAII endpoints without explicitly providing cdp_token - Fixes validation error when adding CAII endpoints
1 parent 6c139ae commit 4c23343

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/core/model_handlers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ def _handle_caii_request(self, prompt: str):
541541

542542
if custom_config:
543543
# Use custom endpoint configuration
544-
API_KEY = custom_config.cdp_token
544+
# If cdp_token is provided in custom config, use it; otherwise fall back to environment/JWT
545+
API_KEY = custom_config.cdp_token if custom_config.cdp_token else _get_caii_token()
545546
MODEL_ID = self.model_id
546547
caii_endpoint = custom_config.endpoint_url
547548
print(f"Using custom CAII endpoint for model: {self.model_id}")

app/models/request_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,13 @@ class CustomPromptRequest(BaseModel):
283283
)
284284

285285

286-
# Custom Endpoint Models - Ultra Simplified
286+
# Custom Endpoint Models
287287
class CustomCAIIEndpoint(BaseModel):
288288
"""Custom CAII endpoint - needs custom URL"""
289289
model_id: str = Field(..., description="Model identifier")
290290
provider_type: str = Field(default="caii", description="Provider type")
291291
endpoint_url: str = Field(..., description="CAII endpoint URL")
292-
cdp_token: str = Field(..., description="CDP token for authentication")
292+
cdp_token: Optional[str] = Field(default=None, description="CDP token for authentication (optional, falls back to CDP_TOKEN env var or /tmp/jwt)")
293293

294294

295295
class CustomBedrockEndpoint(BaseModel):

0 commit comments

Comments
 (0)