export const gptGetEmoji = async (textToAnalyze, openAiClient, temperature = 0.3) => { let emojiJson = [ { emoji: '😞', short_code: ':disappointed_face:', reasoning: 'There was an error with the request.', }, ]; try { const emojiPrompt = ` Analyze the following text and provide at least 1 emojis from unicode v15 in order of relevance, and their markdown short codes, that best represent it as JSON with keys for emoji, short code, and reasoning. Only return the resulting JSON array of objects: ${textToAnalyze.trim()} `; const emojiResponse = await openAiClient.createChatCompletion({ model: 'gpt-3.5-turbo', messages: [ { role: 'assistant', content: emojiPrompt.trim(), }, ], temperature, }); emojiJson = emojiResponse.data.choices[0].message.content .replace('```json', '') .replace('```', '') .trim(); } catch (error) { console.log(error); } return JSON.parse(emojiJson); };