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

1.0 KB
Raw Blame
import {
  AuthenticationType,
  httpClient,
  HttpMethod,
} from '@activepieces/pieces-common';
import { Property } from '@activepieces/pieces-framework';
import { BASE_URL } from './auth';
import { cometApiAuth } from './auth';

export const modelIdDropdown = Property.Dropdown({
  displayName: 'Model',
  auth: cometApiAuth,
  refreshers: [],
  required: true,
  options: async ({ auth }) => {
    if (!auth) {
      return {
        placeholder: 'Please connect your account first.',
        disabled: true,
        options: [],
      };
    }

    const response = await httpClient.sendRequest<{
      data: Array<{ id: string; owned_by: string }>;
    }>({
      url: BASE_URL + '/models',
      authentication: {
        type: AuthenticationType.BEARER_TOKEN,
        token: auth.secret_text,
      },
      method: HttpMethod.GET,
    });

    return {
      disabled: false,
      options: response.body.data.map((model) => ({
        label: `${model.id} (${model.owned_by})`,
        value: model.id,
      })),
    };
  },
});