Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
The PR introduces support for extracting text from DOCX files, refactors file content extraction into a unified get_file_content function with pluggable extractors, and adds corresponding tests and a new dependency.
- Refactor
get_file_contentto use a content-type→extractor mapping and add_extract_docx_content - Update endpoint formatting to handle already-decoded content strings
- Add tests for DOCX, PDF, TXT, unsupported, and empty file scenarios and include
python-docxin dependencies
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/app/services/tutor/utils.py | Refactored file extraction with extractor mapping, added DOCX support |
| src/app/api/api_v1/endpoints/tutor.py | Updated formatting to use string content directly |
| src/app/tests/services/tutor/test_utils.py | Added tests for DOCX, PDF, TXT, unsupported, and empty files |
| pyproject.toml | Added python-docx dependency |
Comments suppressed due to low confidence (2)
src/app/tests/services/tutor/test_utils.py:118
- [nitpick] Opening a real file in tests can lead to environment dependencies. Use an in-memory stream (e.g.,
BytesIO(b"")) to simulate an empty file for more reliable tests.
file = open("test.empty.txt", "rb"),
src/app/services/tutor/utils.py:76
- [nitpick] Internal helper functions like
_extract_pdf_contentcould use a brief docstring to explain their purpose and expected behavior for maintainability.
async def _extract_pdf_content(file) -> str:
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Why?
How?
Screenshots (if appropriate):
Types of changes
Checklist: