-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Fix a "TypeError: expected string or buffer bug" in docx files extracted using Knowledge Graph.#1859 #1865
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
Merged
Conversation
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
Verify that 'reference' is not None and its length is greater than 0 before processing chunks in API4ConversationService. This prevents potential errors when 'reference' is missing or empty.
Simplify the conditionals for checking the existence and non-empty state of the 'reference' key in the API app's response and streaming logic. Additionally, enhance the rerank model in the rag module to handle empty text lists gracefully by returning an empty array and zero score.
# Conflicts: # api/apps/api_app.py
# Conflicts: # web/src/pages/user-setting/constants.tsx # web/src/pages/user-setting/setting-model/constant.ts
…files extracted using Knowledge Graph.
Halfknow
pushed a commit
to Halfknow/ragflow
that referenced
this pull request
Nov 11, 2024
…ted using Knowledge Graph.infiniflow#1859 (infiniflow#1865) ### What problem does this PR solve? Fix a "TypeError: expected string or buffer bug" in docx files extracted using Knowledge Graph. infiniflow#1859 ``` Traceback (most recent call last): File "//Users/XXX/ragflow/rag/svr/task_executor.py", line 149, in build cks = chunker.chunk(row["name"], binary=binary, from_page=row["from_page"], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/XXX/ragflow/rag/app/knowledge_graph.py", line 18, in chunk chunks = build_knowlege_graph_chunks(tenant_id, sections, callback, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/XXX/ragflow/graphrag/index.py", line 87, in build_knowlege_graph_chunks tkn_cnt = num_tokens_from_string(chunks[i]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/XXX/github/ragflow/rag/utils/__init__.py", line 79, in num_tokens_from_string num_tokens = len(encoder.encode(string)) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/XXX/tiktoken/core.py", line 116, in encode if match := _special_token_regex(disallowed_special).search(text): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: expected string or buffer ``` This type is `Dict` <img width="1689" alt="Pasted Graphic 3" src="https://github.com/user-attachments/assets/e5ba5c45-df1d-4697-98c9-14365c839f20"> The correct type should be ` Str` <img width="1725" alt="Pasted Graphic 2" src="https://github.com/user-attachments/assets/e54d5e60-4ce4-4180-b394-24e485013534"> ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe):
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.
What problem does this PR solve?
Fix a "TypeError: expected string or buffer bug" in docx files extracted using Knowledge Graph. #1859
This type is


Dict
The correct type should be
Str
Type of change