(modelId, requestInput, params, stream)
| 295 | } |
| 296 | |
| 297 | function formatCurl(modelId, requestInput, params, stream) { |
| 298 | if (requestInput.constructor.name !== 'Object') { |
| 299 | throw new Error(`requestInput is not an object!`); |
| 300 | } |
| 301 | |
| 302 | const body = { |
| 303 | ...requestInput, |
| 304 | params: paramsExist(params) ? params : undefined, |
| 305 | // do not include stream in the json if it's false, as it is redundant |
| 306 | stream: stream || undefined, |
| 307 | }; |
| 308 | |
| 309 | const lines = [ |
| 310 | `curl -X POST 'https://api.bytez.com/models/v2/${modelId}' \\`, |
| 311 | `-H 'Authorization: BYTEZ_KEY' \\`, |
| 312 | `-H 'Content-Type: application/json' \\`, |
| 313 | `--data '${JSON.stringify(body, null, 2)}'`, |
| 314 | ]; |
| 315 | |
| 316 | const finalString = lines.join('\n'); |
| 317 | |
| 318 | return finalString; |
| 319 | } |
| 320 | |
| 321 | function formatIntoCodeSnippet(template, params, stream, onBeforeUpdateTemplateIds, replacements) { |
| 322 | const sectionsAsString = formatIntoSections(template, params, stream); |
no test coverage detected