-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat: Watsonx client #45
base: master
Are you sure you want to change the base?
Conversation
There's a codestyle rules in |
} | ||
} | ||
|
||
public EventSource getCompletionAsync( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we write some integration tests for these streaming methods? It will make refactoring easier later on. You can use other int. tests as an example.
src/main/java/ee/carlrobert/llm/client/watsonx/WatsonxClient.java
Outdated
Show resolved
Hide resolved
src/main/java/ee/carlrobert/llm/client/watsonx/completion/WatsonxCompletionResponseError.java
Outdated
Show resolved
Hide resolved
src/main/java/ee/carlrobert/llm/client/watsonx/WatsonxAuthenticator.java
Outdated
Show resolved
Hide resolved
9c90c40
to
3bf1fe7
Compare
|
||
public class WatsonxAuthenticator { | ||
|
||
IBMAuthBearerToken bearerToken; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fields could be private if they're not accessed outside this class
.addHeader("Content-Type", "application/x-www-form-urlencoded") | ||
.build(); | ||
try { | ||
Response response = client.newCall(request).execute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't consider creating new bearer tokens on object initiation a good practise, please reconsider using a lazy initialization
} | ||
|
||
// Watsonx API Key | ||
public WatsonxAuthenticator(String username, String apiKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructor is too complex. Can we break it down into smaller units for better readability?
|
||
private void generateNewBearerToken() { | ||
try { | ||
Response response = client.newCall(request).execute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resources need to be cleaned up - try (Response response = client.newCall(request).execute())
.getExpiry()); | ||
} | ||
} catch (IOException e) { | ||
System.out.println(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please re-throw the exception with meaningful message
|
||
public String getBearerTokenValue() { | ||
if (!isZenApiKey && (this.bearerToken == null || (this.bearerToken.getExpiration() * 1000) | ||
< (new Date().getTime() + 60000))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 60000
could be named constant for clarity
.getMessage(); | ||
return message == null ? "" : message; | ||
} catch (Exception ex) { | ||
System.out.println(ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use proper logging
WatsonxCompletionParameters parameters; | ||
|
||
public WatsonxCompletionRequest(Builder builder) { | ||
System.out.println("Model ID: " + builder.modelId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we clean this up?
Add IBM Watsonx.ai client for use with CodeGPT Watsonx.ai integration