SkywardAI / voyager

The project is OpenAI-like API service of SkywardAI ecosystem
Apache License 2.0
1 stars 6 forks source link

[Issue]: Not able to invoke with OpenAI JS SDK #86

Open cbh778899 opened 1 week ago

cbh778899 commented 1 week ago

Contact Details(optional)

No response

What is the issue you are having?

It seems like when using OpenAI JavaScript SDK, this project won't work as expected.

Code:

import OpenAI from 'openai';
const client = new OpenAI({ apiKey: 'test-api-key', baseURL: 'http://localhost:8000/v1/' });

async function completions() {
    const stream = await client.chat.completions.create({stream: true, messages: [{role:'user', content: 'hello'}]});
    for await (const chunk of stream) {
        console.log(chunk.choices[0].delta.content);
    }
    console.log("Finished Response");
}

completions();
// Console output: Finished Response

And although the engine got response normally, the receiver doesn't received the chunk output.

Relevant log output

No response