Skip to content

Commit 99fcdfd

Browse files
committed
chore: allow createEmbeddings to take an optional path
1 parent afe1f42 commit 99fcdfd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/embeddings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,18 @@ export async function searchEmbeddings(query, chunks) {
116116
}
117117

118118
// Only to be used in scripts, not in production
119-
export async function createEmbeddings(id, chunks) {
119+
export async function createEmbeddings(id, chunks, dir = path.join(__dirname, '..', 'embeddings')) {
120120
const embeddings = []
121121

122122
for (let i = 0; i < chunks.length; i++) {
123123
const embedding = await getEmbeddings(chunks[i])
124124
embeddings.push(embedding)
125125
}
126126

127-
await saveEmbeddings(id, chunks, embeddings)
127+
await saveEmbeddings(id, chunks, embeddings, dir)
128128
}
129129

130-
async function saveEmbeddings(id, chunks, embeddings, dir = path.join(__dirname, '..', 'embeddings')) {
130+
async function saveEmbeddings(id, chunks, embeddings, dir) {
131131
if (!chunks.length) throw new Error('No chunks to save')
132132
if (!embeddings || !embeddings.length) throw new Error('No embeddings to save')
133133
if (chunks.length !== embeddings.length) throw new Error('Chunks and embeddings length mismatch')

0 commit comments

Comments
 (0)