From bd74939a55136773a3d966c24492d05ad9e80d35 Mon Sep 17 00:00:00 2001
From: BlipRanger <1860540+BlipRanger@users.noreply.github.com>
Date: Sun, 25 Jun 2023 01:01:47 -0400
Subject: [PATCH] Add templating for custom injection
---
.../extensions/infinity-context/index.js | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/public/scripts/extensions/infinity-context/index.js b/public/scripts/extensions/infinity-context/index.js
index 02aa74e84..9f326c4df 100644
--- a/public/scripts/extensions/infinity-context/index.js
+++ b/public/scripts/extensions/infinity-context/index.js
@@ -1,4 +1,4 @@
-import { saveSettingsDebounced, getCurrentChatId, system_message_types, eventSource, event_types, getRequestHeaders, CHARACTERS_PER_TOKEN_RATIO } from "../../../script.js";
+import { saveSettingsDebounced, getCurrentChatId, system_message_types, eventSource, event_types, getRequestHeaders, CHARACTERS_PER_TOKEN_RATIO, substituteParams, } from "../../../script.js";
import { humanizedDateTime } from "../../RossAscends-mods.js";
import { getApiUrl, extension_settings, getContext, doExtrasFetch } from "../../extensions.js";
import { getFileText, onlyUnique, splitRecursive, IndexedDBStore } from "../../utils.js";
@@ -25,6 +25,7 @@ const defaultSettings = {
chroma_depth_min: -1,
chroma_depth_max: 500,
chroma_depth_step: 1,
+ chroma_default_msg: "In a past conversation: {{memories}}",
split_length: 384,
split_length_min: 64,
@@ -529,7 +530,7 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
const currentChatId = getCurrentChatId();
const selectedStrategy = extension_settings.chromadb.strategy;
const recallStrategy = extension_settings.chromadb.recall_strategy;
- const recallMsg = extension_settings.chromadb.recall_msg;
+ let recallMsg = extension_settings.chromadb.recall_msg || defaultSettings.chroma_default_msg;
const chromaDepth = extension_settings.chromadb.chroma_depth;
const chromaSortStrategy = extension_settings.chromadb.sort_strategy;
if (currentChatId) {
@@ -588,12 +589,16 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
}
if (selectedStrategy === 'custom') {
const context = getContext();
- const charname = context.name2;
+ recallMsg = substituteParams(recallMsg, context.name1, context.name2);
+ console.log(recallMsg)
+ let recallStart = recallMsg.split('{{memories}}')[0]
+ let recallEnd = recallMsg.split('{{memories}}')[1]
+
newChat.push(
{
is_name: false,
is_user: false,
- mes: recallMsg + " [",
+ mes: recallStart,
name: "system",
send_date: 0,
}
@@ -603,7 +608,7 @@ window.chromadb_interceptGeneration = async (chat, maxContext) => {
{
is_name: false,
is_user: false,
- mes: `]\n`,
+ mes: recallEnd + `\n`,
name: "system",
send_date: 0,
}
@@ -682,7 +687,7 @@ jQuery(async () => {
-
+
Memory Recall Strategy