PranavPurwar / Google-Bard

A Java Lib for Google-Bard API (Reverse engineering of Google's Bard API)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Java Library for Google Bard to Ask Questions and Receive Answers

Google Bard is Google's experimental, conversational, AI chat service. It is meant to function similarly to ChatGPT, with the biggest difference being that Google's service will pull its information from the web.

I want to use Google Bard automatically in an easier way, so I built a Java library for it. Tthe library supports continuous conversation with the same client.

How to use the library

Import the library into your project

For maven project:

<dependencies>
    <dependency>
        <groupId>com.pkslow</groupId>
        <artifactId>google-bard</artifactId>
        <version>0.2.0</version>
    </dependency>
</dependencies>
  • 0.2.0: Support images and it's not compatible with previous versions;

Java Code

It's easy to make the call:

AIClient client = new GoogleBardClient(token);
Answer answer = client.ask("can you show me a picture of clock?");

Get the token from browser

We need to get the token from browser for authentication. It a cookie named __Secure-1PSID, and we need to copy the value.

The Example

example code to use

Google Bard is now under development so it may not be available for your country, so you may set the proxy before you run the application:

NetworkUtils.setUpProxy("localhost", "7890");

It's Markdown format for the answer.

Sure, here is a picture of a clock. [Image of Clock]

Do you want to see a picture of a specific type of clock? For example, a digital clock, an analog clock, or a grandfather clock?

Resources

About

A Java Lib for Google-Bard API (Reverse engineering of Google's Bard API)

License:MIT License


Languages

Language:Java 100.0%