Reverse engineered Google bard cli implemented in golang
With Go module support, simply add the following import
import "github.com/ganeshk312/bard-go/bard"
to your code, and then go [build|run|test]
will automatically fetch the necessary dependencies.
Otherwise, run the following Go command to install the bard-go
package:
$ go get -u github.com/ganeshk312/bard-go/bard
Go to https://bard.google.com/
- F12 for console
- Copy the values
- Session: Go to Application → Cookies →
__Secure-1PSID
. Copy the value of that cookie.
- Session: Go to Application → Cookies →
- Provide this token to the NewChatbot api
The NewChatbot api returns a bard client of type Chatbot. Ask function takes message as a string and provides the bard Response object. Bard session retained for the Chatbot client as the functionalities supported by Google bard. Currently, Bard returns three drafts for each prompt, of type Choice in the Response object
chatbot, _ = bard.NewChatbot(sessionID)
response, err := chatbot.Ask(message)