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 | import type { BedrockFinetuneRecord } from '@api/ai-providers/bedrock/types';
import type { ResponseTransformFunction } from '@shared/types/ai-providers/config';
import type {
FineTuningJob,
ListFineTuningJobsResponseBody,
} from '@shared/types/api/routes/fine-tuning-api';
import { bedrockErrorResponseTransform } from './chat-complete';
import { bedrockFinetuneToOpenAI } from './utils';
export const bedrockListFinetuneResponseTransform: ResponseTransformFunction = (
response,
responseStatus,
) => {
if (responseStatus !== 200) {
const error = bedrockErrorResponseTransform(response);
if (error) {
return error;
}
}
const records =
((response as { modelCustomizationJobSummaries?: unknown })
.modelCustomizationJobSummaries as BedrockFinetuneRecord[]) || [];
const openaiRecords = records.map(bedrockFinetuneToOpenAI);
const listResponseBody: ListFineTuningJobsResponseBody = {
data: openaiRecords as unknown as FineTuningJob[],
object: 'list',
last_id: (response as { nextToken?: string })?.nextToken,
has_more: (response as { nextToken?: string })?.nextToken !== undefined,
};
return listResponseBody;
};
|