/# Keep this at 60000 if using an LLM, otherwise set to the per-minute rate you can make an API call |/#| /let promptsPerMinute 60000 || /# Builds a list of every visible message in chat |/#| /let visible [] || /let vIndex 0 || /times guard=off {: /add 1 {{lastMessageId}} :}() {: || /messages hidden=off names=off {{timesIndex}} | /if left={{pipe}} rule=neq right="" {: || /var index={{var::vIndex}} visible {{timesIndex}} || /var vIndex {: /add 1 vIndex :}() || :} || :} || /# Determines the best amount to split the chat messages by |/#| /let splitBy || /let divisors [9,10,11,12] || /let omit 999 || /times {: /len {{var::divisors}} :}() {: || /var index={{timesIndex}} key=divisors | /mod {: /len {{var::visible}} :}() {{pipe}} | /if left={{pipe}} rule=lte right=omit {: || /var omit {{pipe}} || /var index={{timesIndex}} key=divisors | /var key=splitBy || :} || :} || /let remainingMessages ((All but the last {{var::omit}} message(s) have been summarized.)) || /# Builds a list of where the splits should take place |/#| /let msgRanges [] || /sub {: /len {{var::visible}} :}() omit | /div {{pipe}} splitBy | /let key=summaryCount || /times guard=off {{var::summaryCount}} {: || /let startIndex {: /mul splitBy {{timesIndex}} :}() || /let endIndex {: /add startIndex splitBy -1 :}() || /var index={{var::startIndex}} key=visible | /pass {{pipe}}-{: /var index={{var::endIndex}} key=visible :}() | /var index={{timesIndex}} key=msgRanges || :} || /let excerptPrompt Summarize the most important facts and events that have happened in the chat given to you. Limit the summary to 100 words or less. Your response should include nothing but the summary. || /let iuPrefix {: /if left={{instructUserPrefix}} rule=neq right="" else={:/pass:} {:/pass {{trim}}{{instructUserPrefix}}{{trim}}{{noop}}{{newline}}:} :}() || /let iuSuffix {: /if left={{instructUserSuffix}} rule=neq right="" else={:/pass:} {:/pass {{newline}}{{noop}}{{trim}}{{instructUserSuffix}}{{trim}}:} :}() || /let iaPrefix {: /if left={{instructAssistantPrefix}} rule=neq right="" else={:/pass:} {:/pass {{trim}}{{instructAssistantPrefix}}{{trim}}{{noop}}{{newline}}:} :}() || /let iaSuffix {: /if left={{instructAssistantSuffix}} rule=neq right="" else={:/pass:} {:/pass {{newline}}{{noop}}{{trim}}{{instructAssistantSuffix}}{{trim}}:} :}() || /echo Number of Summaries: {{var::summaryCount}} | /times {{var::summaryCount}} {: || /var index={{timesIndex}} msgRanges | /messages hidden=off names=on {{pipe}} | /let key=messageBatch || /let currentNumber {: /add 1 {{timesIndex}} :}() || /if left=messageBatch rule=neq right="" {: || /echo Generating Summary #{{var::currentNumber}} || /div 60000 promptsPerMinute | /delay {{pipe}} || /pass {{var::iuPrefix}} | /pass {{pipe}}{{var::excerptPrompt}} | /pass {{pipe}}{{newline}}{{newline}} | /pass {{pipe}}{{var::messageBatch}} | /pass {{pipe}}{{var::iuSuffix}} || /if left={{var::iaPrefix}} rule=neq right="" else={: || /pass {{pipe}} || :} {: || /pass {{pipe}}{{newline}}{{newline}} | /pass {{pipe}}{{var::iaPrefix}} | /pass {{pipe}}Chat Summary:{{newline}}• {{noop}} | /pass {{pipe}}{{var::iaSuffix}} || :} | /genraw lock=on instruct=off | /let key=genOut || /if left={{timesIndex}} rule=neq right=0 else={: || /pass Summary #{{var::currentNumber}}:{{newline}} | /comment {{pipe}}{{var::genOut}} || :} {: || /messages hidden=on names=off role=assistant {{lastMessageId}} | /pass {{pipe}}{{newline}}{{newline}} | /pass {{pipe}}Summary #{{var::currentNumber}}:{{newline}} | /comment {{pipe}}{{var::genOut}} || /# 0.1s delay to prevent glitches |/#| /delay 100 || /cut {: /add -1 {{lastMessageId}} :}() || :} || :} || :} || /echo Generating final summary! || /div 60000 promptsPerMinute | /delay {{pipe}} || /let finalPrompt Summarize the most important events, details, and context from the conversation so far into a cohesive narrative summary. Your summary should: 1. Maintain chronological order and flow like a story summary. 2. Capture all crucial facts, interactions, motivations, and context. 3. Be extremely concise and compact, omitting unnecessary fluff. 4. Focus on extracting the essence and core details rather than verbatim recounting. Construct the summary in a single long paragraph, using clear and simple language. Aim for a length of around 1000 to 1500 words, giving enough space to include important specifics while remaining brilliantly concise. The goal is to produce a faithful, info-dense encapsulation of the story that reads smoothly while preserving critical details. || /messages hidden=on names=off role=assistant {{lastMessageId}} | /let key=subSummaries || /pass {{var::iuPrefix}} | /pass {{pipe}}{{var::finalPrompt}} | /pass {{pipe}}{{newline}}{{newline}} | /pass {{pipe}}{{var::subSummaries}} | /pass {{pipe}}{{var::iuSuffix}} || /if left={{var::iaPrefix}} rule=neq right="" else={: || /pass {{pipe}} || :} {: || /pass {{pipe}}{{newline}}{{newline}} | /pass {{pipe}}{{var::iaPrefix}} | /pass {{pipe}}Full Summary:{{newline}} | /pass {{pipe}}{{var::iaSuffix}} || :} | /genraw lock=on instruct=off | /comment {{pipe}}{{newline}}{{newline}}{{var::remainingMessages}} || /echo Done! ||