-
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 : expose endpoint to upload multiple documents #46
Conversation
WalkthroughThe recent updates across various Java files and properties in the Spring AI application primarily focus on enhancing data handling capabilities, refining AI service interactions, and updating model configurations. These changes streamline operations, improve data indexing and querying functionalities, and shift to using the more advanced Changes
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: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/config/AppConfig.java (1 hunks)
- rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/DataIndexController.java (1 hunks)
- rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java (2 hunks)
- rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/service/DataIndexerService.java (1 hunks)
- rag/rag-springai-ollama-llm/src/main/resources/application.properties (1 hunks)
- rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (5 hunks)
- rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/TestLlmRagWithSpringAiApplication.java (1 hunks)
Additional comments not posted (13)
rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/config/AppConfig.java (1)
1-11
: The configuration appears clean and well-implemented.rag/rag-springai-ollama-llm/src/main/resources/application.properties (2)
6-9
: Updated AI model and parameters align with the intended enhancements for chat functionality.
11-11
: Model update for embedding functionality is consistent with the changes in chat model configuration.rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/DataIndexController.java (2)
20-28
: The new file upload endpoint is well-implemented with proper exception handling.
31-34
: The method for retrieving the count of indexed data is correctly implemented.rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/TestLlmRagWithSpringAiApplication.java (1)
21-22
: The update of the Docker image for testing aligns with the new AI model used in production settings.rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/service/AIChatService.java (1)
45-46
: Simplification of the similarity search method enhances clarity and maintainability.rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/service/DataIndexerService.java (2)
29-53
: The method for loading and indexing documents is robust, handling multiple document types and logging appropriately.
56-58
: The method for counting documents in the vector store is implemented efficiently.rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (4)
36-43
: The test for uploading PDF content is correctly implemented and verifies the endpoint's functionality.
49-53
: The test for handling chat requests is well-implemented, ensuring the chat functionality responds as expected.
Line range hint
64-82
: Tests for handling edge cases in chat requests (empty and long queries) are thorough and ensure robust error handling.
101-101
: The test for special characters in chat queries effectively checks for input validation.
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
Out of diff range and nitpick comments (2)
rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (2)
12-13
: Consider usingPath
overFile
for better performance and flexibility.Java's
Path
API, part of the NIO package, provides more modern and flexible file operations compared to the olderFile
class. It's recommended to usePath
for new developments.
Line range hint
106-125
: Consider testing for other types of long queries.Testing with a single repeated character is a good start, but consider adding tests with more complex long strings, such as those including spaces or special characters. Would you like assistance in generating these additional test cases?
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/DataIndexController.java (1 hunks)
- rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (6 hunks)
Files skipped from review as they are similar to previous changes (1)
- rag/rag-springai-ollama-llm/src/main/java/com/learning/ai/llmragwithspringai/controller/DataIndexController.java
Additional comments not posted (4)
rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (4)
36-45
: Ensure the PDF file path is correctly referenced and accessible.Verification successful
The shell script output confirms the existence of the PDF file "Rohit_Gurunath_Sharma.pdf" within the repository, specifically located in the
src/main/resources
directory of therag-springai-ollama-llm
module. This location is a standard directory for resources in a Java project, which are typically accessible via the classpath.Given this information, the PDF file path referenced in the test method
uploadPdfContent()
should be correctly accessible if the methodgetFile()
appropriately resolves paths to the classpath resources. The review comment's concern about verifying the PDF file path's correctness and accessibility is addressed by the script's output showing the file's presence in a standard resource directory.Therefore, I will conclude that the file path is correctly referenced and accessible in the context of the test environment.
PDF File Path Verified and Accessible
The PDF file "Rohit_Gurunath_Sharma.pdf" used in the test
uploadPdfContent()
is correctly placed in the resources directory and should be accessible via the classpath. This setup aligns with standard Java project practices for handling resources.
- File Location:
src/main/resources/Rohit_Gurunath_Sharma.pdf
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of the PDF file used in tests. # Test: Check if the file exists in the classpath. fd --type file 'Rohit_Gurunath_Sharma.pdf' --exec ls -l {}Length of output: 175
47-57
: LGTM! Good use of REST Assured for API testing.This test method effectively checks the count of uploaded documents, ensuring the endpoint behaves as expected under normal conditions.
Line range hint
88-106
: Excellent coverage of edge cases for chat functionality.This test method effectively handles an empty query scenario, ensuring the system responds with appropriate error messages and status codes.
Line range hint
125-142
: Good validation of special characters in queries.This test ensures that the system correctly handles queries with special characters, returning appropriate error messages and status codes.
...m/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java
Outdated
Show resolved
Hide resolved
...m/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java
Outdated
Show resolved
Hide resolved
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 (1)
- rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (7 hunks)
Files not reviewed due to errors (1)
- rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (no review received)
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-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (7 hunks)
Additional comments not posted (7)
rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java (7)
52-62
: LGTM! The test for counting uploaded PDF content is correctly implemented.
Line range hint
64-89
: LGTM! The AI chat functionality tests are well-implemented and cover basic query scenarios.
Line range hint
92-138
: LGTM! The tests for handling empty and special character queries in AI chat are correctly implemented.
164-178
: LGTM! The test for unsupported content types is correctly implemented.
180-197
: LGTM! The test for missing required fields in AI chat requests is correctly implemented.
199-213
: LGTM! The test for handling invalid JSON structures in AI chat requests is correctly implemented.
215-217
: Ensure thegetPath
method handles exceptions properly.
void uploadPdfContent() throws IOException, URISyntaxException { | ||
given().multiPart("file", getPath("/Rohit_Gurunath_Sharma.pdf").toFile()) | ||
.when() | ||
.post("/api/data/v1/upload") | ||
.then() | ||
.statusCode(200) | ||
.log() | ||
.all(); | ||
} |
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.
Tip
Codebase Verification
The verification process has shown that the file "/Rohit_Gurunath_Sharma.pdf" does not exist in the 'src/test/resources' directory, which was assumed to be the correct location based on the context of a typical Java project structure. This suggests that there might be an issue with how the file path is handled or documented in the test setup. It is recommended to review the implementation of the getPath
method to ensure it points to the correct location and that the necessary test files are properly placed in the project structure.
- Review the implementation of the
getPath
method to confirm the intended file path. - Ensure that the file "/Rohit_Gurunath_Sharma.pdf" is correctly placed in the project structure as expected by the test.
Analysis chain
Ensure the file path in getPath
method is correctly handled.
The verification script intended to check the existence of the file specified in the getPath
method failed because the Java command could not be executed in the script's environment. This means we haven't yet verified whether the file path is correctly handled in the code.
To proceed, I recommend running a revised script that doesn't rely on executing Java, but instead directly checks the file system based on expected outcomes from the getPath
method, if such expected outcomes can be inferred from the codebase or documentation.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that the file path provided in the `getPath` method is correctly handled and accessible.
# Test: Check if the file exists at the specified path.
if [ -f "$(java -jar rag/rag-springai-ollama-llm/src/test/java/com/learning/ai/llmragwithspringai/LlmRagWithSpringAiApplicationIntTest.java getPath /Rohit_Gurunath_Sharma.pdf)" ]; then
echo "File exists."
else
echo "File does not exist."
fi
Length of output: 305
Script:
#!/bin/bash
# Description: Check if the file path "/Rohit_Gurunath_Sharma.pdf" exists in the expected directory.
# Assuming the file should be located in a 'resources' directory under 'src/test/java'
if [ -f "src/test/resources/Rohit_Gurunath_Sharma.pdf" ]; then
echo "File exists."
else
echo "File does not exist."
fi
Length of output: 108
@Test | ||
@Order(114) | ||
void testNullRequestBody() { | ||
given().contentType(ContentType.JSON) | ||
.body(Optional.empty()) | ||
.when() | ||
.post("/api/ai/chat") | ||
.then() | ||
.statusCode(400) | ||
.header(HttpHeaders.CONTENT_TYPE, is(MediaType.APPLICATION_PROBLEM_JSON_VALUE)) | ||
.body("detail", is("Failed to read request")) | ||
.body("instance", is("/api/ai/chat")) | ||
.body("title", is("Bad Request")) | ||
.log(); | ||
} |
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.
This test checks for null request bodies in AI chat. Consider adding a more descriptive error message.
- .body("detail", is("Failed to read request"))
+ .body("detail", is("Request body cannot be null or empty"))
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.
@Test | |
@Order(114) | |
void testNullRequestBody() { | |
given().contentType(ContentType.JSON) | |
.body(Optional.empty()) | |
.when() | |
.post("/api/ai/chat") | |
.then() | |
.statusCode(400) | |
.header(HttpHeaders.CONTENT_TYPE, is(MediaType.APPLICATION_PROBLEM_JSON_VALUE)) | |
.body("detail", is("Failed to read request")) | |
.body("instance", is("/api/ai/chat")) | |
.body("title", is("Bad Request")) | |
.log(); | |
} | |
@Test | |
@Order(114) | |
void testNullRequestBody() { | |
given().contentType(ContentType.JSON) | |
.body(Optional.empty()) | |
.when() | |
.post("/api/ai/chat") | |
.then() | |
.statusCode(400) | |
.header(HttpHeaders.CONTENT_TYPE, is(MediaType.APPLICATION_PROBLEM_JSON_VALUE)) | |
.body("detail", is("Request body cannot be null or empty")) | |
.body("instance", is("/api/ai/chat")) | |
.body("title", is("Bad Request")) | |
.log(); | |
} |
No description provided.