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

feat : upgrade to 1.0.0-M1 #61

Closed
wants to merge 10 commits into from
Closed

feat : upgrade to 1.0.0-M1 #61

wants to merge 10 commits into from

Conversation

rajadilipkolli
Copy link
Owner

No description provided.

@rajadilipkolli rajadilipkolli self-assigned this May 30, 2024
Copy link
Contributor

coderabbitai bot commented May 30, 2024

Important

Review skipped

Review was skipped due to path filters

Files ignored due to path filters (1)
  • rag/rag-springai-openai-llm/pom.xml is excluded by !**/*.xml

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent updates include adding Java application launch configurations in the .vscode/launch.json file, enhancing the ResponseHeadersModification class with improved logging and default headers, refining import paths and constructor usage in the AIChatService class, and updating application properties configurations to include new defaults and embedding model specifications.

Changes

Files Change Summary
.vscode/launch.json Added configurations for launching Java applications related to rag-springai-openai-llm.
rag/.../config/ResponseHeadersModification.java Enhanced with additional imports, request and response logging, and default headers in restClientCustomizer.
rag/.../service/AIChatService.java Updated imports and refactored constructor to use ChatClient.Builder.
rag/.../resources/application-local.properties Added default value 384 for spring.ai.vectorstore.pgvector.dimensions.
rag/.../resources/application.properties Updated text embedding model to text-embedding-ada-002 for spring.ai.openai.embedding.options.model.

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
Loading

Poem

🌼 In lines of code, where logic does dwell,
The launch configs now set to propel,
With headers logged and data aligned,
A service built with AI in mind.
New models and properties take flight,
In this code, there's pure delight!
💻✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 5af5bde and 0d932ba.

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 for ChatClient. Good use of dependency injection for VectorStore.

@@ -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();
Copy link
Contributor

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 0d932ba and 21f9420.

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: Enhanced restClientCustomizer 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: Added logResponse 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: Added logRequest 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 21f9420 and 2bb1195.

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 the restClientCustomizer 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.

Comment on lines 50 to 57
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=================================================");
}
Copy link
Contributor

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.

Suggested change
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=================================================");
}

Comment on lines 59 to 66
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================================================");
Copy link
Contributor

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.

Suggested change
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================================================");

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

Successfully merging this pull request may close these issues.

1 participant