MCPcopy Create free account
hub / github.com/Bytez-com/docs / formatCurl

Function formatCurl

docs/scripts/generatePages/index.js:297–319  ·  view source on GitHub ↗
(modelId, requestInput, params, stream)

Source from the content-addressed store, hash-verified

295}
296
297function 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
321function formatIntoCodeSnippet(template, params, stream, onBeforeUpdateTemplateIds, replacements) {
322 const sectionsAsString = formatIntoSections(template, params, stream);

Callers 1

generateCodeSnippetsFunction · 0.85

Calls 1

paramsExistFunction · 0.85

Tested by

no test coverage detected