remove; buildFieldForSearch
This commit is contained in:
@@ -10,7 +10,6 @@ import { Tr, langCodeContext, LANG_OPTIONS } from "@/translate";
|
|||||||
import { ChatStore } from "@/types/chatstore";
|
import { ChatStore } from "@/types/chatstore";
|
||||||
import { newChatStore } from "@/types/newChatstore";
|
import { newChatStore } from "@/types/newChatstore";
|
||||||
import { STORAGE_NAME, STORAGE_NAME_SELECTED } from "@/const";
|
import { STORAGE_NAME, STORAGE_NAME_SELECTED } from "@/const";
|
||||||
import { BuildFiledForSearch } from "@/utils/buildForSearch";
|
|
||||||
import { upgrade } from "@/indexedDB/upgrade";
|
import { upgrade } from "@/indexedDB/upgrade";
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
@@ -52,9 +51,6 @@ export function App() {
|
|||||||
|
|
||||||
const [chatStore, _setChatStore] = useState(newChatStore({}));
|
const [chatStore, _setChatStore] = useState(newChatStore({}));
|
||||||
const setChatStore = async (chatStore: ChatStore) => {
|
const setChatStore = async (chatStore: ChatStore) => {
|
||||||
// building field for search
|
|
||||||
chatStore.contents_for_index = BuildFiledForSearch(chatStore);
|
|
||||||
|
|
||||||
console.log("recalculate postBeginIndex");
|
console.log("recalculate postBeginIndex");
|
||||||
const max = chatStore.maxTokens - chatStore.tokenMargin;
|
const max = chatStore.maxTokens - chatStore.tokenMargin;
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
import { ChatStore } from "@/types/chatstore";
|
|
||||||
|
|
||||||
export function BuildFiledForSearch(chatStore: ChatStore): string[] {
|
|
||||||
const contents_for_index: string[] = [];
|
|
||||||
|
|
||||||
if (chatStore.systemMessageContent.trim()) {
|
|
||||||
contents_for_index.push(chatStore.systemMessageContent.trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const msg of chatStore.history) {
|
|
||||||
if (typeof msg.content === "string") {
|
|
||||||
contents_for_index.push(msg.content);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const chunk of msg.content) {
|
|
||||||
if (chunk.type === "text") {
|
|
||||||
const text = chunk.text;
|
|
||||||
if (text?.trim()) {
|
|
||||||
contents_for_index.push(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return contents_for_index;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user