Skip to content

Commit f91afd5

Browse files
authored
fix: Dialogue user does not display username (#3628)
1 parent 0fc4a59 commit f91afd5

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

apps/application/serializers/application_chat.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def to_row(row: Dict):
167167
"\n".join([
168168
f"{improve_paragraph_list[index].get('title')}\n{improve_paragraph_list[index].get('content')}"
169169
for index in range(len(improve_paragraph_list))]),
170-
row.get('asker').get('user_name'),
170+
row.get('asker').get('username'),
171171
(row.get('message_tokens') or 0) + (row.get('answer_tokens') or 0), row.get('run_time'),
172172
str(row.get('create_time').astimezone(pytz.timezone(TIME_ZONE)).strftime('%Y-%m-%d %H:%M:%S')
173173
if row.get('create_time') is not None else None)]
@@ -192,7 +192,6 @@ def stream_response():
192192
worksheet.title = 'Sheet1'
193193

194194
headers = [gettext('Conversation ID'), gettext('summary'), gettext('User Questions'),
195-
gettext('Problem after optimization'),
196195
gettext('answer'), gettext('User feedback'),
197196
gettext('Reference segment number'),
198197
gettext('Section title + content'),

apps/application/serializers/application_chat_record.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ def is_valid(self, *, debug=False, raise_exception=False):
5656
application_id=self.data.get('application_id')).first()
5757
if application_access_token is None:
5858
raise AppApiException(500, gettext('Application authentication information does not exist'))
59-
if not application_access_token.show_source and not debug:
60-
raise AppApiException(500, gettext('Displaying knowledge sources is not enabled'))
6159

6260
def get_chat_record(self):
6361
chat_record_id = self.data.get('chat_record_id')
@@ -83,7 +81,7 @@ def one(self, debug):
8381
show_exec = application_access_token.show_exec
8482
show_source = application_access_token.show_source
8583
return ApplicationChatRecordQuerySerializers.reset_chat_record(
86-
chat_record, show_source, show_exec)
84+
chat_record, True if debug else show_source, True if debug else show_exec)
8785

8886

8987
class ApplicationChatRecordQuerySerializers(serializers.Serializer):
@@ -127,8 +125,8 @@ def reset_chat_record(chat_record, show_source, show_exec):
127125
if item.get('type') == 'reranker-node' and item.get('show_knowledge', False):
128126
paragraph_list = paragraph_list + [rl.get('metadata') for rl in (item.get('result_list') or []) if
129127
'document_id' in (rl.get('metadata') or {}) and 'knowledge_id' in (
130-
rl.get(
131-
'metadata') or {})]
128+
rl.get(
129+
'metadata') or {})]
132130
paragraph_list = list({p.get('id'): p for p in paragraph_list}.values())
133131
knowledge_list = knowledge_list + [{'id': knowledge_id, **knowledge} for knowledge_id, knowledge in
134132
reduce(lambda x, y: {**x, **y},

apps/application/sql/export_application_chat_ee.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SELECT
1111
application_chat_record_temp.improve_paragraph_list as improve_paragraph_list,
1212
application_chat_record_temp.vote_status as vote_status,
1313
application_chat_record_temp.create_time as create_time,
14-
(CASE WHEN "chat_user".id is NULL THEN application_chat.asker ELSE jsonb_build_object('id',chat_user.id,'user_name',chat_user.username) END)::json AS asker
14+
(CASE WHEN "chat_user".id is NULL THEN application_chat.asker ELSE jsonb_build_object('id',chat_user.id,'username',chat_user.username) END)::json AS asker
1515
FROM
1616
application_chat application_chat
1717
left join chat_user chat_user on chat_user.id::varchar = application_chat.chat_user_id
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
select application_chat.*,(CASE WHEN "chat_user".id is NULL THEN application_chat.asker ELSE jsonb_build_object('id',chat_user.id,'user_name',chat_user.username) END)::json AS asker
1+
select application_chat.*,(CASE WHEN "chat_user".id is NULL THEN application_chat.asker ELSE jsonb_build_object('id',chat_user.id,'username',chat_user.username) END)::json AS asker
22
from application_chat application_chat
33
left join chat_user chat_user on chat_user.id::varchar = application_chat.chat_user_id
44
${default_queryset}

apps/chat/views/chat_record.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,4 @@ def get(self, request: Request, chat_id: str, chat_record_id: str):
197197
'chat_record_id': chat_record_id,
198198
'application_id': request.auth.application_id,
199199
'chat_user_id': request.auth.chat_user_id,
200-
}).one(True))
200+
}).one(False))

0 commit comments

Comments
 (0)