Skip to content

Commit

Permalink
feat: fix mcbbs
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangsx committed Jul 5, 2023
1 parent bb4a466 commit 01957d7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions model/mcbbs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export class Mcbbs extends Chat {
support(model: ModelType): number {
switch (model) {
case ModelType.GPT3p5Turbo:
return 2000;
return 4000;
case ModelType.GPT3p5_16k:
return 15000;
default:
return 0;
}
Expand Down Expand Up @@ -83,8 +85,8 @@ export class Mcbbs extends Chat {
} as AxiosRequestConfig);
res.data.pipe(es.split(/\r?\n\r?\n/)).pipe(es.map(async (chunk: any, cb: any) => {
const dataStr = chunk.replace('data: ', '');
if (dataStr === '[Done]') {
stream.write(Event.done, dataStr);
if (dataStr === '[DONE]') {
stream.write(Event.done, {content: ''});
return;
}
const data = parseJSON(dataStr, {} as any);
Expand All @@ -95,6 +97,9 @@ export class Mcbbs extends Chat {
const [{delta: {content = ""}}] = data.choices;
stream.write(Event.message, {content});
}))
res.data.on('close', () => {
stream.end();
})
} catch (e: any) {
console.error(e);
stream.write(Event.error, {error: e.message})
Expand Down

0 comments on commit 01957d7

Please sign in to comment.