added the try/catch block back

pull/77/head
Maria-Aidarus 2023-11-28 20:34:21 +03:00
rodzic d83b03cc09
commit c00c8f0277
1 zmienionych plików z 17 dodań i 1 usunięć

Wyświetl plik

@ -56,7 +56,23 @@ async function performGPTAnalysis(simplifiedContent, apiKey) {
});
const openai = new OpenAIApi(configuration);
return inferredMediaType;
try {
// Using the specified prompt
const prompt = `Analyze the following text and provide the media type and key topics: ${simplifiedContent}`;
const completion = await openai.createCompletion({
model: "mistralai/mistral-7b-instruct",
prompt: prompt,
max_tokens: 150 // Adjust as needed
});
//return completion.data.choices[0].text.trim();
return inferredMediaType;
} catch (error) {
console.error('Error with OpenAI completion:', error);
throw error;
}
// return inferredMediaType;
}
// Placeholder function to map inferred values to predefined formats and topics