google-bard-api
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Simple Google Bard Wrapper

This is a simple wrapper for Google Bard, written in TypeScript. It allows you to easily send messages to Google Bard and receive responses in a structured format.

Installation

To install this package, simply run:

npm install google-bard-api

Usage

To use this package, you will need to provide a valid __Secure-1PSID cookie for Google Bard. Once you have this, you can create a new instance of the Bard class and use the query method to send messages to Google Bard and receive responses.

Here's an example of how to use this package:

import Bard from "google-bard-api";

// Replace this with a valid __Secure-1PSID cookie for Google Bard
const sessionId = "your-session-id-here";

const bard = new Bard(sessionId);

bard.query("What is the meaning of life?")
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });

// Using async-await
async function getResponse() {
  try {
    const response = await bard.query("Who is the current CEO of Twitter?");
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

getResponse();

The query method returns a ChatData object, which contains the following properties:

  • content: The response text from Google Bard.
  • conversationId: The conversation ID for this message.
  • responseId: The response ID for this message.
  • factualityQueries: An array of factuality queries for this message.
  • textQuery: The text query for this message.
  • choices: An array of choices for this message, if any.

Credits

https://github.com/acheong08/Bard

Readme

Keywords

Package Sidebar

Install

npm i google-bard-api

Weekly Downloads

2

Version

1.1.1

License

MIT

Unpacked Size

11.5 kB

Total Files

4

Last publish

Collaborators

  • jaiwanth