feat(blacklist): added ability to blacklist models & providers#2709
feat(blacklist): added ability to blacklist models & providers#2709waleedlatif1 merged 2 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR implements a flexible blacklist system for providers and models using environment variables Key changes:
Implementation notes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant UI as UI/Block Config
participant API as API Routes
participant Utils as Provider Utils
participant Env as Environment Config
Note over Env: BLACKLISTED_PROVIDERS=openai<br/>BLACKLISTED_MODELS=gpt-4,claude-*
User->>UI: Select model for workflow
UI->>Utils: getBaseModelProviders()
Utils->>Utils: filterBlacklistedModelsFromProviderMap()
Utils->>Utils: isProviderBlacklisted(providerId)
Utils->>Env: Check BLACKLISTED_PROVIDERS
Env-->>Utils: Provider blacklist status
Utils->>Utils: isModelBlacklisted(model)
Utils->>Env: Check BLACKLISTED_MODELS
Env-->>Utils: Model blacklist status
Utils-->>UI: Filtered model list (blacklisted removed)
UI-->>User: Display available models
User->>UI: Execute workflow with model
UI->>Utils: getProviderFromModel(model)
Utils->>Utils: Lookup provider in getAllModelProviders()
Utils->>Utils: isProviderBlacklisted(providerId)
Utils->>Env: Check BLACKLISTED_PROVIDERS
Env-->>Utils: Provider status
alt Provider is blacklisted
Utils-->>UI: Error: Provider not available
UI-->>User: Execution fails
else Provider allowed
Utils->>Utils: isModelBlacklisted(model)
Utils->>Env: Check BLACKLISTED_MODELS
Env-->>Utils: Model status
alt Model is blacklisted
Utils-->>UI: Error: Model not available
UI-->>User: Execution fails
else Model allowed
Utils-->>UI: Return providerId
UI->>API: Execute with provider
end
end
User->>API: GET /api/providers/ollama/models
API->>Utils: isProviderBlacklisted('ollama')
Utils->>Env: Check BLACKLISTED_PROVIDERS
Env-->>Utils: Provider status
alt Provider is blacklisted
API-->>User: Return empty models []
else Provider allowed
API->>API: Fetch models from provider
API->>Utils: filterBlacklistedModels(allModels)
Utils->>Utils: isModelBlacklisted(each model)
Utils->>Env: Check BLACKLISTED_MODELS
Env-->>Utils: Model status for each
Utils-->>API: Filtered model list
API-->>User: Return filtered models
end
|
There was a problem hiding this comment.
Additional Comments (1)
-
apps/sim/providers/utils.ts, line 144-154 (link)logic:
getAllModelProviders()doesn't filter blacklisted models/providers, but is used bygetProviderFromModel()on line 158. If a blacklisted model is passed directly to execution logic, it could bypass the blacklist. Consider filtering here too, or document why this is intentional (e.g., for backward compatibility with saved workflows). Is this intentional to allow saved workflows with blacklisted models to still execute, or shouldgetAllModelProviders()also filter blacklisted items?
9 files reviewed, 1 comment
|
@greptile |
* feat(blacklist): added ability to blacklist models & providers * ack PR comments
Summary
Type of Change
Testing
Tested manually
Checklist