openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

JsonProperties avoiding 'Unrecognized request argument supplied' erro…

Open GianSeb opened this issue 2 years ago • 3 comments

…r in Image and Completion Requests

For developers that don't use the client library.

Example was made with RestTemplate.

EX. ERROR: org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request: "{<EOL> "error": {<EOL> "message": "Unrecognized request argument supplied: logitBias",<EOL> "type": "invalid_request_error",<EOL> "param": null,<EOL> "code": null<EOL> }<EOL>}<EOL>"

GianSeb avatar Feb 09 '23 01:02 GianSeb

Not that it makes a diff as it's personal pref, I've been using Gson instead of Jackson annotations.

   GeneratedImage gen = gs.fromJson(response.body(), GeneratedImage.class);

public class @Data GeneratedImage {
	Integer created = 0;
	ArrayList<ImageLocation> data = null;
}

cryptoapebot avatar Feb 09 '23 01:02 cryptoapebot

@cryptoapebot Sorry but the project already use Jackson library like in Image class (com.theokanning.openai.image), and if I would use existing models like CompletionRequest in the -api- module, I need they will be serialized/deserialized correctly.

GianSeb avatar Feb 09 '23 08:02 GianSeb

Yes, of course. I'm not recommending switching, but because of my integration of calls with this library and w/ other projects, I've been forced to choose.

cryptoapebot avatar Feb 09 '23 14:02 cryptoapebot

I'll go ahead and add these everywhere, then nobody will have to will worry about setting jackson to snake case anymore

TheoKanning avatar Mar 08 '23 01:03 TheoKanning