chore: initialize qiming workspace repository
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import {
|
||||
MessageInfo,
|
||||
ProcessingInfo,
|
||||
} from "@/types/interfaces/conversationInfo";
|
||||
import { BindConfigWithSub } from "@/types/interfaces/common";
|
||||
import { MessageStatusEnum } from "@/types/enums/common";
|
||||
import AgentDetailData from "./AgentDetailData.uts";
|
||||
|
||||
/**
|
||||
* 工具层:提供通用的工具函数
|
||||
*/
|
||||
export default class AgentDetailUtils {
|
||||
/**
|
||||
* 根据datasList内容动态确定type类型
|
||||
*/
|
||||
static determineTypeFromData(dataList: any[][]): string {
|
||||
if (!dataList || dataList.length === 0) return "text";
|
||||
|
||||
const firstToken = dataList[0]?.[0];
|
||||
if (firstToken) {
|
||||
switch (firstToken.type) {
|
||||
case "code":
|
||||
return "code";
|
||||
case "table":
|
||||
return "table";
|
||||
case "list":
|
||||
return "list";
|
||||
case "heading":
|
||||
return "heading";
|
||||
case "blockquote":
|
||||
return "quote";
|
||||
case "hr":
|
||||
return "divider";
|
||||
case "math":
|
||||
return "math";
|
||||
case "paragraph":
|
||||
return "paragraph";
|
||||
default:
|
||||
return "text";
|
||||
}
|
||||
}
|
||||
return "text";
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成唯一的uniqueId
|
||||
*/
|
||||
static generateUniqueId(): string {
|
||||
const timestamp = Date.now();
|
||||
const random = Math.random().toString(36).substring(2, 15);
|
||||
return `markdown_${timestamp}_${random}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查会话是否正在进行中
|
||||
*/
|
||||
static checkConversationActive(
|
||||
messages: MessageInfo[],
|
||||
data: AgentDetailData,
|
||||
): void {
|
||||
const hasActiveMessage =
|
||||
(messages?.length &&
|
||||
messages.some(
|
||||
(message) =>
|
||||
message.status === MessageStatusEnum.Loading ||
|
||||
message.status === MessageStatusEnum.Incomplete,
|
||||
)) ||
|
||||
false;
|
||||
data.isConversationActive.value = hasActiveMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理处理中的消息列表
|
||||
*/
|
||||
// static handleChatProcessingList(_processingList: ProcessingInfo[], data: AgentDetailData): void {
|
||||
// const processedMap = new Map<string, ProcessingInfo>()
|
||||
|
||||
// _processingList.forEach((item) => {
|
||||
// const key = item.executeId || ''
|
||||
// const existing = processedMap.get(key)
|
||||
|
||||
// if (!existing) {
|
||||
// processedMap.set(key, item)
|
||||
// }
|
||||
// })
|
||||
|
||||
// const newProcessingList: ProcessingInfo[] = []
|
||||
// processedMap.forEach((value) => {
|
||||
// newProcessingList.push(value)
|
||||
// })
|
||||
// data.processingList.value = newProcessingList
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user