Skip to content

Commit

Permalink
Merge pull request #18 from goldentroll/feature1
Browse files Browse the repository at this point in the history
Update chat.ts
  • Loading branch information
goldentroll authored Sep 10, 2023
2 parents 207c56b + c28b328 commit ae1b873
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 ae1b873

Please sign in to comment.