-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Crash while creating completion #52
Comments
Okay, it looks like CompletionRequest changed to an implicit, inline json object which automagically gets converted into a CompletionRequest class using the json parser. Just wrap {} around the "field":"value" comma separated json data values or else explicitly create a CompletionRequest and set each value in the object. I don't see getters and setters, but it has a NoArgs default contructor and an AllArgs default constructor.
|
Sorry, meant to respond to issue #51 and was going to test your problem next. |
Okay, tested 0.8.1 api and client jars w/ this code.
|
Thanks for your reply, with this new code I get an exception with null message
|
Not sure that last exception is openai-java related. I think it's just complaining that the network call is blocking in your android thread. https://stackoverflow.com/questions/6343166/how-can-i-fix-android-os-networkonmainthreadexception It looks like you can turn off the Android default behavior (not recommended as you could potentially lock up the whole OS) or inside your main program, just put your openai calls in a Runnable. I'm on a desktop app--not Android, so I don't have same restrictions. |
|
I'm using the below code in an Android app made in Android Studio, but still getting the "Unrecognized token 'data': was expecting (JSON String, etc." error. Ideas? Thanks in advance! private class OpenAITask extends AsyncTask<String, Void, String> {
} |
Add this piece to your code and it will start working (for me it did)
Specify the method under doInBackground()
|
Unfortunately that still results in the error: Unrecognized token 'data': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false') |
Here's my code
` String token = "MY_KEYS";
OpenAiService service = new OpenAiService(token);
The text was updated successfully, but these errors were encountered: