Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Error testing the example provided in the documentation #14

Open
jabrena opened this issue Jul 15, 2023 · 11 comments
Open

Error testing the example provided in the documentation #14

jabrena opened this issue Jul 15, 2023 · 11 comments

Comments

@jabrena
Copy link

jabrena commented Jul 15, 2023

Hi,

I am testing your library with the example from the project:

Code:

public class BardDemo {

    public static void main(String[] args) {
        AIClient client = new GoogleBardClient("MY_TOKEN");
        Answer answer = client.ask("What is the date today?");
    }
}

but I don´t understand the following error:

17:31:59.717 [BardDemo.main()] INFO com.pkslow.ai.util.WebUtils -- Creating OkHttpClient with timeout PT5M
17:32:00.011 [BardDemo.main()] INFO com.pkslow.ai.util.WebUtils -- OkHttpClient created
17:32:00.731 [BardDemo.main()] INFO com.pkslow.ai.GoogleBardClient -- getSNlM0e Response code: 200
17:32:00.809 [BardDemo.main()] INFO com.pkslow.ai.GoogleBardClient -- calling Bard with request BardRequest{strSNlM0e=null, question=What is the date today?, conversationId=, responseId=, choiceId=}
17:32:00.814 [BardDemo.main()] ERROR com.pkslow.ai.GoogleBardClient -- Failed to get answer: 
java.lang.NullPointerException: Parameter specified as non-null is null: method okhttp3.FormBody$Builder.add, parameter value
        at okhttp3.FormBody$Builder.add(FormBody.kt)
        at com.pkslow.ai.util.BardUtils.buildRequestBodyForAsk(BardUtils.java:100)
        at com.pkslow.ai.util.BardUtils.createPostRequestForAsk(BardUtils.java:86)
        at com.pkslow.ai.GoogleBardClient.callBardToAsk(GoogleBardClient.java:89)
        at com.pkslow.ai.GoogleBardClient.ask(GoogleBardClient.java:53)
        at BardDemo.main(BardDemo.java:15)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:254)
        at java.base/java.lang.Thread.run(Thread.java:833)

I am using this version of your project:

https://mvnrepository.com/artifact/com.pkslow/google-bard

        <dependency>
            <groupId>com.pkslow</groupId>
            <artifactId>google-bard</artifactId>
            <version>0.3.3</version>
        </dependency>

Can you help me?

Many thanks in advance

Juan Antonio

@LarryDpk
Copy link
Owner

There's some change for the auth on Google Bard side. working on this to find a better solution.

@jabrena
Copy link
Author

jabrena commented Jul 18, 2023

Oki, tell me when I can test again the library

@LarryDpk
Copy link
Owner

open bard with incognito mode and get the token again can work for a short time. now Google makes the token expire soon.

@jabrena
Copy link
Author

jabrena commented Jul 18, 2023

I will try today

@jabrena
Copy link
Author

jabrena commented Jul 21, 2023

@LarryDpk
Copy link
Owner

From this issue acheong08/Bard#68 (comment) we can see:
Bard now requires 3 different types of cookies __Secure-1PAPISID, __Secure-1PSIDTS, __Secure-1PSIDCC and one of them is rotated every 20 mins. This makes the whole implementation becomes impossible.

I will add more cookies and try. But Bard is making more restriction.

@jabrena
Copy link
Author

jabrena commented Jul 22, 2023

Oki, if you have the Curl requests, I could test from my side in Spain.

@LarryDpk
Copy link
Owner

Strange, it's ok for me. Reloign incognito mode and get the new token:
image

Successful call:
image

@estebangarciaalonso
Copy link

It worked the first time as you said and then it stopped working...

@LarryDpk
Copy link
Owner

can't do anything due to Google Bard Limit

@LarryDpk
Copy link
Owner

Now it needs two cookies, please use latest version

Repository owner deleted a comment from krazyv3 Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants