bard-api-node is a Node.js library for interacting with Bard, an AI Chatbot developed by Google. Bard is based on Google's Large language model (LLM), LaMDA, which is designed to generate human-like text and images in response to prompts.
Bard is basically an AI Chatbot developed by Google. It is based on Google’s Large language model (LLM), LaMDA, similar to how ChatGPT is based on GPT. These are types of neural networks that mimic the underlying architecture of the brain in the form of a computer. Bard is separate from Google Search, which is the default way how billions of people look for information on the web. Unlike how a traditional search works, Bard is conversational and allows users to write a prompt and receive human-like text and images generated by artificial intelligence.
In its own description, Bard is a “large language model, also known as a conversational AI or chatbot trained to be informative and comprehensive”. “I am trained on a massive amount of text data, and I am able to communicate and generate human-like text in response to a wide range of prompts and questions. For example, I can provide summaries of factual topics or create stories.”
To use the Bard-API-Node library in your project, you can install it via npm directly:
npm install bard-api-node
or can install it via npm from Github:
npm install git+https://github.com/codenze/bard-api-node.git
To authenticate with the Bard API, you need to obtain the session value. Here's how you can get it:
- Visit https://bard.google.com/.
- Open the browser console by pressing F12.
- Go to the "Application" tab.
- Under "Cookies", find the cookie named
__Secure-1PSID
or__Secure-3PSID
. - Copy the value of the cookie, which will be your session value.
const { BardAPI } = require('bard-api-node');
async function testAssistant() {
try {
const assistant = new BardAPI();
// Set session information for authentication
await assistant.setSession('__Secure-1PSID', 'YourSecure1PSIDToken'); // or '__Secure-3PSID'
// ...
// Send a query to Bard
const response = await assistant.getBardResponse('Hello, how are you?');
console.log('Bard:', response.content);
} catch (error) {
console.error('Error:', error);
}
}
testAssistant();
Make sure to replace Your_Session_Value
with the actual value of your session obtained from the Bard website.
This Node.js library for interacting with the Bard chat assistant is inspired by the following repositories and contributors:
- Bard-API by Daniel Park
- Bard by Alex Cheong
Their original work on the Bard-API and Bard repositories served as references and inspirations for developing this Node.js implementation.
Please note that these repositories are for Python-based implementations and utilize the __Secure-1PSID
session value to mimic API calls to the Bard interface.
I welcome any feedback, bug reports, or problems you may encounter while using this library. If you have any issues or suggestions, please don't hesitate to reach out. You can send your reports to [email protected].
Thank you for your support and feedback!
This project is licensed under the MIT License. If you find this project helpful in your own work, I would appreciate a star or acknowledgment in your projects.