Skip to content

Commit 31147c0

Browse files
authored
fix: AI conversation file upload image cannot be loaded (#3512)
1 parent 0bd6485 commit 31147c0

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

apps/application/serializers/application_chat_record.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,18 @@ def reset_chat_record(chat_record, show_source, show_exec):
155155
'padding_problem_text': chat_record.details.get('problem_padding').get(
156156
'padding_problem_text') if 'problem_padding' in chat_record.details else None,
157157
**(show_source_dict if show_source else {}),
158-
**(show_exec_dict if show_exec else {})
158+
**(show_exec_dict if show_exec else show_exec_dict)
159159
}
160160

161-
def page(self, current_page: int, page_size: int, with_valid=True):
161+
def page(self, current_page: int, page_size: int, with_valid=True, show_source=None, show_exec=None):
162162
if with_valid:
163163
self.is_valid(raise_exception=True)
164164
order_by = '-create_time' if self.data.get('order_asc') is None or self.data.get(
165165
'order_asc') else 'create_time'
166-
application_access_token = QuerySet(ApplicationAccessToken).filter(
167-
application_id=self.data.get('application_id')).first()
168-
show_source = False
169-
show_exec = False
170-
if application_access_token is not None:
171-
show_exec = application_access_token.show_exec
172-
show_source = application_access_token.show_source
166+
if show_source is None:
167+
show_source = True
168+
if show_exec is None:
169+
show_exec = True
173170
page = page_search(current_page, page_size,
174171
QuerySet(ChatRecord).filter(chat_id=self.data.get('chat_id')).order_by(order_by),
175172
post_records_handler=lambda chat_record: self.reset_chat_record(chat_record, show_source,

apps/chat/serializers/chat_record.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from django.utils.translation import gettext_lazy as _, gettext
1414
from rest_framework import serializers
1515

16-
from application.models import VoteChoices, ChatRecord, Chat
16+
from application.models import VoteChoices, ChatRecord, Chat, ApplicationAccessToken
1717
from application.serializers.application_chat import ChatCountSerializer
1818
from application.serializers.application_chat_record import ChatRecordSerializerModel, \
1919
ApplicationChatRecordQuerySerializers
@@ -159,6 +159,13 @@ def list(self):
159159

160160
def page(self, current_page, page_size):
161161
self.is_valid(raise_exception=True)
162+
application_access_token = QuerySet(ApplicationAccessToken).filter(
163+
application_id=self.data.get('application_id')).first()
164+
show_source = False
165+
show_exec = False
166+
if application_access_token is not None:
167+
show_exec = application_access_token.show_exec
168+
show_source = application_access_token.show_source
162169
return ApplicationChatRecordQuerySerializers(
163170
data={'application_id': self.data.get('application_id'), 'chat_id': self.data.get('chat_id')}).page(
164-
current_page, page_size)
171+
current_page, page_size, show_source=show_source, show_exec=show_exec)

ui/src/components/ai-chat/component/chat-input-operate/index.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,8 @@
129129
</el-row>
130130
<el-space wrap>
131131
<template v-for="(item, index) in uploadImageList" :key="index">
132-
133132
<div
134133
class="file file-image cursor border border-r-6"
135-
v-if="item.url"
136134
@mouseenter.stop="mouseenter(item)"
137135
@mouseleave.stop="mouseleave()"
138136
>
@@ -239,6 +237,7 @@
239237
:show-file-list="false"
240238
:accept="getAcceptList()"
241239
:on-change="(file: any, fileList: any) => uploadFile(file, fileList)"
240+
v-model:file-list="fileAllList"
242241
ref="upload"
243242
>
244243
<el-tooltip

0 commit comments

Comments
 (0)