소스 검색

Fix: Resolve JSON download errors in Document.download() (#8084)

### What problem does this PR solve?

An exception is thrown only when the json file has only two keys, `code`
and `message`. In other cases, response.content is returned normally.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.19.1
Liu An 5 달 전
부모
커밋
f007c1c772
No account linked to committer's email address
1개의 변경된 파일7개의 추가작업 그리고 2개의 파일을 삭제
  1. 7
    2
      sdk/python/ragflow_sdk/modules/document.py

+ 7
- 2
sdk/python/ragflow_sdk/modules/document.py 파일 보기

@@ -63,9 +63,14 @@ class Document(Base):

def download(self):
res = self.get(f"/datasets/{self.dataset_id}/documents/{self.id}")
error_keys = set(["code", "message"])
try:
res = res.json()
raise Exception(res.get("message"))
response = res.json()
actual_keys = set(response.keys())
if actual_keys == error_keys:
raise Exception(res.get("message"))
else:
return res.content
except json.JSONDecodeError:
return res.content


Loading…
취소
저장