From ff9d5532da59b701794c60016b1e57cda52beea5 Mon Sep 17 00:00:00 2001 From: Severian Date: Sat, 4 Oct 2025 04:49:28 +0800 Subject: [PATCH] chore: test --- src/app/api/proxy/route.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/api/proxy/route.ts b/src/app/api/proxy/route.ts index de5c248..ae513c2 100644 --- a/src/app/api/proxy/route.ts +++ b/src/app/api/proxy/route.ts @@ -334,9 +334,12 @@ export async function POST(request: NextRequest) { ); } - // Parse potential token from messages[3] - const tokenCandidate: string | undefined = body.messages?.[3]?.content; - const providedConversationId = parseConversationToken(tokenCandidate || undefined); + // Parse potential token from messages[3] (user) or messages[4] (assistant prior reply) + const tokenCandidateUser: string | undefined = body.messages?.[3]?.content; + const tokenCandidateAssistant: string | undefined = body.messages?.[4]?.content; + const providedConversationId = + parseConversationToken(tokenCandidateUser || undefined) || + parseConversationToken(tokenCandidateAssistant || undefined); let existingCard: StoredCard | null = null; let linkedByToken = false; @@ -382,14 +385,11 @@ export async function POST(request: NextRequest) { } const extracted = extractCardData(body.messages); - if (!existingCard) { - existingCard = findExistingCard(extracted.trackingName); - } // Prefer existing card's conversationId; otherwise generate a new random one for creation const conversationId = existingCard ? existingCard.conversationId - : providedConversationId || generateId(); + : generateId(); console.log(`Conversation ID: ${conversationId}`); @@ -487,7 +487,7 @@ export async function POST(request: NextRequest) { }; extractedCards.push(newCard); const tokenNote = ` This is the conversation ID you can use to start off a new chat when capturing alternate greetings, use it instead of the character name: [sucker:conv=${conversationId}]`; - responseMessage = `New character "${extracted.trackingName}" created (v1).${tokenNote}`; + responseMessage = `New character "${extracted.data.name}" created (v1).${tokenNote}`; } cleanupExpiredCards();