You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.
Towards the end of the context modifier example reimplementAuthorsNote.js some code tries to truncate the output so as to not exceed info.memoryLength or info.maxChars, but ends up needlessly truncating the most recent actions instead.
Edit Note: (Fixed an issue with my reasoning. The bug is there, but for a different set of reasons)
// Make sure the new context isn't too long, or it will get truncated by the server.
const combinedLines = lines.join("\n").slice(-(info.maxChars - info.memoryLength))
const finalText = [contextMemory, combinedLines].join("")
return { text: finalText }
So at this point the function has split the incoming text into contextMemory and context where context is the length of memoryLength representing the AI's memory window. lines.join("\n") is context with the author's notes injected (3 lines back from front). It's assumed that the input text was an arbitrary length that could have exceeded maxChars. I believe the above code is trying to truncate the modified output text so that finalText is truncated from the front (ie oldest player actions) to maxChars. (otherwise the server would truncate the back losing the newest actions).
So the mistakes it makes are that it assumes lines.join("\n") is already info.memoryLength, which is false because it is context (which is length memoryLength) with the author's notes injected, pushing it over. Further, truncation is only happening on the context portion of the text when the intent here is to truncate all of text; context portion should be untouched. Last, truncation is weird when maxChars is greater than memoryLength. Like, if memoryLength is 20 and maxChars is 21, that's slice(-1) which results in the very last char of the most recent player actions making it through. Why would we throw away the most recent actions right? We want to truncate the oldest actions.
Below is the fixed code that should replace the above.
// Make sure the final context isn't too long, or it will get truncated by the server.
const finalText = (contextMemory + lines.join("\n")).slice(-info.maxChars);
return { text: finalText }
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Towards the end of the context modifier example reimplementAuthorsNote.js some code tries to truncate the output so as to not exceed info.memoryLength or info.maxChars, but ends up needlessly truncating the most recent actions instead.
Edit Note: (Fixed an issue with my reasoning. The bug is there, but for a different set of reasons)
So at this point the function has split the incoming
text
intocontextMemory
andcontext
wherecontext
is the length ofmemoryLength
representing the AI's memory window.lines.join("\n")
iscontext
with the author's notes injected (3 lines back from front). It's assumed that the inputtext
was an arbitrary length that could have exceededmaxChars
. I believe the above code is trying to truncate the modified output text so thatfinalText
is truncated from the front (ie oldest player actions) tomaxChars
. (otherwise the server would truncate the back losing the newest actions).So the mistakes it makes are that it assumes
lines.join("\n")
is already info.memoryLength, which is false because it iscontext
(which is lengthmemoryLength
) with the author's notes injected, pushing it over. Further, truncation is only happening on thecontext
portion of the text when the intent here is to truncate all oftext
;context
portion should be untouched. Last, truncation is weird whenmaxChars
is greater thanmemoryLength
. Like, ifmemoryLength
is 20 andmaxChars
is 21, that's slice(-1) which results in the very last char of the most recent player actions making it through. Why would we throw away the most recent actions right? We want to truncate the oldest actions.Below is the fixed code that should replace the above.
The text was updated successfully, but these errors were encountered: