Skip to content

Commit 9242a17

Browse files
committed
Add error handling
Signed-off-by: David Weik <[email protected]>
1 parent 9684787 commit 9242a17

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

js/utility/call-SCR-LLM.js

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,10 @@ async function callSCRLLM(
5151
})
5252
}
5353
)
54-
55-
const SCRLLMRESPONSEJSON = await SCRLLMRESPONSE.json();
56-
return SCRLLMRESPONSEJSON?.data;
57-
/*
58-
return {url: `${SCREndpoint}/${model}/${model}`, body:{
59-
inputs: [
60-
{
61-
name: "systemPrompt",
62-
value: systemPrompt
63-
},
64-
{
65-
name: "userPrompt",
66-
value: userPrompt
67-
},
68-
{
69-
name: "options",
70-
value: stringOptionsSCRLLM
71-
}
72-
]
73-
}}
74-
*/
54+
if(SCRLLMRESPONSE.status === 200) {
55+
const SCRLLMRESPONSEJSON = await SCRLLMRESPONSE.json();
56+
return SCRLLMRESPONSEJSON?.data;
57+
} else {
58+
return {error: `Request for ${model} failed with the HTTP code: ${SCRLLMRESPONSE.status}`}
59+
}
7560
}

0 commit comments

Comments
 (0)