Skip to content

Commit

Permalink
search seems to work again ...
Browse files Browse the repository at this point in the history
  • Loading branch information
yeus committed Nov 5, 2024
1 parent fef0f65 commit 3203d33
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/components/tyMarkdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function addCopyButtons(md: MarkdownIt) {
});
md.renderer.rules.fence = (tokens, idx, options, env, self) => {
console.log('render code fence blocks...');
// console.log('render code fence blocks...');
// Original rendered HTML of the code block
const originalRenderedHtml = defaultFenceRenderer(
tokens,
Expand Down
30 changes: 15 additions & 15 deletions src/modules/taskyon/taskManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ function useTaskVectors(
const { getVectorIndex, resetVectorStore } = useVectorStore('taskyondbv');

async function syncVectorIndexWithTasks(
resetVectorIndex = false,
progressCallback: (done: number, total: number) => void,
) {
console.log('sync vector index');
Expand All @@ -337,16 +336,6 @@ function useTaskVectors(
return;
}

if (resetVectorIndex) {
console.log('delete vector store');
await resetVectorStore();
console.log('delete vector mappings');
await taskyonDB.vectormappings.remove();
await taskyonDB.addCollections({
vectormappings: collections.vectormappings,
});
}

let counter = 0;
//taskyonDB.vectormappings.exportJSON()
for (const task of tasks.values()) {
Expand All @@ -363,6 +352,16 @@ function useTaskVectors(
console.log('Sync complete.');
}

const resetTaskVectors = async () => {
console.log('delete vector store');
await resetVectorStore();
console.log('delete vector mappings');
await taskyonDB?.vectormappings.remove();
await taskyonDB?.addCollections({
vectormappings: collections.vectormappings,
});
};

const vecMappingFromTask = (taskId: string) =>
taskyonDB?.vectormappings
.findOne({
Expand Down Expand Up @@ -513,7 +512,7 @@ function useTaskVectors(
deleteTaskFromVectorStore,
addtoVectorDB,
filteredVectorSearch,
resetVectorStore,
resetTaskVectors,
searchSimilarTasks,
};
}
Expand Down Expand Up @@ -554,8 +553,8 @@ export function useTyTaskManager(
deleteTaskFromVectorStore,
addtoVectorDB,
filteredVectorSearch,
resetVectorStore,
searchSimilarTasks
resetTaskVectors,
searchSimilarTasks,
} = useTaskVectors(tasks, vectorizerModel, taskyonDB);

async function countVecs() {
Expand Down Expand Up @@ -687,13 +686,13 @@ export function useTyTaskManager(
async function deleteAllTasks() {
// also delete vectordb!
// TODO: manually re-initiailized taskyondb after remove...
await resetTaskVectors();
if (taskyonDB) {
console.log('delete the entire database!');
await taskyonDB.remove();
}
tasks.clear();
parentToChildrenMap.clear();
await resetVectorStore();
notifySubscribers(undefined, 'deleteAll');
}

Expand Down Expand Up @@ -909,6 +908,7 @@ export function useTyTaskManager(
deleteTaskThread,
countTasks,
syncVectorIndexWithTasks,
resetTaskVectors,
countVecs,
filteredVectorSearch,
findLeafTasks,
Expand Down
33 changes: 25 additions & 8 deletions src/pages/taskyon/TaskManager.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<template>
<q-page class="q-gutter-xs q-pa-xs">
{{ props }}
<q-btn
:percentage="syncProgress"
:icon="matSync"
:icon="mdiRefresh"
@click="onUpdateSearchIndex"
>
update search index {{ syncProgressString }}</q-btn
>
<q-btn :icon="mdiDatabaseRemove" @click="onResetSearchIndex">
reset search index
</q-btn>
<q-table
style="font-size: 0.8em"
wrap-cells
Expand Down Expand Up @@ -86,8 +88,12 @@ import Search from 'components/SearchInput.vue';
import { TaskNode } from 'src/modules/taskyon/types';
//import Task from 'components/taskyon/TaskWidget.vue';
import { useTaskyonStore } from 'src/stores/taskyonState';
import { matSync } from '@quasar/extras/material-icons';
import { mdiApproximatelyEqual, mdiForum } from '@quasar/extras/mdi-v6';
import {
mdiApproximatelyEqual,
mdiDatabaseRemove,
mdiForum,
mdiRefresh,
} from '@quasar/extras/mdi-v6';
import { useRouter } from 'vue-router';
import { onMounted } from 'vue';
import { QTableProps } from 'quasar';
Expand Down Expand Up @@ -143,7 +149,7 @@ updateCounts();
async function onUpdateSearchIndex() {
const taskManager = await state.getTaskManager();
if (taskManager) {
await taskManager.syncVectorIndexWithTasks(false, (done, total) => {
await taskManager.syncVectorIndexWithTasks((done, total) => {
syncProgress.value = done / total;
syncProgressString.value = `${done}/${total}`;
indexCount.value = done;
Expand All @@ -153,6 +159,17 @@ async function onUpdateSearchIndex() {
updateCounts();
}
async function onResetSearchIndex() {
const taskManager = await state.getTaskManager();
if (taskManager) {
await taskManager.resetTaskVectors();
syncProgressString.value = '*done*';
syncProgress.value = 0.0;
indexCount.value = 0;
}
updateCounts();
}
const createMangoQuery = (labelString: string) => {
const labels = labelString.split('\n');
return {
Expand Down Expand Up @@ -208,10 +225,10 @@ async function onSearchChange(params: searchParams) {
searchResults.value = [];
} else {
// Update the URL with the search parameter
const newQuery = { ...props.query, ...params };
const newQuery = { ...defaultParams, ...props.query, ...params };
router.push({ query: newQuery }); // Perform your search here
console.log(`Searching for ${params}`);
//await searchTasks(q, k, l);
console.log('Searching for: ', params);
await searchTasks(newQuery);
console.log('finished search!');
console.log(searchResults.value);
}
Expand Down

0 comments on commit 3203d33

Please sign in to comment.