MyGit

acheong08/Bard

Fork: 177 Star: 1421 (更新于 2024-12-19 20:34:11)

license: MIT

Language: Python .

Python SDK/API for reverse engineered Google Bard

最后发布版本: 2.1.0 ( 2023-07-20 18:41:05)

GitHub网址

Bard

Reverse engineering of Google's Bard chatbot API

Installation

 $ pip3 install --upgrade GoogleBard

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.

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

最近版本更新:(数据更新于 2024-10-10 21:11:48)

2023-07-20 18:41:05 2.1.0

2023-07-20 15:02:19 2.0.0

2023-06-27 01:24:39 1.4.0

2023-06-26 03:46:13 1.3.3

2023-06-10 09:53:28 1.3.2

2023-06-09 18:18:42 1.3.1

2023-06-02 01:38:11 1.3.0

2023-06-02 01:05:03 1.2.2

2023-06-01 12:33:58 1.2.1

2023-05-28 20:52:00 1.2.0

主题(topics):

chatbot, google, google-bard, gpt, reverse-engineering

acheong08/Bard同语言 Python最近更新仓库

2024-12-22 09:03:32 ultralytics/ultralytics

2024-12-21 13:26:40 notepad-plus-plus/nppPluginList

2024-12-21 11:42:53 XiaoMi/ha_xiaomi_home

2024-12-21 04:33:22 comfyanonymous/ComfyUI

2024-12-20 18:47:56 home-assistant/core

2024-12-20 15:41:40 jxxghp/MoviePilot