Skip to content

Commit 758f424

Browse files
committed
fix: replace get_byte() with get_bytes() for consistency in file handling
1 parent 93530e0 commit 758f424

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

apps/application/flow/step_node/document_extract_node/impl/base_document_extract_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def save_image(image_list):
6666

6767
for doc in document:
6868
file = QuerySet(File).filter(id=doc['file_id']).first()
69-
buffer = io.BytesIO(file.get_byte().tobytes())
69+
buffer = io.BytesIO(file.get_bytes().tobytes())
7070
buffer.name = doc['name'] # this is the important line
7171

7272
for split_handle in (parse_table_handle_list + split_handles):

apps/application/flow/step_node/image_understand_step_node/impl/base_image_understand_node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def write_context(node_variable: Dict, workflow_variable: Dict, node: INode, wor
5959

6060
def file_id_to_base64(file_id: str):
6161
file = QuerySet(File).filter(id=file_id).first()
62-
file_bytes = file.get_byte()
62+
file_bytes = file.get_bytes()
6363
base64_image = base64.b64encode(file_bytes).decode("utf-8")
6464
return [base64_image, what(None, file_bytes.tobytes())]
6565

@@ -171,7 +171,7 @@ def generate_message_list(self, image_model, system: str, prompt: str, history_m
171171
for img in image:
172172
file_id = img['file_id']
173173
file = QuerySet(File).filter(id=file_id).first()
174-
image_bytes = file.get_byte()
174+
image_bytes = file.get_bytes()
175175
base64_image = base64.b64encode(image_bytes).decode("utf-8")
176176
image_format = what(None, image_bytes.tobytes())
177177
images.append(

apps/application/flow/step_node/speech_to_text_step_node/impl/base_speech_to_text_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def process_audio_item(audio_item, model):
3030
# 根据file_name 吧文件转成mp3格式
3131
file_format = file.file_name.split('.')[-1]
3232
with tempfile.NamedTemporaryFile(delete=False, suffix=f'.{file_format}') as temp_file:
33-
temp_file.write(file.get_byte().tobytes())
33+
temp_file.write(file.get_bytes().tobytes())
3434
temp_file_path = temp_file.name
3535
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp3') as temp_amr_file:
3636
temp_mp3_path = temp_amr_file.name

apps/knowledge/serializers/document.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ def export_zip(self, with_valid=True):
558558

559559
def download_source_file(self):
560560
self.is_valid(raise_exception=True)
561-
return FileSerializer.Operate(id=self.data.get('knowledge_id')).get(with_valid=True)
561+
file = QuerySet(File).filter(source_id=self.data.get('document_id')).first()
562+
return FileSerializer.Operate(id=file.id).get(with_valid=True)
562563

563564
def one(self, with_valid=False):
564565
if with_valid:

0 commit comments

Comments
 (0)