Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/web/inngest/functions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import prisma from "@super/db";
import { inngest } from "../client";
import { getRepoFileContents } from "@/modules/github/lib/github";
import { indexCodebase } from "@/modules/pinecone/rag";

export const helloWorld = inngest.createFunction(
{ id: "hello-world" },
Expand Down Expand Up @@ -34,7 +35,9 @@ export const indexRepo = inngest.createFunction(
})

await step.run("index-codebase", async()=>{

await indexCodebase(`${owner}/${repo}`, files)
})

return {success:true, indexedFiles: files.length}
}
)
2 changes: 1 addition & 1 deletion apps/web/lib/pinecone/pinecone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export const pinecone = new Pinecone({
})

export const pineconeIndex = pinecone.index({
name: "supercode-vector-embeddings-v1",
name: "supercode-vector-embeddings-v2",
})
15 changes: 15 additions & 0 deletions apps/web/modules/pinecone/rag/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,19 @@ export async function indexCodebase(repoId: string, files: {path:string, content
}

console.log("File indexed")
}

export async function retrieveContext(query: string, repoId: string, topK:number=5){

const embedding = await generateEmbedding(query);

const results = await pineconeIndex.query({
vector: embedding,
filter: {repoId},
topK,
includeMetadata:true
})

return results.matches.map(match=>match.metadata?.content as string).filter(Boolean)

}
2 changes: 1 addition & 1 deletion apps/web/modules/repository/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const connectRepository = async (owner: string, repo: string, githubId: n

try {
await inngest.send({
name: "repository.connected",
name: "repository-connected",
data:{
owner,
repo,
Expand Down