diff --git a/src/actions/lookup.js b/src/actions/lookup.js index 5ad60861..15336049 100644 --- a/src/actions/lookup.js +++ b/src/actions/lookup.js @@ -26,7 +26,6 @@ * */ export async function lookup(env, params={}) { - // TODO console.log("lookup", params); const { hypotheticals = [], hypothetical_1, hypothetical_2, hypothetical_3, ...other_params } = params; if(hypothetical_1) hypotheticals.push(hypothetical_1); @@ -35,46 +34,6 @@ export async function lookup(env, params={}) { if(!hypotheticals) return {error: "hypotheticals is required"}; const collection = env.smart_blocks?.smart_embed ? env.smart_blocks : env.smart_sources; return await collection.lookup({...(other_params || {}), hypotheticals}); - // BELOW LOGIC MOVED TO SmartEntities.lookup() - console.log(collection); - if(!collection || !collection.smart_embed) return {error: "Embedding search is not enabled."}; - const embeddings = await collection.smart_embed.embed_batch(hypotheticals.map(h => ({embed_input: h}))); - console.log(embeddings); - console.log({scope: env.chats?.current?.scope}); - const filter = { - ...(env.chats?.current?.scope || {}), - ...(params.filter || {}), - }; - console.log({filter}); - const results = embeddings.flatMap((embedding, i) => { - return collection.nearest(embedding.vec, filter); - }); - // console.log(results); - // sort by sim sim desc - results.sort((a, b) => { - if(a.sim === b.sim) return 0; - return (a.sim > b.sim) ? -1 : 1; - }); - // get top K results - const k = params.k || env.config.lookup_k || 10; - let top_k = await Promise.all(results.slice(0, k) - // filter duplicates by r.data.path - .filter((r, i, a) => a.findIndex(t => t.data.path === r.data.path) === i) - .map(async r => { - return { - score: r.sim, - path: r.data.path, - }; - }) - ); - // DO: decided whether to use these functions - // console.log("nearest before std dev slice", top_k.length); - // top_k = get_nearest_until_next_dev_exceeds_std_dev(top_k); // tested - // console.log("nearest after std dev slice", top_k.length); - // top_k = sort_by_len_adjusted_similarity(top_k); // tested - console.log(top_k); - console.log(`Found and returned ${top_k.length} ${collection.collection_name}.`); - return top_k; } // // IN DEVELOPMENT (Collection.retrieve(strategy, opts)) diff --git a/src/sc_smart_view.js b/src/sc_smart_view.js index 64f2de20..2e1d5e13 100644 --- a/src/sc_smart_view.js +++ b/src/sc_smart_view.js @@ -223,8 +223,8 @@ export class ScSmartView extends SmartObsidianView { if (!entity) return false; if (entity.is_canvas) return true; if (entity.is_excalidraw) return true; - if (entity.note?.is_canvas) return true; - if (entity.note?.is_excalidraw) return true; + if (entity.source?.is_canvas) return true; + if (entity.source?.is_excalidraw) return true; return false; } }