Reverse engineering of Google's Bard chatbot
Project description
Bard
Reverse engineering of Google's Gemini chatbot API, formerly BARD.
Installation
$ pip3 install --upgrade GoogleBard1
Authentication
Go to https://bard.google.com/
- F12 for console
- Copy the values
- Session: Go to Application → Cookies →
__Secure-1PSID
and__Secure-1PSIDTS
. Copy the value of those cookie.
- Session: Go to Application → Cookies →
Usage
$ python3 -m Bard -h
usage: Bard.py [-h] --session <__Secure-1PSID> --session_ts <__Secure-1PSIDTS>
options:
-h, --help show this help message and exit
--session --session_ts pass two cookies
Quick mode
$ export BARD_QUICK="true"
$ export BARD__Secure_1PSID="<__Secure-1PSID>"
$ export BARD__Secure_1PSIDTS="<__Secure-1PSIDTS>"
$ python3 -m Bard
Environment variables can be placed in .zshrc.
Example bash shortcut:
# USAGE1: bard QUESTION
# USAGE2: echo "QUESTION" | bard
bard () {
export BARD_QUICK=true
export BARD__Secure_1PSID=<__Secure-1PSID>
export BARD__Secure_1PSIDTS=<__Secure-1PSIDTS>
python3 -m Bard "${@:-$(</dev/stdin)}" | tail -n+7
}
Implementation:
from os import environ
from Bard import Chatbot
Secure_1PSID = environ.get("BARD__Secure_1PSID")
Secure_1PSIDTS = environ.get("BARD__Secure_1PSIDTS")
chatbot = Chatbot(Secure_1PSID, Secure_1PSIDTS)
answer = chatbot.ask("Hello, how are you?")
print(answer['content']
Async Implementation:
import asyncio
from os import environ
from Bard import AsyncChatbot
Secure_1PSID = environ.get("BARD__Secure_1PSID")
Secure_1PSIDTS = environ.get("BARD__Secure_1PSIDTS")
async def main():
chatbot = await AsyncChatbot.create(Secure_1PSID, Secure_1PSIDTS)
response = await chatbot.ask("Hello, how are you?")
print(response['content'])
asyncio.run(main())
Developer Documentation
Credits:
- discordtehe - Derivative of his original reverse engineering
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
GoogleBard1-2.1.2.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for GoogleBard1-2.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d574d44da96687c02e6d3129281e748e1adc3170f0c44e06e3d05eec4b055b0 |
|
MD5 | cbf8482bb2b4174ad047d93ee0c1a4e6 |
|
BLAKE2b-256 | 2a66dc40f6b7eb94b053d217ace0699e23cc72cbb9fe80fac2ce44338f8617cd |