I have a Firebase function which is timing out consistently with the same test query that I am using “How should I clean my yorkie’s teeth at home?”
It seems like ChatGPT really wants to get thorough instructions. Anyway, Firebase functions have a 60s timeout so whatever happens I need something back sooner. I haven’t adjusted max_tokens
or anything like that yet. Here is my code:
async function openAi(messages) {
const { Configuration, OpenAIApi } = require('openai');
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const completion = await openai.createChatCompletion({
model: 'gpt-4',
messages: messages,
});
// console.log(completion.data.choices[0].message);
return {
message: completion.data.choices[0].message,
raw: completion.data,
};
}
I am using gpt-4
which I know slows things down. Anything else I can do in my code to speed things up?