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 RAG #29

Merged
merged 6 commits into from
Mar 28, 2024
Merged

feat : implement RAG #29

merged 6 commits into from
Mar 28, 2024

Conversation

rajadilipkolli
Copy link
Owner

@rajadilipkolli rajadilipkolli commented Mar 28, 2024

Summary by CodeRabbit

  • New Features
    • Introduced an AI customer support agent interface for chat-based responses.
    • Implemented a REST controller for handling AI chat customer support requests.
    • Added new record classes for AI chat requests and responses, improving data validation and response structure.
  • Refactor
    • Updated database connection configuration to use JdbcConnectionDetails for enhanced connection management.
    • Changed HTTP methods from GET to POST for chat services, aligning with RESTful practices.
  • Documentation
    • Updated Swagger configuration to reflect the new service name and root URL path.
  • Tests
    • Enhanced test cases to support POST requests and added new checks for AI chat functionality.
  • Chores
    • Renamed CI build workflow for better alignment with project naming conventions.
    • Added a new application property to define the service name.

Copy link
Contributor

coderabbitai bot commented Mar 28, 2024

Walkthrough

The project underwent a significant update focusing on enhancing its AI chat capabilities, particularly around customer support and cricket-related inquiries. Key changes include renaming and reconfiguring the CI build workflow, updating database connection configurations, introducing new models and services for AI chat interactions, and shifting HTTP methods from GET to POST for API consistency. Additionally, there's a notable shift towards a more structured and interactive chat service framework, aiming to provide more precise and user-friendly responses.

Changes

Files Change Summary
.github/workflows/...-llm.yml Renamed CI build workflow and updated paths and working directory.
.../config/AIConfig.java Updated to use JdbcConnectionDetails for database connections and changed resource document.
.../config/AICustomerSupportAgent.java Introduced interface for AI customer support agent.
.../config/ChatTools.java, .../config/SwaggerConfig.java Modified annotations for tool configuration and Swagger setup.
.../controller/CustomerSupportController.java Added REST controller for handling AI chat requests.
.../domain/request/AIChatRequest.java, .../domain/response/... Introduced record classes for AI chat requests and responses.
.../service/CustomerSupportService.java, .../llmragwithspringai/... Updated service logic for AI chat interactions, focusing on cricket.
.../test/..., .../LLMRagWithSpringBootTest.java Updated tests to reflect API method changes and added new checks.
.../resources/application.properties Added spring.application.name property.

"In the land of code and sun,
Changes swift, the deed is done.
🐇 With each line, a new tale spun,
Chatting AI, second to none.
Through cricket fields, the queries run,
Under the watchful eye of none but one,
A rabbit's work, forever fun."
🌟🎉🐾

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-tests 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 tests 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 tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6adb623 and 8c8c378.
Files ignored due to path filters (5)
  • llm-rag-with-langchain4j-spring-boot/src/main/resources/medicaid-wa-faqs.pdf is excluded by !**/*.pdf
  • rag-langchain4j-AllMiniLmL6V2-llm/docker/docker-compose.yml is excluded by !**/*.yml
  • rag-langchain4j-AllMiniLmL6V2-llm/docker/docker_pgadmin_servers.json is excluded by !**/*.json
  • rag-langchain4j-AllMiniLmL6V2-llm/pom.xml is excluded by !**/*.xml
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/resources/Rohit.pdf is excluded by !**/*.pdf
Files selected for processing (16)
  • .github/workflows/rag-langchain4j-AllMiniLmL6V2-llm.yml (2 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/config/AIConfig.java (5 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/config/AICustomerSupportAgent.java (1 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/config/ChatTools.java (1 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/config/SwaggerConfig.java (1 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/controller/CustomerSupportController.java (1 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/domain/request/AIChatRequest.java (1 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/domain/response/AICustomerSupportResponse.java (1 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/service/CustomerSupportService.java (1 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/resources/application.properties (1 hunks)
  • rag-langchain4j-AllMiniLmL6V2-llm/src/test/java/com/learning/ai/LLMRagWithSpringBootTest.java (2 hunks)
  • rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java (2 hunks)
  • rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/model/request/AIChatRequest.java (1 hunks)
  • rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/model/response/AIChatResponse.java (1 hunks)
  • rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java (2 hunks)
  • rag-springai-openai-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (2 hunks)
Files skipped from review due to trivial changes (3)
  • .github/workflows/rag-langchain4j-AllMiniLmL6V2-llm.yml
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/config/ChatTools.java
  • rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/config/SwaggerConfig.java
Additional comments (18)
rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/model/response/AIChatResponse.java (1)
  • 1-5: The implementation of AIChatResponse as a record is concise and appropriate for immutable data structures. Implementing Serializable suggests it may be used in contexts requiring serialization, which is good foresight if applicable.
rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/domain/response/AICustomerSupportResponse.java (1)
  • 1-5: The AICustomerSupportResponse record is well-defined. Consider adding documentation to clarify the purpose of the records and trophiesWon fields, especially since their types are generic List<String>, which might not be immediately clear to other developers or future maintainers.
rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/domain/request/AIChatRequest.java (1)
  • 8-12: The AIChatRequest record is well-defined, and the use of validation annotations is appropriate. The inclusion of a question mark in the @Pattern regex ("^[a-zA-Z0-9 ?]*$"), while likely intended to allow question sentences, could be clarified or documented to ensure it aligns with the expected input format.
rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/model/request/AIChatRequest.java (1)
  • 1-13: This file is identical to the AIChatRequest.java in the rag-langchain4j-AllMiniLmL6V2-llm module, and the previous comments apply here as well.
rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/config/AICustomerSupportAgent.java (1)
  • 7-17: The AICustomerSupportAgent interface is well-defined, and the use of @UserMessage and @V annotations indicates proper integration with the LangChain4J framework. Consider adding documentation to clarify the purpose and usage of these framework-specific annotations for future maintainers or developers unfamiliar with LangChain4J.
rag-langchain4j-AllMiniLmL6V2-llm/src/main/resources/application.properties (1)
  • 1-1: The addition of spring.application.name is appropriate and helps in identifying the application within the Spring ecosystem. The rest of the configuration settings are standard and correctly formatted.
rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/AiController.java (1)
  • 24-27: The changes to the ragService method, including changing its HTTP method to POST and accepting a request body, are appropriate for the intended functionality. Consider adding Swagger or similar documentation annotations to describe the endpoint, its parameters, and response model for better API documentation and usability.
rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/controller/CustomerSupportController.java (1)
  • 24-27: The CustomerSupportController is well-implemented, with appropriate use of @PostMapping and @RequestBody for the /api/ai/chat endpoint. Similar to the previous controller, consider adding Swagger or similar documentation annotations to describe the endpoint, its parameters, and response model for enhanced API documentation and usability.
rag-langchain4j-AllMiniLmL6V2-llm/src/test/java/com/learning/ai/LLMRagWithSpringBootTest.java (2)
  • 30-39: The test method name whenRequestGetFromPdf_thenOK no longer accurately reflects the operation being tested, as the request method has been changed from GET to POST. Consider renaming the method to better describe its current functionality, such as whenPostRequestToAiChat_thenOK.
  • 31-39: Using a specific name like "Rohit Gurunath Sharma" in the test assertion makes the test dependent on the data setup and potentially brittle. Consider using a more generic assertion that doesn't rely on specific data unless the test setup ensures this data's presence.
rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/service/CustomerSupportService.java (1)
  • 13-37: The CustomerSupportService class is well-structured and follows good practices in dependency injection and separation of concerns. However, consider adding error handling for cases where the embeddingStore.findRelevant method returns an empty list, to avoid IndexOutOfBoundsException at relevant.get(0).
rag-springai-openai-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java (2)
  • 21-27: The updated template description for cricket is detailed and informative. However, ensure that this level of detail aligns with the overall design and user experience expectations for the AI chat service. If the service is expected to cover a wide range of topics, consider how specific topics are introduced and managed within the service.
  • 46-55: In the chat method, the process of constructing the systemMessage and userMessage is clear and follows the intended logic. However, consider adding error handling or validation for the listOfSimilarDocuments to ensure that the service can gracefully handle cases where no similar documents are found for the given query.
rag-springai-openai-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (2)
  • 30-39: The test testRag correctly uses MediaType.APPLICATION_JSON_VALUE for the content type and checks for specific responses. However, consider parameterizing the test with different queries and expected outcomes to cover a broader range of scenarios and ensure the robustness of the AI chat functionality.
  • 57-71: In the testEmptyQuery method, the validation for an empty query is well-handled, including checking for specific violation messages. This is a good practice for ensuring meaningful error responses are returned to the client. Keep this approach consistent across all error handling in the API.
rag-langchain4j-AllMiniLmL6V2-llm/src/main/java/com/learning/ai/config/AIConfig.java (3)
  • 77-98: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [64-107]

The update to use JdbcConnectionDetails for configuring the PgVectorEmbeddingStore is a good practice, as it provides more clarity and control over the JDBC connection details. However, ensure that the transition from DataSource to JdbcConnectionDetails is reflected across all database interactions within the project to maintain consistency.

  • 77-98: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [88-107]

Changing the document resource from "medicaid-wa-faqs.pdf" to "Rohit.pdf" indicates a shift in the focus of the content being used for embeddings. Ensure that this change aligns with the overall goals of the project and that the new document is properly prepared and relevant for the intended use cases.

  • 91-95: The commented-out code related to loading an HTML document and extracting text from it suggests potential future enhancements. While it's useful to keep such code for reference, consider moving it to a separate branch or documentation to keep the main codebase clean and focused on currently active functionality.

@rajadilipkolli rajadilipkolli merged commit 6d00a63 into main Mar 28, 2024
2 checks passed
@rajadilipkolli rajadilipkolli deleted the refactor branch March 28, 2024 14:52
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