#google #cli #bard

app bard-rs

Google Bard CLI

20 stable releases

new 1.1.9 Jun 5, 2023
1.1.8 May 25, 2023
1.0.5 Apr 30, 2023

#40 in Web programming

Download history 149/week @ 2023-04-28 63/week @ 2023-05-05 162/week @ 2023-05-12 223/week @ 2023-05-19 57/week @ 2023-05-26 45/week @ 2023-06-02

491 downloads per month

MIT license

570KB
1K SLoC

Google Bard CLI

A simple command line interface for interacting with Google Bard, written in Rust.

This CLI allows you to save chat history as a Markdown file at a specified absolute or relative path in realtime

and handles graceful exit with Ctrl+C.

image


output

Prerequisites

You need to have Rust and Cargo installed on your system. If you don't have them, you can install them from the official Rust website.

Installation

Install from cargo.

cargo install bard-rs

or

  1. Clone the repository to your local machine:

    git clone https://github.com/Alfex4936/Bard-rs
    
  2. Change the working directory:

    cd Bard-rs
    
  3. Build the project:

    cargo build --release
    

The executable binary file will be located in the target/release folder.

Usage

Before using the Google Bard CLI, you need to obtain your session cookie. To get the session cookie, follow these steps:

  1. Go to Google Bard in Chrome.
  2. Open Chrome Developer Tools (F12 or Ctrl + Shift + I).
  3. Go to the "Application" tab.
  4. Under "Storage" > "Cookies", click on "https://bard.google.com".
  5. Find the cookie with the name __Secure-1PSID, and copy its value. (it includes "." usually)

Now you can use the Google Bard CLI:

Supported options: -s (session cookie), -m (if present, it'll print other Bard's responses for your prompt), -p (if present with path, it'll save your chat history as markdown.), -e (if present with .env file location, it'll use that session cookie)

It'll save as your first prompt message. (eg: "Hey yo" -> bard_hey_yo.md)

bard-rs --session <your_session_cookie> --path ./

Replace <your_session_cookie> with the value you copied from the Developer Tools.

If you don't want to save the chat history as a Markdown file, skip --path:

bard-rs --session <your_session_cookie>

If you don't want to pass that long session in terminal, use .env file

bard-rs -e .env -p ./

If you prefer not to specify a path, bard-rs will automatically search for the .env file in the following locations: the argument-provided path, the current working directory, and the directory of the bard-rs binary.

(-p is still required if you want to save the chat history as markdown file.)

bard-rs

above command is same as bard-rs -e .env

.env file must contain SESSION_ID key. (the keys being used for the -s value and SESSION_ID are identical, they are both derived from __Secure-1PSID)

! using echo SESSION_ID=... > .env might cause encoding problem that dotenv cannot read and end up causing no session key error.

SESSION_ID=~.

Commands

  • Type your message and press Enter to send it to Google Bard.
  • Type !reset to reset the conversation.
  • Type !exit to exit the CLI.
  • Type !show to see other Bard's answers for your last message.

License

This project is licensed under the MIT License.

Credits:

  • acheong08 - Inspired by this Python version.

Dependencies

~13–23MB
~457K SLoC