mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
First working version
This commit is contained in:
@ -57,7 +57,7 @@ function onSplitLengthInput() {
|
|||||||
|
|
||||||
async function addMessages(chat_id, messages) {
|
async function addMessages(chat_id, messages) {
|
||||||
const url = new URL(getApiUrl());
|
const url = new URL(getApiUrl());
|
||||||
url.pathname = '/api/chroma';
|
url.pathname = '/api/chromadb';
|
||||||
|
|
||||||
const messagesDeepCopy = JSON.parse(JSON.stringify(messages));
|
const messagesDeepCopy = JSON.parse(JSON.stringify(messages));
|
||||||
const splittedMessages = [];
|
const splittedMessages = [];
|
||||||
@ -98,7 +98,7 @@ async function addMessages(chat_id, messages) {
|
|||||||
|
|
||||||
async function queryMessages(chat_id, query) {
|
async function queryMessages(chat_id, query) {
|
||||||
const url = new URL(getApiUrl());
|
const url = new URL(getApiUrl());
|
||||||
url.pathname = '/api/chroma/query';
|
url.pathname = '/api/chromadb/query';
|
||||||
|
|
||||||
const queryMessagesResult = await fetch(url, {
|
const queryMessagesResult = await fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -123,7 +123,6 @@ window.chromadb_interceptGeneration = async (chat) => {
|
|||||||
|
|
||||||
if (messagesToStore.length > 0) {
|
if (messagesToStore.length > 0) {
|
||||||
await addMessages(currentChatId, messagesToStore);
|
await addMessages(currentChatId, messagesToStore);
|
||||||
}
|
|
||||||
|
|
||||||
const lastMessage = chat[chat.length - 1];
|
const lastMessage = chat[chat.length - 1];
|
||||||
|
|
||||||
@ -134,9 +133,10 @@ window.chromadb_interceptGeneration = async (chat) => {
|
|||||||
|
|
||||||
const newChat = queriedMessages.map(m => JSON.parse(m.meta));
|
const newChat = queriedMessages.map(m => JSON.parse(m.meta));
|
||||||
|
|
||||||
console.log(newChat);
|
chat.splice(0, messagesToStore.length, ...newChat);
|
||||||
|
|
||||||
chat.splice(0, messagesToStore.length, newChat);
|
console.log('ChromaDB chat after injection', chat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user