Skip to content

Commit

Permalink
check length message empty
Browse files Browse the repository at this point in the history
  • Loading branch information
vunb committed Dec 21, 2023
1 parent 1a40cc2 commit e143185
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
export { Request } from './engine/request';
export { Context } from './engine/context';
export { Struct } from './engine/struct';
export { Logger } from './lib/logger';
14 changes: 9 additions & 5 deletions src/plugins/chatgpt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import OpenAI from 'openai';
import { Request, Context } from '../common';
import { Request, Context, Logger } from '../common';

const logger = new Logger('ChatGPT');
/**
> chatgpt
Expand All @@ -21,10 +22,13 @@ export async function chatgpt(req: Request, ctx: Context) {
});

let result = '';
messages.push({
role: 'user',
content: req.message,
});
if (messages.length === 0) {
messages.push({
role: 'user',
content: req.message,
});
}
logger.info('Feed the message: ', messages);
if (apiStream) {
const stream = await openai.chat.completions.create({
messages,
Expand Down

0 comments on commit e143185

Please sign in to comment.