diff --git a/apps/web/src/lib/organizations/organization-models.ts b/apps/web/src/lib/organizations/organization-models.ts index fd604b91fd..8f5a31e180 100644 --- a/apps/web/src/lib/organizations/organization-models.ts +++ b/apps/web/src/lib/organizations/organization-models.ts @@ -40,6 +40,10 @@ export async function getAvailableModelsForOrganization( filteredModels = models; } + if (organization.plan === 'teams' && organization.settings.data_collection === 'deny') { + filteredModels = filteredModels.filter(model => model.mayTrainOnYourPrompts !== true); + } + if (organization.plan !== 'enterprise' && organization.settings.data_collection !== 'deny') { filteredModels.push(...(await listAvailableExperimentModels())); } diff --git a/apps/web/src/routers/organizations/organization-settings-router.test.ts b/apps/web/src/routers/organizations/organization-settings-router.test.ts index c14dcfd112..e9fac0f99b 100644 --- a/apps/web/src/routers/organizations/organization-settings-router.test.ts +++ b/apps/web/src/routers/organizations/organization-settings-router.test.ts @@ -386,6 +386,36 @@ describe('organizations settings trpc router', () => { 'anthropic/claude-3-opus', ]); }); + + it('should exclude data-collection-required models for teams orgs that deny collection', async () => { + const openRouterModelsResponse = { + data: [ + makeOpenRouterModel('openai/gpt-4o'), + { + ...makeOpenRouterModel('openai/gpt-4o:free'), + mayTrainOnYourPrompts: true, + }, + ], + } satisfies OpenRouterModelsResponse; + + mockedGetEnhancedOpenRouterModels.mockResolvedValue(openRouterModelsResponse); + + const teamsOrg = await createTestOrganization( + 'Teams Org Denying Data Collection', + owner.id, + 0, + { data_collection: 'deny' }, + true + ); + await addUserToOrganization(teamsOrg.id, member.id, 'member'); + + const caller = await createCallerForUser(member.id); + const result = await caller.organizations.settings.listAvailableModels({ + organizationId: teamsOrg.id, + }); + + expect(result.data.map(model => model.id)).toEqual(['openai/gpt-4o']); + }); }); describe('updateDefaultModel procedure', () => {