Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

793 B
Raw Blame
import { ModelOptionsSurface } from '@activepieces/shared';
import { keepPreviousData, useQuery } from '@tanstack/react-query';

import { aiProviderApi } from '@/features/platform-admin/api/ai-provider-api';

export const aiModelHooks = {
  useModelOptions: ({
    projectId,
    surface,
    tierId,
    enabled = true,
  }: {
    projectId?: string;
    surface: ModelOptionsSurface;
    tierId?: string;
    enabled?: boolean;
  }) =>
    useQuery({
      enabled,
      queryKey: ['ai-model-options', projectId ?? 'platform', surface, tierId],
      queryFn: () =>
        projectId === undefined
          ? aiProviderApi.listPlatformModelOptions({ surface })
          : aiProviderApi.listModelOptions({ projectId, surface, tierId }),
      placeholderData: keepPreviousData,
    }),
};