This repository was archived by the owner on Jun 6, 2024. It is now read-only.
Done some Refactoring, like extract method, extract class, decomposing conditional etc. #489
Open
BuzzLightyear2002 wants to merge 1 commit intoTheoKanning:mainfrom
Open
Done some Refactoring, like extract method, extract class, decomposing conditional etc. #489BuzzLightyear2002 wants to merge 1 commit intoTheoKanning:mainfrom
BuzzLightyear2002 wants to merge 1 commit intoTheoKanning:mainfrom
Conversation
jaDEVirek
reviewed
Apr 2, 2024
jaDEVirek
left a comment
There was a problem hiding this comment.
Looks good with some nits.
Thanks.
| // Constants for token counts per message and name | ||
| final int TOKENS_PER_MESSAGE_GPT_3_5_TURBO = 4; | ||
| final int TOKENS_PER_MESSAGE_GPT_4 = 3; | ||
| final int TOKENS_PER_NAME = 1; |
There was a problem hiding this comment.
Final members for utils class, should be static.
Reason: It provides better performance, values are inlined at compile time instead of a runtime value lookup.
|
|
||
| AssistantRequest assistantRequest = AssistantRequest.builder() | ||
| .model(TikTokensUtil.ModelEnum.GPT_4_1106_preview.getName()) | ||
| .model(TikTokensUtil.ModelEnum.GPT_3_5_TURBO.getName()) |
There was a problem hiding this comment.
Is there any good reason, why the model type changed?
Thanks.
| Map<JsonToken, JsonNodeHandler> handlers = new HashMap<>(); | ||
| handlers.put(JsonToken.VALUE_NULL, new MissingNodeHandler()); | ||
| // Add more handlers for different token types if needed | ||
| return handlers; |
There was a problem hiding this comment.
Nit: Returning collections such as Map - from functions, should preserve their immutability.
Thing about collections.unmodifiableMap
https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#unmodifiableMap-java.util.Map-
| ); | ||
| throw new OpenAiHttpException(error, e, e.code()); | ||
| } | ||
| } |
There was a problem hiding this comment.
Nit: It can be optimized
try {
ResponseBody errorBody = response.errorBody();
if (errorBody != null) {
OpenAiError error = mapper.readValue(errorBody.string(), OpenAiError.class);
throw new OpenAiHttpException(error, new HttpException(response), response.code());
}
} catch (IOException ex) {
throw new HttpException(response);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for submitting a pull request! Please check CONTRIBUTING.md for style guidelines.
Changes
Describe your changes here
New API Checklist
See CONTRIBUTING.md for more info.