Bard
2.1.0
วิศวกรรมย้อนกลับของ Bard chatbot API ของ Google
$ pip3 install --upgrade GoogleBard
ไปที่ https://bard.google.com/
__Secure-1PSID
และ __Secure-1PSIDTS
คัดลอกค่าของคุกกี้เหล่านั้น $ 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
$ export BARD_QUICK="true"
$ export BARD__Secure_1PSID="<__Secure-1PSID>"
$ export BARD__Secure_1PSIDTS="<__Secure-1PSIDTS>"
$ python3 -m Bard
ตัวแปรสภาพแวดล้อมสามารถวางใน .zshrc
ตัวอย่างทางลัดทุบตี:
# 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
}
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' ]
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 ())
เครดิต: