openai-node
openai-node copied to clipboard
openai.createEmbedding() bug: cannot pass in array for "input" param
Describe the bug
When I pass in an array of strings for the "input" param as specified here, the connection times out and eventually I get an error 500 with the error message: "Error: read ECONNRESET".
Passing in a non-array string for "input" works fine.
I am using Next.js using their serverless endpoints testing on localhost.
To Reproduce
Reproduction info in description
Code snippets
try {
const promptEmbeddingsRes = await openAi.createEmbedding({
model: 'text-embedding-ada-002',
input: ['test', 'test', 'test'],
})
console.log('prompt embeddings', promptEmbeddingRes.data.data)
return res.status(200).json(promptEmbeddingsRes.data.data)
} catch (e) {
console.error('Error creating embedding: ', e)
return res.status(500).send("Error creating embedding: " + e)
}
OS
macOS
Node version
v16
Library version
3.1
Whoops, I stuck promptEmbeddingRes.data.data in the .json(), and that was not allowed. Once i fixed that, the api worked fine.
Nope, the error happened again after that json issue was fixed, so reopening this
Hey! I'm facing this issue in the streaming APIs as well
I believe this is fixed in v4 of this library – please reopen with further details if that's not the case.