From 99724cf99ccdcb4ee39c7b531345a234b370a25c Mon Sep 17 00:00:00 2001 From: robin* Date: Fri, 18 Oct 2024 16:52:46 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EC=B5=9C?= =?UTF-8?q?=EC=8B=A0=ED=99=94=20=ED=94=8C=EB=9E=9C=20=EC=A0=9C=ED=95=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/graphql/uptodate.ts | 16 +++++++++++++++- apps/api/src/utils/plan.ts | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/api/src/graphql/uptodate.ts b/apps/api/src/graphql/uptodate.ts index 731c854fd..21d2ec6ed 100644 --- a/apps/api/src/graphql/uptodate.ts +++ b/apps/api/src/graphql/uptodate.ts @@ -4,11 +4,12 @@ import { and, asc, cosineDistance, eq } from 'drizzle-orm'; import { uniqueBy } from 'remeda'; import { z } from 'zod'; import { builder } from '@/builder'; -import { db, PageContentChunks, PageContents, Pages } from '@/db'; +import { db, firstOrThrow, PageContentChunks, PageContents, Pages, Sites } from '@/db'; import { PageState } from '@/enums'; import * as langchain from '@/external/langchain'; import { fixByChangePrompt, keywordExtractionPrompt } from '@/prompt/fix-by-change'; import { assertSitePermission } from '@/utils/permissions'; +import { assertTeamPlanRule } from '@/utils/plan'; import { Page } from './objects'; type FindOutdatedContent = { @@ -56,6 +57,19 @@ builder.queryFields((t) => ({ userId: ctx.session.userId, }); + const site = await db + .select({ + teamId: Sites.teamId, + }) + .from(Sites) + .where(eq(Sites.id, args.siteId)) + .then(firstOrThrow); + + await assertTeamPlanRule({ + teamId: site.teamId, + rule: 'aiSearch', + }); + const chain1 = RunnableSequence.from([ ChatPromptTemplate.fromMessages([ ['system', keywordExtractionPrompt], diff --git a/apps/api/src/utils/plan.ts b/apps/api/src/utils/plan.ts index 93da11cdd..44278424a 100644 --- a/apps/api/src/utils/plan.ts +++ b/apps/api/src/utils/plan.ts @@ -84,5 +84,12 @@ export const assertTeamPlanRule = async (params: GetP } break; } + + default: { + if (!value) { + throw new ReadableError({ code: 'feature_not_available' }); + } + break; + } } };