add try catch for openai responses api
This commit is contained in:
@@ -91,7 +91,10 @@ async function recommendationsLoader(
|
|||||||
title,
|
title,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const response = await openAIClient.responses.create({
|
let response;
|
||||||
|
|
||||||
|
try {
|
||||||
|
response = await openAIClient.responses.create({
|
||||||
store: false,
|
store: false,
|
||||||
prompt: {
|
prompt: {
|
||||||
id: analysesRecommendationsPromptId,
|
id: analysesRecommendationsPromptId,
|
||||||
@@ -104,6 +107,10 @@ async function recommendationsLoader(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error calling OpenAI: ', error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
const json = JSON.parse(response.output_text);
|
const json = JSON.parse(response.output_text);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user