feat: complete mindspace conversation packages
This commit is contained in:
@@ -130,6 +130,7 @@ export function usePageEditSubChat({
|
||||
const uploadChatImage = useCallback(async (
|
||||
file: File,
|
||||
onProgress?: (progress: number) => void,
|
||||
options: { messageId?: string | null } = {},
|
||||
): Promise<string> => {
|
||||
if (!file.type.startsWith('image/')) {
|
||||
throw new Error('只支持图片文件');
|
||||
@@ -138,6 +139,8 @@ export function usePageEditSubChat({
|
||||
const asset = await uploadMindSpaceAsset(categoryId, file, {
|
||||
maxImageBytes: CHAT_IMAGE_UPLOAD_MAX_INPUT_BYTES,
|
||||
onProgress,
|
||||
sessionId: sessionRef.current?.id ?? null,
|
||||
messageId: options.messageId ?? null,
|
||||
});
|
||||
return buildAbsoluteAssetImageUrl({
|
||||
id: asset.id,
|
||||
@@ -305,7 +308,7 @@ export function usePageEditSubChat({
|
||||
const submit = useCallback(
|
||||
async (
|
||||
text: string,
|
||||
context: MindSpaceChatContext,
|
||||
context: MindSpaceChatContext & { messageId?: string },
|
||||
imageUrls?: string[],
|
||||
previewImageUrls?: string[],
|
||||
) => {
|
||||
@@ -327,6 +330,7 @@ export function usePageEditSubChat({
|
||||
const userPrefix = buildUserAddressPrefix(user);
|
||||
const agentPrefix = `${userPrefix}${mindspacePrefix}`;
|
||||
const userMessage = buildUserMessage(trimmed, {
|
||||
id: context.messageId,
|
||||
agentText: `${agentPrefix}${trimmed}`,
|
||||
displayText: trimmed,
|
||||
imageUrls: normalizedImageUrls,
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
applyLocalLlmFallback,
|
||||
bootstrapProjectMemory,
|
||||
cancelRequest,
|
||||
claimMindSpaceConversationUploads,
|
||||
confirmTool,
|
||||
createAgentRun,
|
||||
deleteChatSession,
|
||||
@@ -572,6 +573,7 @@ export function useTKMindChat(
|
||||
const uploadChatImage = useCallback(async (
|
||||
file: File,
|
||||
onProgress?: (progress: number) => void,
|
||||
options: { messageId?: string | null } = {},
|
||||
): Promise<string> => {
|
||||
if (!file.type.startsWith('image/')) {
|
||||
throw new Error('只支持图片文件');
|
||||
@@ -581,6 +583,7 @@ export function useTKMindChat(
|
||||
maxImageBytes: CHAT_IMAGE_UPLOAD_MAX_INPUT_BYTES,
|
||||
onProgress,
|
||||
sessionId: sessionRef.current?.id ?? null,
|
||||
messageId: options.messageId ?? null,
|
||||
});
|
||||
return buildAbsoluteAssetImageUrl({
|
||||
id: asset.id,
|
||||
@@ -1122,7 +1125,7 @@ export function useTKMindChat(
|
||||
const submit = useCallback(
|
||||
async (
|
||||
text: string,
|
||||
options?: { mindspaceContext?: MindSpaceChatContext },
|
||||
options?: { mindspaceContext?: MindSpaceChatContext; messageId?: string },
|
||||
imageUrls?: string[],
|
||||
previewImageUrls?: string[],
|
||||
) => {
|
||||
@@ -1146,6 +1149,7 @@ export function useTKMindChat(
|
||||
const skillPrefix = buildAutoChatSkillPrefix(trimmed, grantedSkills ?? []);
|
||||
const agentPrefix = `${userPrefix}${mindspacePrefix}${skillPrefix}`;
|
||||
const userMessage = buildUserMessage(trimmed, {
|
||||
id: options?.messageId,
|
||||
agentText: `${agentPrefix}${trimmed}`,
|
||||
displayText: trimmed,
|
||||
imageUrls: normalizedImageUrls,
|
||||
@@ -1184,6 +1188,9 @@ export function useTKMindChat(
|
||||
if (!activeSessionId) {
|
||||
throw new Error('后台任务已提交,但未返回会话');
|
||||
}
|
||||
if (normalizedImageUrls.length > 0) {
|
||||
void claimMindSpaceConversationUploads(activeSessionId, userMessage.id).catch(() => {});
|
||||
}
|
||||
if (!session?.id || session.id !== activeSessionId) {
|
||||
const nextSession: Session = {
|
||||
id: activeSessionId,
|
||||
|
||||
Reference in New Issue
Block a user