mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: Dialogue user does not display username (#3628)
This commit is contained in:
parent
0fc4a59e96
commit
f91afd593b
|
|
@ -167,7 +167,7 @@ class ApplicationChatQuerySerializers(serializers.Serializer):
|
|||
"\n".join([
|
||||
f"{improve_paragraph_list[index].get('title')}\n{improve_paragraph_list[index].get('content')}"
|
||||
for index in range(len(improve_paragraph_list))]),
|
||||
row.get('asker').get('user_name'),
|
||||
row.get('asker').get('username'),
|
||||
(row.get('message_tokens') or 0) + (row.get('answer_tokens') or 0), row.get('run_time'),
|
||||
str(row.get('create_time').astimezone(pytz.timezone(TIME_ZONE)).strftime('%Y-%m-%d %H:%M:%S')
|
||||
if row.get('create_time') is not None else None)]
|
||||
|
|
@ -192,7 +192,6 @@ class ApplicationChatQuerySerializers(serializers.Serializer):
|
|||
worksheet.title = 'Sheet1'
|
||||
|
||||
headers = [gettext('Conversation ID'), gettext('summary'), gettext('User Questions'),
|
||||
gettext('Problem after optimization'),
|
||||
gettext('answer'), gettext('User feedback'),
|
||||
gettext('Reference segment number'),
|
||||
gettext('Section title + content'),
|
||||
|
|
|
|||
|
|
@ -56,8 +56,6 @@ class ChatRecordOperateSerializer(serializers.Serializer):
|
|||
application_id=self.data.get('application_id')).first()
|
||||
if application_access_token is None:
|
||||
raise AppApiException(500, gettext('Application authentication information does not exist'))
|
||||
if not application_access_token.show_source and not debug:
|
||||
raise AppApiException(500, gettext('Displaying knowledge sources is not enabled'))
|
||||
|
||||
def get_chat_record(self):
|
||||
chat_record_id = self.data.get('chat_record_id')
|
||||
|
|
@ -83,7 +81,7 @@ class ChatRecordOperateSerializer(serializers.Serializer):
|
|||
show_exec = application_access_token.show_exec
|
||||
show_source = application_access_token.show_source
|
||||
return ApplicationChatRecordQuerySerializers.reset_chat_record(
|
||||
chat_record, show_source, show_exec)
|
||||
chat_record, True if debug else show_source, True if debug else show_exec)
|
||||
|
||||
|
||||
class ApplicationChatRecordQuerySerializers(serializers.Serializer):
|
||||
|
|
@ -127,8 +125,8 @@ class ApplicationChatRecordQuerySerializers(serializers.Serializer):
|
|||
if item.get('type') == 'reranker-node' and item.get('show_knowledge', False):
|
||||
paragraph_list = paragraph_list + [rl.get('metadata') for rl in (item.get('result_list') or []) if
|
||||
'document_id' in (rl.get('metadata') or {}) and 'knowledge_id' in (
|
||||
rl.get(
|
||||
'metadata') or {})]
|
||||
rl.get(
|
||||
'metadata') or {})]
|
||||
paragraph_list = list({p.get('id'): p for p in paragraph_list}.values())
|
||||
knowledge_list = knowledge_list + [{'id': knowledge_id, **knowledge} for knowledge_id, knowledge in
|
||||
reduce(lambda x, y: {**x, **y},
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ SELECT
|
|||
application_chat_record_temp.improve_paragraph_list as improve_paragraph_list,
|
||||
application_chat_record_temp.vote_status as vote_status,
|
||||
application_chat_record_temp.create_time as create_time,
|
||||
(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
|
||||
(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
|
||||
FROM
|
||||
application_chat application_chat
|
||||
left join chat_user chat_user on chat_user.id::varchar = application_chat.chat_user_id
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
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
|
||||
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
|
||||
from application_chat application_chat
|
||||
left join chat_user chat_user on chat_user.id::varchar = application_chat.chat_user_id
|
||||
${default_queryset}
|
||||
|
|
@ -197,4 +197,4 @@ class ChatRecordView(APIView):
|
|||
'chat_record_id': chat_record_id,
|
||||
'application_id': request.auth.application_id,
|
||||
'chat_user_id': request.auth.chat_user_id,
|
||||
}).one(True))
|
||||
}).one(False))
|
||||
|
|
|
|||
Loading…
Reference in New Issue