@sap-ai-sdk/foundation-models
Version:
SAP Cloud SDK for AI is the official Software Development Kit (SDK) for **SAP AI Core**, **SAP Generative AI Hub**, and **Orchestration Service**.
18 lines • 819 B
JavaScript
/**
* Creates a JSONL Blob for upload via FileApi from typed chat completion requests.
* Each request is assigned a sequential custom_id (request-1, request-2, ...).
* @param requests - Chat completion requests to include in the batch.
* @returns A Blob containing one JSON object per line.
* @experimental This API is experimental and may change at any time without prior notice.
*/
export function createBatchInput(requests) {
const lines = requests.map((body, i) => JSON.stringify({
custom_id: `request-${i + 1}`,
method: 'POST',
url: '/v1/chat/completions',
body
}));
// The AI Core file API requires content-type 'text/csv' for batch input files.
return new Blob([lines.join('\n')], { type: 'text/csv' });
}
//# sourceMappingURL=azure-openai-batch-input.js.map