-
Notifications
You must be signed in to change notification settings - Fork 4
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 : upgrade to 1.0.0-M1 #61
Conversation
Important Review skippedReview was skipped due to path filters Files ignored due to path filters (1)
You can disable this status message by setting the WalkthroughThe recent updates include adding Java application launch configurations in the Changes
Sequence Diagram(s)sequenceDiagram
participant Developer as Developer
participant VSCode as VSCode
participant App as Java Application
participant Logger as Logger
participant Client as API Client
Developer->>+VSCode: Launch Configuration
VSCode->>App: Start "Spring Boot-LlmRagWithSpringAiApplication<rag-springai-openai-llm>"
App->>+Logger: Log App Start
App->>Logger: Log Request Details
App->>+Client: Send API Request
Client->>-App: API Response
App->>Logger: Log Response Details
App-->>-VSCode: Running Application
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
rag/rag-springai-openai-llm/pom.xml
is excluded by!**/*.xml
Files selected for processing (1)
- rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java (3 hunks)
Additional comments not posted (2)
rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java (2)
6-10
: Updated import statements to reflect new package paths.
43-44
: Constructor now correctly uses the builder pattern forChatClient
. Good use of dependency injection forVectorStore
.
@@ -58,7 +58,7 @@ public String chat(String searchQuery) { | |||
OpenAiChatOptions chatOptions = | |||
OpenAiChatOptions.builder().withFunction("currentDateFunction").build(); | |||
Prompt prompt = new Prompt(List.of(systemMessage, userMessage), chatOptions); | |||
ChatResponse aiResponse = aiClient.call(prompt); | |||
ChatResponse aiResponse = aiClient.prompt(prompt).call().chatResponse(); |
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.
Ensure robust error handling for AI client interactions.
Consider adding try-catch blocks around the AI client call to handle potential exceptions and ensure the application's stability.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- .vscode/launch.json (1 hunks)
- rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/ResponseHeadersModification.java (1 hunks)
- rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java (3 hunks)
- rag/rag-springai-openai-llm/src/main/resources/application-local.properties (1 hunks)
- rag/rag-springai-openai-llm/src/main/resources/application.properties (1 hunks)
Files skipped from review due to trivial changes (3)
- .vscode/launch.json
- rag/rag-springai-openai-llm/src/main/resources/application-local.properties
- rag/rag-springai-openai-llm/src/main/resources/application.properties
Files skipped from review as they are similar to previous changes (1)
- rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java
Additional comments not posted (5)
rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/ResponseHeadersModification.java (5)
5-6
: Imports added for Charset, StandardCharsets, List, Logger, and StreamUtils.These imports are necessary for the new functionalities added to the class, such as logging and stream manipulation.
Also applies to: 8-10, 16-16, 22-22
28-28
: Logger instance added.This is a standard practice for logging in Java applications, and the logger is used effectively in the new methods.
32-42
: EnhancedrestClientCustomizer
method to include logging and default headers.The enhancements to the
restClientCustomizer
method are well-implemented. Logging both the request and response will provide valuable debugging information, and setting default headers is a good practice for ensuring consistent HTTP requests.
45-52
: AddedlogResponse
method to log details about the HTTP response.The method logs important response details, which can be crucial for debugging and monitoring. Using
StreamUtils
to log the response body is efficient and effective.
54-61
: AddedlogRequest
method to log details about the HTTP request.The method logs essential request details, enhancing traceability and debuggability of the application. The use of
StandardCharsets.UTF_8
for logging the request body ensures correct encoding handling.
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.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/ResponseHeadersModification.java (1 hunks)
Files not summarized due to errors (1)
- rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/ResponseHeadersModification.java: Error: Server error. Please try again later.
Additional comments not posted (3)
rag/rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/config/ResponseHeadersModification.java (3)
5-6
: Ensure the newly added imports are utilized effectively in the code.Also applies to: 8-10, 25-25
31-31
: Excellent use of a static logger for consistent logging across the class.
35-47
: Review therestClientCustomizer
method for proper HTTP client customization.This method effectively customizes the HTTP client to log requests and responses, and set default headers. It also uses a buffering request factory to enable multiple reads of the response body, which is crucial for logging.
private void logResponse(ClientHttpResponse response) throws IOException { | ||
LOGGER.info("============================response begin=========================================="); | ||
LOGGER.info("Status code : {}", response.getStatusCode()); | ||
LOGGER.info("Status text : {}", response.getStatusText()); | ||
LOGGER.info("Headers : {}", response.getHeaders()); | ||
LOGGER.info("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset())); | ||
LOGGER.info("=======================response end================================================="); | ||
} |
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.
Enhance the logResponse
method to handle potential exceptions more gracefully.
- LOGGER.info("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset()));
+ try {
+ LOGGER.info("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset()));
+ } catch (IOException e) {
+ LOGGER.error("Error reading response body", e);
+ }
This change is recommended to prevent the application from crashing in case of an IOException when reading the response body.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
private void logResponse(ClientHttpResponse response) throws IOException { | |
LOGGER.info("============================response begin=========================================="); | |
LOGGER.info("Status code : {}", response.getStatusCode()); | |
LOGGER.info("Status text : {}", response.getStatusText()); | |
LOGGER.info("Headers : {}", response.getHeaders()); | |
LOGGER.info("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset())); | |
LOGGER.info("=======================response end================================================="); | |
} | |
private void logResponse(ClientHttpResponse response) throws IOException { | |
LOGGER.info("============================response begin=========================================="); | |
LOGGER.info("Status code : {}", response.getStatusCode()); | |
LOGGER.info("Status text : {}", response.getStatusText()); | |
LOGGER.info("Headers : {}", response.getHeaders()); | |
try { | |
LOGGER.info("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset())); | |
} catch (IOException e) { | |
LOGGER.error("Error reading response body", e); | |
} | |
LOGGER.info("=======================response end================================================="); | |
} |
private void logRequest(HttpRequest request, byte[] body) { | ||
|
||
LOGGER.info("===========================request begin================================================"); | ||
LOGGER.info("URI : {}", request.getURI()); | ||
LOGGER.info("Method : {}", request.getMethod()); | ||
LOGGER.info("Headers : {}", request.getHeaders()); | ||
LOGGER.info("Request body: {}", new String(body, StandardCharsets.UTF_8)); | ||
LOGGER.info("==========================request end================================================"); |
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.
Refactor the logRequest
method to handle potential exceptions more gracefully.
- LOGGER.info("Request body: {}", new String(body, StandardCharsets.UTF_8));
+ try {
+ LOGGER.info("Request body: {}", new String(body, StandardCharsets.UTF_8));
+ } catch (Exception e) {
+ LOGGER.error("Error logging request body", e);
+ }
This change ensures that any exceptions during the logging of the request body are caught and handled appropriately.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
private void logRequest(HttpRequest request, byte[] body) { | |
LOGGER.info("===========================request begin================================================"); | |
LOGGER.info("URI : {}", request.getURI()); | |
LOGGER.info("Method : {}", request.getMethod()); | |
LOGGER.info("Headers : {}", request.getHeaders()); | |
LOGGER.info("Request body: {}", new String(body, StandardCharsets.UTF_8)); | |
LOGGER.info("==========================request end================================================"); | |
private void logRequest(HttpRequest request, byte[] body) { | |
LOGGER.info("===========================request begin================================================"); | |
LOGGER.info("URI : {}", request.getURI()); | |
LOGGER.info("Method : {}", request.getMethod()); | |
LOGGER.info("Headers : {}", request.getHeaders()); | |
try { | |
LOGGER.info("Request body: {}", new String(body, StandardCharsets.UTF_8)); | |
} catch (Exception e) { | |
LOGGER.error("Error logging request body", e); | |
} | |
LOGGER.info("==========================request end================================================"); |
No description provided.