Skip to content

Commit

Permalink
Update chat.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
goldentroll authored Sep 10, 2023
1 parent 9a20c78 commit c28b328
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pages/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const handler = async (req: Request): Promise<Response> => {
let tokenCount = prompt_tokens.length;
let messagesToSend: Message[] = [];

for (let i = messages.length - 1; i >= 0; i--) {
for (let i = messages.length - 1; i >= 0; --i) {
const message = messages[i];
const tokens = encoding.encode(message.content);

Expand All @@ -54,6 +54,7 @@ const handler = async (req: Request): Promise<Response> => {
const stream = await OpenAIStream(model, promptToSend, temperatureToUse, key, messagesToSend);

return new Response(stream);

} catch (error) {
console.error(error);
if (error instanceof OpenAIError) {
Expand Down

0 comments on commit c28b328

Please sign in to comment.