trieve-fern-adapter
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -133,3 +133,3 @@ #!/usr/bin/env node | ||
} | ||
const tracking_id = `${slug !== null && slug !== void 0 ? slug : path.replace('.mdx', '')}-${heading}`.replace(' ', '-'); | ||
const tracking_id = `${slug && slug != path ? slug + '/' : ''}${path.replace('.mdx', '')}-${heading}`.replace(/\s/g, '-'); | ||
const chunk = { | ||
@@ -140,2 +140,3 @@ chunk_html, | ||
tracking_id, | ||
upsert_by_tracking_id: true, | ||
metadata, | ||
@@ -148,3 +149,3 @@ group_tracking_ids: [path], | ||
phrase: semantic_boost_phrase, | ||
distance_factor: 0.3, | ||
distance_factor: 0.5, | ||
}; | ||
@@ -202,3 +203,4 @@ } | ||
}; | ||
const heading = `<h2><span class="openapi-method">${method.toUpperCase()}</span> ${summary}</h2>`; | ||
const heading = `<h2><span class="openapi-method">${method.toUpperCase()}</span> ${summary} /${endpoint}</h2>`; | ||
const cleanHeading = `${method.toUpperCase()} ${summary} ${endpoint}`; | ||
let chunk_html = heading; | ||
@@ -214,10 +216,11 @@ if (description) { | ||
tracking_id: operationId, | ||
upsert_by_tracking_id: true, | ||
group_tracking_ids: [path], | ||
fulltext_boost: { | ||
phrase: heading, | ||
boost_factor: 1.3, | ||
phrase: cleanHeading, | ||
boost_factor: 1.5, | ||
}, | ||
semantic_boost: { | ||
phrase: heading, | ||
distance_factor: 0.3, | ||
phrase: cleanHeading, | ||
distance_factor: 0.5, | ||
}, | ||
@@ -311,3 +314,3 @@ convert_html_to_text: true, | ||
if (groups.groups.length === 0) { | ||
console.info('Dataset cleared'); | ||
console.info('Groups cleared'); | ||
break; | ||
@@ -319,4 +322,18 @@ } | ||
} | ||
console.info('Waiting on delete...'); | ||
console.info('Waiting on groups to clear...'); | ||
} | ||
while (true) { | ||
try { | ||
console.info('Checking for chunks...'); | ||
const scrollResp = await trieve.scroll({}); | ||
if (scrollResp.chunks.length === 0) { | ||
console.info('Chunks cleared'); | ||
break; | ||
} | ||
} | ||
catch (err) { | ||
console.error('Error getting groups', err); | ||
} | ||
console.info('Waiting on chunks to clear...'); | ||
} | ||
} | ||
@@ -338,2 +355,3 @@ catch (_a) { | ||
} | ||
chunkReqPayloads = chunkReqPayloads.filter((v, i, a) => a.findIndex((t) => t.chunk_html === v.chunk_html) === i); | ||
for (let i = 0; i < chunkReqPayloads.length; i += 120) { | ||
@@ -340,0 +358,0 @@ const chunkBatch = chunkReqPayloads.slice(i, i + 120); |
{ | ||
"name": "trieve-fern-adapter", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
18122
371