Start of Readme, More Cleanup

This commit is contained in:
2025-04-20 10:57:06 -04:00
parent 25f8cae8cb
commit 9dcd31dd04
8 changed files with 222 additions and 298 deletions

View File

@@ -6,7 +6,6 @@ import (
"github.com/tmc/langchaingo/callbacks"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/vectorstores"
"github.com/tmc/langchaingo/vectorstores/pgvector"
"strconv"
)
@@ -37,20 +36,11 @@ func NewGetRelevantDocs(db *database.Database, llm *LLM, repoID string, size int
}
func (rd *RelevantDocs) GetRelevantFileChunks(ctx context.Context, query string) ([]*FileChunkID, error) {
conn, err := rd.db.DB(ctx)
if err != nil {
return nil, err
}
defer conn.Release()
vectorStore, err := pgvector.New(ctx,
pgvector.WithConn(conn),
pgvector.WithEmbedder(rd.llm.Embedder()),
pgvector.WithCollectionName("file_chunks"),
)
vectorStore, closeFunc, err := rd.db.GetVectorStore(ctx, rd.llm.Embedder())
if err != nil {
return nil, err
}
defer closeFunc()
retr := vectorstores.ToRetriever(vectorStore, rd.size, vectorstores.WithFilters(map[string]any{"type": "file_chunk", "repo_id": rd.repoID}))
retr.CallbacksHandler = rd.CallbacksHandler