import { createAction } from '@activepieces/pieces-framework';
import { assemblyaiAuth } from '../../auth';
import { getAssemblyAIClient } from '../../client';
import { lemurRequestIdProp } from './shared-props';

export const purgeLemurRequestData = createAction({
  name: 'purgeLemurRequestData',
  auth: assemblyaiAuth,
  requireAuth: true,
  displayName: 'Purge LeMUR request data',
  description: `Delete the data for a previously submitted LeMUR request.
The LLM response data, as well as any context provided in the original request will be removed.`,
  audience: 'both',
  aiMetadata: {
    description:
      'Permanently deletes the data of a previously submitted LeMUR request, identified by its request ID, including the LLM response and any context from the original request. Use this to purge LeMUR data for privacy or compliance; this is a destructive mutation. Requires a valid LeMUR request ID and is not idempotent.',
    idempotent: false,
  },
  props: {
    request_id: lemurRequestIdProp,
  },
  async run(context) {
    const client = getAssemblyAIClient(context);
    const purgeRequestDataResponse = await client.lemur.purgeRequestData(
      context.propsValue.request_id
    );
    return purgeRequestDataResponse;
  },
});
