diff --git a/apps/nextjs-app/src/features/app/hooks/useAI.ts b/apps/nextjs-app/src/features/app/hooks/useAI.ts index 3ff591ade..2a91511cb 100644 --- a/apps/nextjs-app/src/features/app/hooks/useAI.ts +++ b/apps/nextjs-app/src/features/app/hooks/useAI.ts @@ -1,13 +1,14 @@ import { useQuery } from '@tanstack/react-query'; import { getAIConfig } from '@teable/openapi'; -import { useBaseId } from '@teable/sdk/hooks'; +import { useBaseId, useIsReadOnlyPreview } from '@teable/sdk/hooks'; export function useAI() { const baseId = useBaseId() as string; + const isReadOnlyPreview = useIsReadOnlyPreview(); const { data } = useQuery({ queryKey: ['ai-config', baseId], queryFn: () => getAIConfig(baseId).then(({ data }) => data), - enabled: Boolean(baseId), + enabled: Boolean(baseId) && !isReadOnlyPreview, }); return {