Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix various issues related to OpenAI API spec #39

Merged
merged 6 commits into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions routes/chatRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ assistant:`;
);
res.write('event: data\n');
res.write('data: [DONE]\n\n');
res.end();
global.lastRequest = {
type: 'chat',
messages: [
Expand Down
11 changes: 6 additions & 5 deletions routes/completionsRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ router.post('/', async (req, res) => {
if (responseStart) {
process.stdout.write(data);
controller.enqueue(
dataToResponse(data, promptTokens, completionTokens, stream)
dataToCompletionResponse(data, promptTokens, completionTokens, stream)
);
} else {
console.log('===== PROCESSING PROMPT... =====');
Expand Down Expand Up @@ -168,9 +168,9 @@ router.post('/', async (req, res) => {
let lastChunk; // in case stop prompts are longer, lets combine the last 2 chunks to check
const writable = new WritableStream({
write(chunk) {
const currContent = chunk.choices[0].delta.content;
const currContent = chunk.choices[0].text;
const lastContent = !!lastChunk
? lastChunk.choices[0].delta.content
? lastChunk.choices[0].text
: undefined;
const last2Content = !!lastContent
? lastContent + currContent
Expand Down Expand Up @@ -199,6 +199,7 @@ router.post('/', async (req, res) => {
);
res.write('event: data\n');
res.write('data: [DONE]\n\n');
res.end();
global.lastRequest = {
type: 'completion',
prompt: prompt,
Expand Down Expand Up @@ -230,9 +231,9 @@ router.post('/', async (req, res) => {
let lastChunk; // in case stop prompts are longer, lets combine the last 2 chunks to check
const writable = new WritableStream({
write(chunk) {
const currContent = chunk.choices[0].message.content;
const currContent = chunk.choices[0].text;
const lastContent = !!lastChunk
? lastChunk.choices[0].message.content
? lastChunk.choices[0].text
: undefined;
const last2Content = !!lastContent
? lastContent + currContent
Expand Down