Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Gemini API endpoint to use the 'gemini-2.0-flash-lite' model. The review feedback suggests externalizing the API URL to a configuration file instead of hardcoding it as a constant to improve maintainability and flexibility across different environments.
Comment on lines
15
to
+16
| private static final String GEMINI_URL = | ||
| "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent"; | ||
| "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-lite:generateContent"; |
There was a problem hiding this comment.
Gemini 모델 URL을 상수로 하드코딩하는 대신, application.properties와 같은 설정 파일에서 값을 주입받도록 변경하는 것을 고려해 보세요. apiKey가 이미 설정 파일에서 주입되고 있는 것처럼, URL도 외부 설정으로 분리하면 향후 모델 변경이나 환경별(예: 개발, 프로덕션) 설정 관리가 더 유연해집니다.
예를 들어, 다음과 같이 리팩터링할 수 있습니다.
@Component
public class GeminiClient {
private final RestClient restClient;
private final String apiKey;
private final String geminiUrl;
public GeminiClient(
@Value("${gemini.api-key:}") String apiKey,
@Value("${gemini.url:https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-lite:generateContent}") String geminiUrl
) {
this.apiKey = apiKey;
this.geminiUrl = geminiUrl;
this.restClient = RestClient.create();
}
public String generateComment(String systemInstruction, String userPrompt) {
// ...
Map<?, ?> response = restClient.post()
.uri(geminiUrl + "?key=" + apiKey)
// ...
}
}이렇게 변경하면 코드 수정 없이 설정 파일 변경만으로 Gemini 모델을 쉽게 교체할 수 있습니다.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
gemini-2.0-flash 무료 티어 쿼터 0 → gemini-2.0-flash-lite로 변경