Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sqs committed Dec 26, 2023
1 parent 4fe1b06 commit c18e229
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions provider/docs/bin/docs-query.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFile } from 'fs/promises'
import path from 'path'
import envPaths from 'env-paths'
import { createCorpus } from '../src/corpus'
import { indexCorpus } from '../src/corpus'
import { createFileSystemCorpusCache } from '../src/corpus/cache/fs'
import { type CorpusData } from '../src/corpus/data'
import { extractContentUsingMozillaReadability } from '../src/corpus/doc/contentExtractor'
Expand Down Expand Up @@ -33,12 +33,12 @@ const corpusData = JSON.parse(await readFile(corpusDataFile, 'utf8')) as CorpusD
const cacheDir = envPaths('opencodegraph-provider-docs').cache
const fsCache = createFileSystemCorpusCache(cacheDir)

const corpus = createCorpus(corpusData.docs, {
const corpus = indexCorpus(corpusData, {
cache: fsCache,
contentExtractor: extractContentUsingMozillaReadability,
})
const results = await corpus.search(query)
console.error(`# ${corpus.length} docs in corpus`)
console.error(`# ${corpus.docs.length} docs in corpus`)
console.error(`# Query: ${JSON.stringify(query)}`)
const MAX_RESULTS = 5
console.error(`# ${results.length} results${results.length > MAX_RESULTS ? ` (showing top ${MAX_RESULTS})` : ''}`)
Expand Down

0 comments on commit c18e229

Please sign in to comment.