Skip to content

Commit

Permalink
fix a small issue
Browse files Browse the repository at this point in the history
  • Loading branch information
PawanOsman committed Jul 13, 2023
1 parent 5e9aeb2 commit 3991439
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "googlebard",
"version": "1.0.6",
"version": "1.0.7",
"description": "A reverse engineered API for Google Bard chatbot",
"main": "dist/index.js",
"type": "module",
Expand Down
8 changes: 4 additions & 4 deletions src/classes/bard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,20 @@ class Bard {
public async ask(prompt: string, conversationId?: string) {
// return await this.askStream((data) => {}, prompt, conversationId);
let resData = await this.send(prompt, conversationId);
return resData[0];
return resData[3];
}

public async askStream(data: (arg0: string) => void, prompt: string, conversationId?: string) {
let resData = await this.send(prompt, conversationId);
if (!resData) return "";
if (!resData[0]) return "";
let responseChunks = resData[0].split(" ");
if (!resData[3]) return "";
let responseChunks = resData[3].split(" ");
for await (let chunk of responseChunks) {
if (chunk === "") continue;
data(`${chunk} `);
await Wait(Random(25, 250)); // simulate typing
}
return resData[0];
return resData[3];
}

private async send(prompt: string, conversationId?: string) {
Expand Down

0 comments on commit 3991439

Please sign in to comment.