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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { createAction, Property } from '@activepieces/pieces-framework';
import OpenAI from 'openai';
import { openaiAuth } from '../auth';
import { listFilesActionOutputSchema } from '../output-schemas';
export const listFiles = createAction({
audience: 'both',
auth: openaiAuth,
name: 'list_files',
classification: 'SEARCH',
displayName: 'List Files',
description: 'List the files in your OpenAI account.',
aiMetadata: { description: 'Returns the files stored in the connected OpenAI account together with their ids, names, sizes, and purposes, either the whole account or, when a purpose filter is supplied, only assistants, vision, batch, or fine-tune files, capped by an optional limit. Use it to browse or audit what has been uploaded and to collect file ids; find_file is the better choice when checking for one exact filename. Read-only and idempotent.', idempotent: true },
props: {
purpose: Property.StaticDropdown({
displayName: 'Purpose',
description: 'Only include files with this purpose.',
required: false,
options: {
options: [
{ label: 'Assistants', value: 'assistants' },
{ label: 'Vision', value: 'vision' },
{ label: 'Batch', value: 'batch' },
{ label: 'Fine-Tuning', value: 'fine-tune' },
],
},
}),
limit: Property.Number({
displayName: 'Max Results',
description: 'Up to this many files, from 1 to 10,000.',
required: false,
defaultValue: 100,
display: 'stepper',
min: 1,
max: 10000,
step: 10,
}),
},
outputSchema: listFilesActionOutputSchema,
async run(context) {
const openai = new OpenAI({ apiKey: context.auth.secret_text });
const { purpose, limit } = context.propsValue;
const params: { purpose?: string; limit?: number } = {};
if (purpose) params.purpose = purpose;
if (typeof limit === 'number') params.limit = limit;
const response = await openai.files.list(params);
return {
files: response.data,
count: response.data.length,
};
},
});