Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/models_provider/serializers/model_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def _build_query_params(self, workspace_id, workspace_manage: bool, user_id):
queryset = queryset.filter(user_id=value)
else:
queryset = queryset.filter(**{field: value})
queryset = queryset.order_by("-create_time")
queryset = queryset.select_related("user").order_by("-create_time")
return (
{
"model_query_set": queryset,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { get, post, put, del, postStream } from '@/api/admin/core/request'
import { ADMIN_API_BASE_PATH as adminApiBase } from '@/api/constants'

const getPrefix = (applicationId: string) => `/system/resource/application/${applicationId}`

/** 打开对话。 */
const getConversationOpen = (applicationId: string) => get(`${getPrefix(applicationId)}/open`)

/** 发送对话消息并返回原始流式响应。 */
const postConversationMessage = (chatId: string, data: unknown, applicationId: string) =>
postStream(adminApiBase, `${getPrefix(applicationId)}/chat/${chatId}/chat_message`, data)

/** 取消对话消息生成。 */
const postCancelConversationMessage = (chatId: string, applicationId: string) =>
post(`${getPrefix(applicationId)}/chat/${chatId}/cancel_chat_message`, {})

/** 恢复对话消息流。 */
const postResumeConversationMessage = (chatId: string, chatRecordId: string, applicationId: string) =>
postStream(
adminApiBase,
`${getPrefix(applicationId)}/chat/${chatId}/chat_record/${chatRecordId}/resume_chat_message`,
)

/** 获取历史会话分页。 */
const getConversationPage = (page: number, size: number, applicationId: string) =>
get(`${getPrefix(applicationId)}/historical_conversation/${page}/${size}`)

/** 获取会话记录详情。 */
const getConversationRecordDetail = (chatId: string, chatRecordId: string, applicationId: string) =>
get(`${getPrefix(applicationId)}/chat/${chatId}/chat_record/${chatRecordId}`)

/** 获取会话记录分页。 */
const getConversationRecordPage = (chatId: string, page: number, size: number, applicationId: string) =>
get(`${getPrefix(applicationId)}/historical_conversation_record/${chatId}/${page}/${size}`)

/** 删除会话。 */
const deleteConversation = (chatId: string, applicationId: string) =>
del(`${getPrefix(applicationId)}/historical_conversation/${chatId}`)

/** 修改会话信息。 */
const putConversation = (chatId: string, data: unknown, applicationId: string) =>
put(`${getPrefix(applicationId)}/historical_conversation/${chatId}`, data)

/** 使用指定智能体将语音转换为文字。 */
const postSpeechToText = (applicationId: string, data: unknown) =>
post(`${getPrefix(applicationId)}/speech_to_text`, data)

export default {
getConversationOpen,
postConversationMessage,
postCancelConversationMessage,
postResumeConversationMessage,
getConversationPage,
getConversationRecordDetail,
getConversationRecordPage,
deleteConversation,
putConversation,
postSpeechToText,
}
5 changes: 4 additions & 1 deletion ui/src/conversation-panel/view/debug/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import ConversationApi from '@/api/admin/workspace/conversation'
import WorkspaceConversationApi from '@/api/admin/workspace/conversation'
import SystemResourceConversationApi from '@/api/admin/system/resource-management/application/conversation'
import { isSystemResource } from '@/utils/resource-context'
import { useStore } from '@/stores'
import FileApi from '@/api/admin/file'
import { FILE_SOURCE_TYPE } from '@/api/enums'
Expand All @@ -14,6 +16,7 @@ import type { ConversationBundle } from '../types'
/** debug 模式:装配各组件 store。adapter 走 admin(带 applicationId)。 */
export function createDebugConversation(): ConversationBundle {
const route = useRoute()
const ConversationApi = isSystemResource() ? SystemResourceConversationApi : WorkspaceConversationApi
const appId = computed(
() => (route.params.id as string) || (route.params.applicationId as string) || '',
)
Expand Down
Loading