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 : implement simple RAG #38

Merged
merged 2 commits into from
Apr 7, 2024
Merged

feat : implement simple RAG #38

merged 2 commits into from
Apr 7, 2024

Conversation

rajadilipkolli
Copy link
Owner

No description provided.

Copy link
Contributor

coderabbitai bot commented Apr 7, 2024

Walkthrough

The update introduces a centralized ChatService to streamline chat functionalities, reducing direct interactions between the ChatController and clients (ChatClient, EmbeddingClient). It enhances the chat system with methods for handling various chat scenarios and RAG generation. Additionally, a new dataset of restaurant information is added, alongside a template for document-based chat responses.

Changes

File Path Change Summary
.../controller/ChatController.java Updated to use ChatService for chat functionalities and added ragGenerate method.
.../service/ChatService.java New service class for AI chat interactions, including chat processing and RAG generation.
.../resources/data/restaurants.json Added restaurant information dataset.
.../resources/rag-prompt-template.st Introduced a template for document-based chat responses.
.../controller/ChatControllerTest.java Updated tests with HttpStatus.SC_OK, added JSON content type assertions, and a new test method ragWithSimpleStore.

🐰✨
In the realm of code, under the digital sky,
A change was made, oh me, oh my!
With ChatService now leading the play,
Our chats are smarter, day by day.
So here's to the team, with brains so bright,
Making our digital world a 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.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@rajadilipkolli rajadilipkolli self-assigned this Apr 7, 2024
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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f470727 and dc63c59.
Files selected for processing (5)
  • chatmodel-springai/src/main/java/com/example/ai/controller/ChatController.java (2 hunks)
  • chatmodel-springai/src/main/java/com/example/ai/service/ChatService.java (1 hunks)
  • chatmodel-springai/src/main/resources/data/restaurants.json (1 hunks)
  • chatmodel-springai/src/main/resources/rag-prompt-template.st (1 hunks)
  • chatmodel-springai/src/test/java/com/example/ai/controller/ChatControllerTest.java (4 hunks)
Additional comments not posted (12)
chatmodel-springai/src/main/resources/rag-prompt-template.st (1)

1-9: LGTM! The RAG prompt template is well-structured and aligns with the objectives of enhancing response generation capabilities.

chatmodel-springai/src/main/java/com/example/ai/controller/ChatController.java (5)

19-22: Ensure ChatService is properly annotated with @Autowired or passed through constructor injection for maintainability and consistency with Spring's dependency injection principles.


27-52: The delegation of chat functionalities to ChatService simplifies the controller and centralizes business logic, aligning with best practices for clean architecture.


50-52: Consider adding error handling for external service calls within ChatService methods to ensure robustness and reliability of the chat functionalities.


50-52: Adding logging for incoming requests and responses can enhance observability and debugging capabilities.


50-52: The new ragGenerate method introduces RAG functionality as intended. Ensure comprehensive testing to validate its integration and functionality.

chatmodel-springai/src/test/java/com/example/ai/controller/ChatControllerTest.java (2)

38-39: Using HttpStatus.SC_OK constant and asserting JSON content type improves readability and maintainability of the tests.


79-89: The new test method ragWithSimpleStore effectively covers querying restaurant information using the RAG feature. Ensure it includes negative test cases and edge cases for comprehensive coverage.

chatmodel-springai/src/main/resources/data/restaurants.json (1)

1-10: LGTM! The restaurant data is well-structured and aligns with the objectives of enriching the application's data sources for improved response generation.

chatmodel-springai/src/main/java/com/example/ai/service/ChatService.java (3)

92-127: The ragGenerate method effectively implements the RAG feature, leveraging the new restaurant data and prompt template. Consider adding error handling for IO operations and external service calls to enhance robustness.


92-127: Ensure the deletion of documents from simpleVectorStore after processing does not affect subsequent requests or parallel processing scenarios.


92-127: Adding logging for key steps within the ragGenerate method can improve observability and debugging capabilities.

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 Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between dc63c59 and 4b1a3c6.
Files selected for processing (1)
  • chatmodel-springai/src/test/java/com/example/ai/controller/ChatControllerTest.java (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • chatmodel-springai/src/test/java/com/example/ai/controller/ChatControllerTest.java

@rajadilipkolli rajadilipkolli merged commit a2d689d into main Apr 7, 2024
2 checks passed
@rajadilipkolli rajadilipkolli deleted the rag branch April 7, 2024 09:31
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