feat: Chat record details (#3418)
This commit is contained in:
parent
22d86f046a
commit
4b4691d689
@ -14,6 +14,7 @@ urlpatterns = [
|
|||||||
path('captcha', views.CaptchaView.as_view(), name='captcha'),
|
path('captcha', views.CaptchaView.as_view(), name='captcha'),
|
||||||
path('vote/chat/<str:chat_id>/chat_record/<str:chat_record_id>', views.VoteView.as_view(), name='vote'),
|
path('vote/chat/<str:chat_id>/chat_record/<str:chat_record_id>', views.VoteView.as_view(), name='vote'),
|
||||||
path('historical_conversation', views.HistoricalConversationView.as_view(), name='historical_conversation'),
|
path('historical_conversation', views.HistoricalConversationView.as_view(), name='historical_conversation'),
|
||||||
|
path('historical_conversation/<str:chat_id>/record/<str:chat_record_id>',views.ChatRecordView.as_view(),name='conversation_details'),
|
||||||
path('historical_conversation/<int:current_page>/<int:page_size>', views.HistoricalConversationView.PageView.as_view(), name='historical_conversation'),
|
path('historical_conversation/<int:current_page>/<int:page_size>', views.HistoricalConversationView.PageView.as_view(), name='historical_conversation'),
|
||||||
path('historical_conversation_record/<str:chat_id>', views.HistoricalConversationRecordView.as_view(), name='historical_conversation_record'),
|
path('historical_conversation_record/<str:chat_id>', views.HistoricalConversationRecordView.as_view(), name='historical_conversation_record'),
|
||||||
path('historical_conversation_record/<str:chat_id>/<int:current_page>/<int:page_size>', views.HistoricalConversationRecordView.PageView.as_view(), name='historical_conversation_record')
|
path('historical_conversation_record/<str:chat_id>/<int:current_page>/<int:page_size>', views.HistoricalConversationRecordView.PageView.as_view(), name='historical_conversation_record')
|
||||||
|
|||||||
@ -11,6 +11,7 @@ from drf_spectacular.utils import extend_schema
|
|||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
|
from application.serializers.application_chat_record import ChatRecordOperateSerializer
|
||||||
from chat.api.chat_api import HistoricalConversationAPI, PageHistoricalConversationAPI, \
|
from chat.api.chat_api import HistoricalConversationAPI, PageHistoricalConversationAPI, \
|
||||||
PageHistoricalConversationRecordAPI, HistoricalConversationRecordAPI
|
PageHistoricalConversationRecordAPI, HistoricalConversationRecordAPI
|
||||||
from chat.api.vote_api import VoteAPI
|
from chat.api.vote_api import VoteAPI
|
||||||
@ -118,3 +119,25 @@ class HistoricalConversationRecordView(APIView):
|
|||||||
'application_id': request.auth.application_id,
|
'application_id': request.auth.application_id,
|
||||||
'chat_user_id': request.auth.chat_user_id,
|
'chat_user_id': request.auth.chat_user_id,
|
||||||
}).page(current_page, page_size))
|
}).page(current_page, page_size))
|
||||||
|
|
||||||
|
|
||||||
|
class ChatRecordView(APIView):
|
||||||
|
authentication_classes = [TokenAuth]
|
||||||
|
|
||||||
|
@extend_schema(
|
||||||
|
methods=['GET'],
|
||||||
|
description=_("Get conversation details"),
|
||||||
|
summary=_("Get conversation details"),
|
||||||
|
operation_id=_("Get conversation details"), # type: ignore
|
||||||
|
parameters=PageHistoricalConversationRecordAPI.get_parameters(),
|
||||||
|
responses=PageHistoricalConversationRecordAPI.get_response(),
|
||||||
|
tags=[_('Chat')] # type: ignore
|
||||||
|
)
|
||||||
|
def get(self, request: Request, chat_id: str, chat_record_id: str):
|
||||||
|
return result.success(ChatRecordOperateSerializer(
|
||||||
|
data={
|
||||||
|
'chat_id': chat_id,
|
||||||
|
'chat_record_id': chat_record_id,
|
||||||
|
'application_id': request.auth.application_id,
|
||||||
|
'chat_user_id': request.auth.chat_user_id,
|
||||||
|
}).one(True))
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import {
|
|||||||
} from '@/request/chat/index'
|
} from '@/request/chat/index'
|
||||||
import { type ChatProfile } from '@/api/type/chat'
|
import { type ChatProfile } from '@/api/type/chat'
|
||||||
import { type Ref } from 'vue'
|
import { type Ref } from 'vue'
|
||||||
import type { ResetPasswordRequest } from "@/api/type/user.ts";
|
import type { ResetPasswordRequest } from '@/api/type/user.ts'
|
||||||
|
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
import type { LoginRequest } from '@/api/type/user'
|
import type { LoginRequest } from '@/api/type/user'
|
||||||
@ -219,7 +219,7 @@ const logout: (loading?: Ref<boolean>) => Promise<Result<boolean>> = (loading) =
|
|||||||
*/
|
*/
|
||||||
const resetCurrentPassword: (
|
const resetCurrentPassword: (
|
||||||
request: ResetPasswordRequest,
|
request: ResetPasswordRequest,
|
||||||
loading?: Ref<boolean>
|
loading?: Ref<boolean>,
|
||||||
) => Promise<Result<boolean>> = (request, loading) => {
|
) => Promise<Result<boolean>> = (request, loading) => {
|
||||||
return post('/chat_user/current/reset_password', request, undefined, loading)
|
return post('/chat_user/current/reset_password', request, undefined, loading)
|
||||||
}
|
}
|
||||||
@ -230,6 +230,21 @@ const resetCurrentPassword: (
|
|||||||
const getChatUserProfile: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
|
const getChatUserProfile: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
|
||||||
return get('/chat_user/profile', {}, loading)
|
return get('/chat_user/profile', {}, loading)
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取对话详情
|
||||||
|
* @param chat_id 对话id
|
||||||
|
* @param chat_record_id 对话记录id
|
||||||
|
* @param loading 加载器
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
const getChatRecord: (
|
||||||
|
chat_id: string,
|
||||||
|
chat_record_id: string,
|
||||||
|
loading?: Ref<boolean>,
|
||||||
|
) => Promise<Result<any>> = (chat_id, chat_record_id, loading) => {
|
||||||
|
return get(`historical_conversation/${chat_id}/record/${chat_record_id}`, {}, loading)
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
open,
|
open,
|
||||||
chat,
|
chat,
|
||||||
@ -252,5 +267,6 @@ export default {
|
|||||||
pageChatRecord,
|
pageChatRecord,
|
||||||
logout,
|
logout,
|
||||||
resetCurrentPassword,
|
resetCurrentPassword,
|
||||||
getChatUserProfile
|
getChatUserProfile,
|
||||||
|
getChatRecord,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -312,6 +312,37 @@ const getOpenChatAPI = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取对话详情
|
||||||
|
* @param row
|
||||||
|
*/
|
||||||
|
function getSourceDetail(row: any) {
|
||||||
|
if (row.record_id) {
|
||||||
|
if (props.type === 'debug-ai-chat') {
|
||||||
|
chatLogApi
|
||||||
|
.getChatRecordDetails(id || props.appId, row.chat_id, row.record_id, loading)
|
||||||
|
.then((res) => {
|
||||||
|
const exclude_keys = ['answer_text', 'id', 'answer_text_list']
|
||||||
|
Object.keys(res.data).forEach((key) => {
|
||||||
|
if (!exclude_keys.includes(key)) {
|
||||||
|
row[key] = res.data[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
chatAPI.getChatRecord(row.chat_id, row.record_id, loading).then((res) => {
|
||||||
|
const exclude_keys = ['answer_text', 'id', 'answer_text_list']
|
||||||
|
Object.keys(res.data).forEach((key) => {
|
||||||
|
if (!exclude_keys.includes(key)) {
|
||||||
|
row[key] = res.data[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 对话
|
* 对话
|
||||||
*/
|
*/
|
||||||
@ -511,26 +542,6 @@ function chatMessage(chat?: any, problem?: string, re_chat?: boolean, other_para
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取对话详情
|
|
||||||
* @param row
|
|
||||||
*/
|
|
||||||
function getSourceDetail(row: any) {
|
|
||||||
if (row.record_id) {
|
|
||||||
chatLogApi
|
|
||||||
.getChatRecordDetails(id || props.appId, row.chat_id, row.record_id, loading)
|
|
||||||
.then((res) => {
|
|
||||||
const exclude_keys = ['answer_text', 'id', 'answer_text_list']
|
|
||||||
Object.keys(res.data).forEach((key) => {
|
|
||||||
if (!exclude_keys.includes(key)) {
|
|
||||||
row[key] = res.data[key]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 滚动条距离最上面的高度
|
* 滚动条距离最上面的高度
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user