Chat
Class
Make sure you read through the Authentication page first, if you haven't already.
An easy way to continue a chat with Bard.
Example
import Bard from "bard-ai";
let myBard = new Bard(COOKIE);
let myChat = myBard.createChat({ ...ids });
console.log(await myChat.ask("How are you?"));
console.log(await myChat.ask("What's the last thing I said?"));
Arguments
Parameter | Type | Description |
---|---|---|
ids | object | Used for importing a previous conversation. If left blank, creates a new conversation. |
Usage
Create a new conversation with the following code:
let myBard = new Bard(COOKIE);
let myChat = myBard.createChat();
Chat.ask()
Asks something to the current Chat()
instance.
Example
import Bard from "bard-ai";
let myBard = new Bard(COOKIE);
let myChat = myBard.createChat({ ...ids });
console.log(await myChat.ask("What is 1+1?"));
console.log(await myChat.ask("What is 1 more than that value?"));
Usage
Call the .ask()
method asynchronously (with an await
) on the same instance of Bard.Chat
. That way, it will remember what was previously said. This is similar to continuing a "Chat" in ChatGPT.
The Chat.ask()
method has the exact same API as Bard.ask()
(in fact, they
call the same function under the hood). This means that it also supports the
same config. Check the documentation for Bard.ask()
for more
information.
Chat.export()
Exports the current conversation. Go to Importing/Exporting Chats to learn more.