chore: test

This commit is contained in:
Severian
2025-10-04 04:49:28 +08:00
parent e10fd80914
commit ff9d5532da

View File

@@ -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();