Skip to content

Commit

Permalink
Fix Bing outputting extra chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
XInTheDark committed May 4, 2024
1 parent 35195b1 commit 0ed15b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/aiChat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Chat({ launchContext }) {
} else {
let response = "";
let r = await getChatResponse(currentChat, query);
for await (const chunk of processChunks(r, provider)) {
for await (const chunk of await processChunks(r, provider)) {
response += chunk;
response = formatResponse(response, provider);
_setChatData(chatData, setChatData, "", response);
Expand Down
8 changes: 4 additions & 4 deletions src/api/gpt.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import { useEffect, useState } from "react";
import * as G4F from "g4f";
const g4f = new G4F.G4F();

// DeepInfra Llama 3 module
// DeepInfra module
import { DeepInfraProvider, getDeepInfraResponse } from "./Providers/deepinfra";

// Blackbox module
import { BlackboxProvider, getBlackboxResponse } from "./Providers/blackbox";

// Replicate Llama 3 module
// Replicate module
import { ReplicateProvider, getReplicateResponse } from "./Providers/replicate";

// Google Gemini module
Expand Down Expand Up @@ -122,7 +122,7 @@ export default (
setMarkdown(response);
} else {
let r = await chatCompletion(messages, options);
for await (const chunk of processChunks(r, provider)) {
for await (const chunk of await processChunks(r, provider)) {
response += chunk;
response = formatResponse(response, provider);
setMarkdown(response);
Expand Down Expand Up @@ -367,7 +367,7 @@ export const processChunks = async function* (response, provider) {
yield prevChunk;
prevChunk = chunk;
}
} else if (provider in [DeepInfraProvider, BlackboxProvider, ReplicateProvider]) {
} else if ([DeepInfraProvider, BlackboxProvider, ReplicateProvider].includes(provider)) {
// response must be an async generator
yield* response;
} else {
Expand Down

0 comments on commit 0ed15b5

Please sign in to comment.