Skip to content

Commit aa901c7

Browse files
committed
fix: update file URL paths to use relative references
1 parent da0be4b commit aa901c7

File tree

9 files changed

+13
-20
lines changed

9 files changed

+13
-20
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def generate_history_human_message_for_details(self, chat_record):
130130
file_id_list = [image.get('file_id') for image in image_list]
131131
return HumanMessage(content=[
132132
{'type': 'text', 'text': data['question']},
133-
*[{'type': 'image_url', 'image_url': {'url': f'/oss/file/{file_id}'}} for file_id in file_id_list]
133+
*[{'type': 'image_url', 'image_url': {'url': f'./oss/file/{file_id}'}} for file_id in file_id_list]
134134

135135
])
136136
return HumanMessage(content=chat_record.problem_text)

apps/common/handle/impl/qa/xlsx_parse_qa_handle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def handle_sheet(file_name, sheet, image_dict):
3939
content = str(content.value)
4040
image = image_dict.get(content, None)
4141
if image is not None:
42-
content = f'![](/oss/file/{image.id})'
42+
content = f'![](./oss/file/{image.id})'
4343
paragraph_list.append({'title': title[0:255],
4444
'content': content[0:102400],
4545
'problem_list': problem_list})

apps/common/handle/impl/qa/zip_parse_qa_handle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ def get_image_list(result_list: list, zip_files: List[str]):
9898
else:
9999
image_file_list.append({'source_file': image_path,
100100
'image_id': new_image_id})
101-
content = content.replace(source_image_path, f'/oss/file/{new_image_id}')
101+
content = content.replace(source_image_path, f'./oss/file/{new_image_id}')
102102
p['content'] = content
103103
else:
104104
image_file_list.append({'source_file': image_path,
105105
'image_id': new_image_id})
106-
content = content.replace(source_image_path, f'/oss/file/{new_image_id}')
106+
content = content.replace(source_image_path, f'./oss/file/{new_image_id}')
107107
p['content'] = content
108108

109109
return image_file_list

apps/common/handle/impl/table/xlsx_parse_table_handle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def fill_merged_cells(self, sheet, image_dict):
4343

4444
image = image_dict.get(cell_value, None)
4545
if image is not None:
46-
cell_value = f'![](/oss/file/{image.id})'
46+
cell_value = f'![](./oss/file/{image.id})'
4747

4848
# 使用标题作为键,单元格的值作为值存入字典
4949
row_data[headers[col_idx]] = cell_value

apps/common/handle/impl/text/doc_split_handle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def image_to_mode(image, doc: Document, images_list, get_image_id):
4444
if len([i for i in images_list if i.id == image_uuid]) == 0:
4545
image = File(id=image_uuid, file_name=part.filename, meta={'debug': False, 'content': part.blob})
4646
images_list.append(image)
47-
return f'![](/oss/file/{image_uuid})'
47+
return f'![](./oss/file/{image_uuid})'
4848
return None
4949
return None
5050

apps/common/handle/impl/text/xlsx_split_handle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
def post_cell(image_dict, cell_value):
2121
image = image_dict.get(cell_value, None)
2222
if image is not None:
23-
return f'![](/oss/file/{image.id})'
23+
return f'![](./oss/file/{image.id})'
2424
return cell_value.replace('\n', '<br>').replace('|', '&#124;')
2525

2626

apps/common/handle/impl/text/zip_split_handle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ def get_image_list(result_list: list, zip_files: List[str]):
9292
else:
9393
image_file_list.append({'source_file': image_path,
9494
'image_id': new_image_id})
95-
content = content.replace(source_image_path, f'/oss/file/{new_image_id}')
95+
content = content.replace(source_image_path, f'./oss/file/{new_image_id}')
9696
p['content'] = content
9797
else:
9898
image_file_list.append({'source_file': image_path,
9999
'image_id': new_image_id})
100-
content = content.replace(source_image_path, f'/oss/file/{new_image_id}')
100+
content = content.replace(source_image_path, f'./oss/file/{new_image_id}')
101101
p['content'] = content
102102

103103
return image_file_list

apps/knowledge/serializers/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ def write_image(zip_path: str, image_list: List[str]):
167167
search = re.search("\(.*\)", image)
168168
if search:
169169
text = search.group()
170-
if text.startswith('(/oss/file/'):
171-
r = text.replace('(/oss/file/', '').replace(')', '')
170+
if text.startswith('(./oss/file/'):
171+
r = text.replace('(./oss/file/', '').replace(')', '')
172172
r = r.strip().split(" ")[0]
173173
if not is_valid_uuid(r):
174174
break

apps/tools/serializers/tool.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def edit(self, with_valid=True):
452452
)
453453
file.save(self.data.get('image').read())
454454

455-
tool.icon = f'/oss/file/{file_id}'
455+
tool.icon = f'./oss/file/{file_id}'
456456
tool.save()
457457

458458
return tool.icon
@@ -475,14 +475,7 @@ def get_internal_tools(self):
475475
Q(scope=ToolScope.INTERNAL) &
476476
Q(is_active=True)
477477
)
478-
# 处理动态url
479-
prefix = CONFIG.get_admin_path()
480-
return [
481-
{
482-
**tool,
483-
'icon': tool['icon'].replace('/admin', prefix),
484-
} for tool in ToolModelSerializer(query_set, many=True).data
485-
]
478+
return ToolModelSerializer(query_set, many=True).data
486479

487480
class AddInternalTool(serializers.Serializer):
488481
user_id = serializers.UUIDField(required=True, label=_("User ID"))

0 commit comments

Comments
 (0)