Fix assistant messages not being authored by Miku

This commit is contained in:
James S 2025-01-18 18:44:26 -08:00
parent fb78222a3e
commit db7fb0f001

View File

@ -62,7 +62,7 @@ async function main() {
* USER: * USER:
* Answer the user query. * Answer the user query.
* [ Langchain JSON structured output instructions ] * [ Langchain JSON structured output instructions ]
* { ... "author": "vinso", "content": "message history 1" ... } * { ... "author": "vinso1445", "content": "message history 1" ... }
* { ... "author": "f0oby", "content": "message history 2" ... } * { ... "author": "f0oby", "content": "message history 2" ... }
* { ... "author": "scoliono", "content": "message history 3" ... } * { ... "author": "scoliono", "content": "message history 3" ... }
* *
@ -85,7 +85,7 @@ async function main() {
* a thought across multiple messages. It's up to the inference code to decide what to do with * a thought across multiple messages. It's up to the inference code to decide what to do with
* this. * this.
*/ */
function structurePrompt(msg, cleanContent) { function structurePrompt(msg, cleanContent, isBotMessage = false) {
/** /**
* Handle replies by maintaining a sliding window of message references. * Handle replies by maintaining a sliding window of message references.
* If the replied-to message is too old to be part of this conversation, then leave this * If the replied-to message is too old to be part of this conversation, then leave this
@ -110,8 +110,8 @@ async function main() {
// 'name', 'context', 'reactions' could be undefined, in which case those fields are omitted // 'name', 'context', 'reactions' could be undefined, in which case those fields are omitted
return JSON.stringify({ return JSON.stringify({
timestamp: (new Date(msg.timestamp)).toUTCString(), timestamp: (new Date(msg.timestamp)).toUTCString(),
author: msg.author.name, author: isBotMessage ? 'Hatsune Miku#1740' : msg.author.name,
name: REAL_NAMES[msg.author.name], name: isBotMessage ? 'Hatsune Miku' : REAL_NAMES[msg.author.name],
context: repliedToContent, context: repliedToContent,
content: cleanContent, content: cleanContent,
reactions: reactionString reactions: reactionString
@ -175,7 +175,7 @@ async function main() {
convoRefs[msg.id] = cleanContent; convoRefs[msg.id] = cleanContent;
// write a single discord message to the prompt // write a single discord message to the prompt
discordMsgs.push(structurePrompt(msg, cleanContent)); discordMsgs.push(structurePrompt(msg, cleanContent, botAuthoredMsgSequence));
if (++counter % 1000 === 0) { if (++counter % 1000 === 0) {
console.log(counter + " messages written"); console.log(counter + " messages written");