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

Function toAccordion

docs/scripts/generatePages/index.js:175–225  ·  view source on GitHub ↗
({
  exampleTitle,
  exampleDescription,
  supportsUrlInput,
  supportsBase64Input,
  mediaInputType,
  defaultOpen,
  js,
  py,
  curl,
})

Source from the content-addressed store, hash-verified

173}
174
175function toAccordion({
176 exampleTitle,
177 exampleDescription,
178 supportsUrlInput,
179 supportsBase64Input,
180 mediaInputType,
181 defaultOpen,
182 js,
183 py,
184 curl,
185}) {
186 const codeGroupItems = [];
187
188 for (const { snippet, renderAs, label } of [
189 { snippet: js, renderAs: 'javascript', label: 'javascript' },
190 { snippet: py, renderAs: 'python', label: 'python' },
191 { snippet: curl, renderAs: 'bash', label: 'http' },
192 ]) {
193 const codeGroupItem = `
194\`\`\`${renderAs} ${label}
195${snippet}
196\`\`\`
197`.trim();
198
199 codeGroupItems.push(codeGroupItem);
200 }
201
202 const codeGroupsString = codeGroupItems.join('\n');
203
204 const shouldHaveBase64Details = supportsUrlInput && supportsBase64Input;
205
206 const base64Details = `
207You can send the **${mediaInputType}** via \`url\` or \`base64\` data URL.
208
209We recommend \`url\` for better performance, as \`base64\` increases payload size.
210`.trim();
211
212 const Accordion = new Component({
213 name: 'Accordion',
214 props: { defaultOpen, title: exampleTitle },
215 children: [
216 exampleDescription,
217 new Component({
218 name: 'CodeGroup',
219 children: [codeGroupsString, ...(shouldHaveBase64Details ? [base64Details] : [])],
220 }),
221 ],
222 });
223
224 return Accordion;
225}
226
227async function generateCodeSnippets(modelId, requestInput, requestInputHttp, params, stream) {
228 const js = formatIntoCodeSnippet(

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected