Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | import type { ResponseTransformFunction } from '@shared/types/ai-providers/config';
import type { CancelBatchResponseBody } from '@shared/types/api/routes/batch-api';
import { BatchStatus } from '@shared/types/api/routes/batch-api';
import { bedrockErrorResponseTransform } from './chat-complete';
export const bedrockCancelBatchResponseTransform: ResponseTransformFunction = (
aiProviderResponseBody,
aiProviderResponseStatus,
_aiProviderResponseHeaders,
_strictOpenAiCompliance,
saRequestData,
) => {
if (aiProviderResponseStatus !== 200) {
const errorResponse = bedrockErrorResponseTransform(aiProviderResponseBody);
if (errorResponse) return errorResponse;
}
const batchId = decodeURIComponent(
saRequestData.url.split('/v1/batches/')[1].split('/')[0],
);
const batchResponseBody: CancelBatchResponseBody = {
id: batchId,
status: BatchStatus.CANCELLED,
object: 'batch',
input_file_id: '',
endpoint: '',
created_at: 0,
request_counts: {
total: 0,
completed: 0,
failed: 0,
},
expires_at: 0,
in_progress_at: 0,
finalizing_at: 0,
completed_at: 0,
failed_at: 0,
expired_at: 0,
cancelling_at: 0,
cancelled_at: 0,
};
return batchResponseBody;
};
|