-
Notifications
You must be signed in to change notification settings - Fork 2
facade/attachment_preprocessor.py #138
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
The head ref may contain hidden characters: "135-bok-\uCCA8\uBD80\uC6A9-\uC804\uCC98\uB9AC\uAE30-\uC2DC\uC791\uD398\uC774\uC9C0-0---1"
Conversation
docling 사용 ext : hwpx, docx 그 외 langchain
Summary of ChangesHello @mestanam-mnc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 첨부 파일 처리 로직 내에서 페이지 번호 매기기 방식을 조정합니다. 이는 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
이 PR은 첨부 파일의 페이지 번호를 계산하는 로직을 수정합니다. hwpx/docx 파일과 그 외 파일의 페이지 처리를 구분하는 것이 목적으로 보입니다. 하지만 hwpx/docx가 아닌 파일에 대한 구현에서, 페이지 정보가 없는 문서가 페이지 2로 잘못 할당되는 논리적 오류가 있는 것으로 보입니다. 또한, 코드를 단순화할 수 있는 불필요한 조건문이 있습니다. 수정 제안을 포함한 구체적인 리뷰 의견을 남겼습니다.
| page = chunk.metadata.get('page', 1) | ||
| if ext not in ['.hwpx', '.docx']: | ||
| page += 1 |
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.
페이지 번호 계산 로직에 두 가지 문제가 있는 것 같습니다.
첫째, if ext not in ['.hwpx', '.docx']: 조건문은 항상 참(true)입니다. DocumentProcessor의 __call__ 메소드를 보면, 이 compose_vectors 메소드는 .hwpx나 .docx가 아닌 파일 형식에 대해서만 호출되기 때문입니다. 따라서 이 if문은 불필요하며 코드를 혼란스럽게 만들 수 있습니다.
둘째, 페이지 정보가 없는 문서의 페이지 번호 계산이 잘못된 것으로 보입니다.
- 페이지 번호가 있는 문서(예: PDF)의 경우,
chunk.metadata.get('page', 1)은 0부터 시작하는 페이지 번호(0, 1, 2...)를 반환하고, 여기에 1을 더하여 1부터 시작하는 페이지 번호(1, 2, 3...)로 올바르게 변환됩니다. - 하지만 페이지 번호가 없는 문서의 경우,
chunk.metadata.get('page', 1)은 기본값 1을 반환하고,page += 1에 의해 최종적으로 2가 됩니다. 이로 인해 해당 문서의 모든 내용은 페이지 2에 할당되는데, 이는 의도된 동작이 아닐 가능성이 높습니다. 일반적으로 페이지 1에 할당되어야 합니다.
더 간단하고 올바른 구현은 다음과 같습니다.
page = chunk.metadata.get('page', 0) + 1이렇게 하면 0부터 시작하는 페이지는 1부터 시작하도록 변환되고, 페이지가 없는 문서는 페이지 1(0 + 1)에 할당됩니다.
| page = chunk.metadata.get('page', 1) | |
| if ext not in ['.hwpx', '.docx']: | |
| page += 1 | |
| page = chunk.metadata.get('page', 0) + 1 |
파일 확장자에 따른 langchain, docling 사용여부 구분
docling
langchain
hwpx, docx를 제외한 확장자에 대해서는 page에 +1
확인필요