-
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 : implement RAG #29
Conversation
WalkthroughThe 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
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
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. ImplementingSerializable
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 therecords
andtrophiesWon
fields, especially since their types are genericList<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 therag-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 toPOST
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 aswhenPostRequestToAiChat_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 theembeddingStore.findRelevant
method returns an empty list, to avoidIndexOutOfBoundsException
atrelevant.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 thesystemMessage
anduserMessage
is clear and follows the intended logic. However, consider adding error handling or validation for thelistOfSimilarDocuments
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 usesMediaType.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 thePgVectorEmbeddingStore
is a good practice, as it provides more clarity and control over the JDBC connection details. However, ensure that the transition fromDataSource
toJdbcConnectionDetails
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.
Summary by CodeRabbit
JdbcConnectionDetails
for enhanced connection management.GET
toPOST
for chat services, aligning with RESTful practices.