🐛 fix codebase bug returning no results
This commit is contained in:
parent
90e76bcd4c
commit
3c1853bd98
2 changed files with 11 additions and 11 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import { Chunk, ContextItem, ContextProviderExtras, ILLM } from "..";
|
||||
import { FullTextSearchCodebaseIndex } from "../indexing/FullTextSearch";
|
||||
import { LanceDbIndex } from "../indexing/LanceDbIndex";
|
||||
import { ChunkCodebaseIndex } from "../indexing/chunk/ChunkCodebaseIndex";
|
||||
import { IndexTag } from "../indexing/types";
|
||||
import { llmCanGenerateInParallel } from "../llm/autodetect";
|
||||
import { getBasename } from "../util";
|
||||
|
|
@ -124,25 +123,26 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
}
|
||||
|
||||
const branches = (await Promise.race([
|
||||
workspaceDirs.map((dir) => extras.ide.getBranch(dir)),
|
||||
Promise.all(workspaceDirs.map((dir) => extras.ide.getBranch(dir))),
|
||||
new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(["NONE"]);
|
||||
}, 500);
|
||||
}),
|
||||
])) as string[];
|
||||
const tags: IndexTag[] = workspaceDirs.map((directory, i) => ({
|
||||
directory,
|
||||
branch: branches[i],
|
||||
artifactId: ChunkCodebaseIndex.artifactId,
|
||||
}));
|
||||
const tags: (artifactId: string) => IndexTag[] = (artifactId: string) =>
|
||||
workspaceDirs.map((directory, i) => ({
|
||||
directory,
|
||||
branch: branches[i],
|
||||
artifactId,
|
||||
}));
|
||||
|
||||
let ftsResults: Chunk[] = [];
|
||||
|
||||
try {
|
||||
if (extras.fullInput.trim() !== "") {
|
||||
ftsResults = await ftsIndex.retrieve(
|
||||
tags,
|
||||
tags(ftsIndex.artifactId),
|
||||
extras.fullInput
|
||||
.trim()
|
||||
.split(" ")
|
||||
|
|
@ -161,7 +161,7 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
extras.ide.readFile(path),
|
||||
);
|
||||
let vecResults = await lanceDbIndex.retrieve(
|
||||
tags,
|
||||
tags(lanceDbIndex.artifactId),
|
||||
extras.fullInput,
|
||||
nRetrieve,
|
||||
filterDirectory,
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ class OllamaEmbeddingsProvider extends BaseEmbeddingsProvider {
|
|||
return "ollama::" + this.options.model;
|
||||
}
|
||||
|
||||
embed(chunks: string[]) {
|
||||
async embed(chunks: string[]) {
|
||||
const results: any = [];
|
||||
for (const chunk of chunks) {
|
||||
results.push(embedOne(chunk, this.options));
|
||||
results.push(await embedOne(chunk, this.options));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue