MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / parseSiliconFlowError

Function parseSiliconFlowError

web/src/llm-api/siliconflow.ts:601–631  ·  view source on GitHub ↗
(response: Response)

Source from the content-addressed store, hash-verified

599}
600
601async function parseSiliconFlowError(response: Response): Promise<SiliconFlowError> {
602 const errorText = await response.text()
603 let errorBody: SiliconFlowError['errorBody']
604 try {
605 const parsed = JSON.parse(errorText)
606 if (parsed?.error?.message) {
607 errorBody = {
608 error: {
609 message: parsed.error.message,
610 code: parsed.error.code ?? null,
611 type: parsed.error.type ?? null,
612 },
613 }
614 } else {
615 errorBody = {
616 error: {
617 message: errorText || response.statusText,
618 code: response.status,
619 },
620 }
621 }
622 } catch {
623 errorBody = {
624 error: {
625 message: errorText || response.statusText,
626 code: response.status,
627 },
628 }
629 }
630 return new SiliconFlowError(response.status, response.statusText, errorBody)
631}
632
633function creditsToFakeCost(credits: number): number {
634 return credits / ((1 + PROFIT_MARGIN) * 100)

Callers 2

handleSiliconFlowStreamFunction · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected