Skip to content

Commit bbe52ae

Browse files
committed
Fixed referencing between nodes of the same file
1 parent c979f49 commit bbe52ae

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

rocket-chatter-ingestion-server/src/core/llm.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const openai = new OpenAI({ apiKey: OPENAI_KEY })
55

66
export namespace LLM {
77
export async function generateEmbeddings(data: string): Promise<number[]> {
8+
return [1, 2, 3]
89
try {
910
const content = await openai.embeddings.create({
1011
input: data,

rocket-chatter-ingestion-server/src/process/prepare/processor/file.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,21 @@ export class FileProcessor implements IFileProcessor {
8888
}
8989

9090
// Replace import names with absolute paths
91+
const nodesInFile: Record<string, string> = {} // { name: id }
92+
for (const node of treeNodes) {
93+
node.sourceFileRelativePath = sourceFile.getFullPath()
94+
nodesInFile[node.name] = node.getID()
95+
}
96+
9197
for (const treeNode of treeNodes) {
9298
treeNode.sourceFileRelativePath = sourceFile.getFullPath()
9399
treeNode.uses = treeNode.uses
94100
.filter((x) => x.name)
95101
.map((x) => {
96-
if (parsedImports.has(x.name)) {
102+
if (parsedImports.has(x.name))
97103
x.name = `${parsedImports.get(x.name)!}.ts:${x.name}`
104+
if (nodesInFile[x.name]) {
105+
x.name = nodesInFile[x.name]
98106
}
99107
return x
100108
})

rocket-chatter-ingestion-server/src/use.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { Codebase } from "./process/prepare/codebase"
33
import { FileProcessor } from "./process/prepare/processor/file"
44

55
async function main() {
6-
const codebase = new Codebase("./project", new FileProcessor(), 1)
6+
const codebase = new Codebase("./project2", new FileProcessor(), 1)
77
await codebase.process()
88
await codebase.embed()
99

10-
insertDataIntoDB(codebase.embeddingsDirPath, 1)
10+
// insertDataIntoDB(codebase.embeddingsDirPath, 1)
1111
}
1212

1313
main()

0 commit comments

Comments
 (0)