Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the HttpResponse for requests #16

Open
Adam1901 opened this issue Jul 13, 2024 · 2 comments
Open

Expose the HttpResponse for requests #16

Adam1901 opened this issue Jul 13, 2024 · 2 comments

Comments

@Adam1901
Copy link

Hi,

I've tried a few openAi sdks and this one shows the most promise.

My current use case is using it inside a lambda function, and this is ideal. And already live

However when the api errors for whatever reason it returns the error as a string.

It would be really helpful to have the response (or a mapped object) to check the status code is OK before carrying on with the function

@Adam1901
Copy link
Author

Adam1901 commented Jul 13, 2024

Basing the flow of execution on exceptions feels wrong to me

 try {
      String translatedText = audioClient.createTranscript(request);
      return translatedText;
    } catch (OpenAIException e) {
      throw new RuntimeException(e);
    }

@StefanBratanov
Copy link
Owner

Hi @Adam1901 nice that you are using the library. Isn't e.error() what you are looking for? You can see the Error record at https://github.com/StefanBratanov/jvm-openai/blob/master/src/main/java/io/github/stefanbratanov/jvm/openai/OpenAIException.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants