punyaslokdutta / bard-ai

A lightweight library to access Google Bard.

Home Page:https://www.npmjs.com/package/bard-ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EvanZhouDev Banner

A JavaScript API for Google Bard

Ready to start? Read the Docs

Library Overview

Features

Introduction

bard-ai was built to provide free AI to everyone, through Google Bard. It's completely free, and takes minimal setup.

Originally based off of acheong08's Python Bard API Code.

Comparison

Compared to leading JS Bard API googlebard:

bard-ai Compared to GoogleBard
Learn more...

Currently, the most popular JavaScript Bard is GoogleBard by PawanOsman. However, there are 3 main reasons why bard-ai is superior:

Size

After being minified and gzipped, bard-ai is 1.3KB, while google-bard is 112.8KB (checked with Bundlephobia). That makes bard-ai ~99% smaller!

Speed

This library is up to 150% faster, as tested with hyperfine --warmup 1 --runs 3 between bard-ai and googlebard1.

API

googlebard overcomplicates many things, including importing the cookies to importing and exporting conversations. bard-ai has been built to make it simple and easy to use.

Let's Get Started!

Read the documentation, available at bard-ai-docs.vercel.app.

Table of Contents

Go ahead! It's easy to learn... Trust me!




Footnotes

  1. Run hyperfine --warmup 1 --runs 3 between bard-ai v1.2.2 and googlebard with following code for googlebard (in "googlebard.js"):

    import { Bard } from "googlebard";
    
    let cookies = `__Secure-1PSID=MY_KEY`;
    let bot = new Bard(cookies);
    
    let response = await bot.ask("Hello world!");
    console.log(response);
    

    And following code for bard-ai (in "bard-ai.js"):

    import Bard, { askAI } from "bard-ai";
    
    await Bard.init("MY_KEY");
    
    console.log(await askAI("Hello world!"));
    

    With this benchmark output:

    Benchmark 1: node bard-ai.js
    Time (mean Β± Οƒ):      6.951 s Β±  2.272 s    [User: 0.181 s, System: 0.044 s]
    Range (min … max):    5.333 s …  9.549 s    3 runs
    
    Benchmark 2: node googlebard.js
    Time (mean Β± Οƒ):      7.691 s Β±  1.029 s    [User: 0.389 s, System: 0.073 s]
    Range (min … max):    6.510 s …  8.394 s    3 runs
    
    Summary
    'node bard-ai.js' ran
    1.11 Β± 0.39 times faster than 'node googlebard.js'
    
    ↩

About

A lightweight library to access Google Bard.

https://www.npmjs.com/package/bard-ai

License:GNU General Public License v3.0


Languages

Language:JavaScript 100.0%