Skip to content

Instantly share code, notes, and snippets.

@SuvidhaMalaviya
Created February 5, 2023 12:08
Show Gist options
  • Save SuvidhaMalaviya/c0dd18323d071117d86e9946744b76e4 to your computer and use it in GitHub Desktop.
Save SuvidhaMalaviya/c0dd18323d071117d86e9946744b76e4 to your computer and use it in GitHub Desktop.
ChatGPT Integration-3
Call<ResponseBody> call = chatGPTAPI.sendRequest("Hello, how are you?", 100, 0.5f);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
try {
// Use response.body() to access the response from the API
String responseString = response.body().string();
// Do something with the response
} catch (IOException e) {
// Handle the exception
}
} else {
// Handle the error
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
// Handle the failure
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment