Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sqs committed Feb 18, 2024
1 parent 98eaac8 commit 19c905b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion provider/docs/bin/create-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (args.length !== 0) {
usage()
}

const archive: CorpusArchive = await readJSONFromStdin()
const archive = (await readJSONFromStdin()) as CorpusArchive
console.error(
`# Using archive: ${archive.docs.length} docs, content ID ${archive.contentID}, description ${JSON.stringify(
archive.description
Expand All @@ -44,6 +44,7 @@ function readJSONFromStdin(): Promise<any> {
})
process.stdin.once('end', () => {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const json = JSON.parse(data.join(''))
resolve(json)
} catch (error) {
Expand Down
6 changes: 3 additions & 3 deletions provider/docs/src/search/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (isWebWindowRuntime) {
//
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
env.backends.onnx.wasm.wasmPaths = import.meta.resolve('../../node_modules/@xenova/transformers/dist/')
} else {
} else if (typeof __dirname !== 'undefined') {
// TODO(sqs): seems to be triggered when running in vscode
env.backends.onnx.wasm.wasmPaths = __dirname + '/../node_modules/@xenova/transformers/dist/'
env.backends.onnx.wasm.numThreads = 1
Expand Down Expand Up @@ -87,10 +87,10 @@ export const embedText = useWebWorker ? embedTextOnWorker : embedTextInThisScope
export async function embedTextInThisScope(text: string, logger?: Logger): Promise<Float32Array> {
try {
const t0 = performance.now()
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment

const out = await (await pipe)(text, { pooling: 'mean', normalize: true })
logger?.(`embedText (${text.length} chars) took ${Math.round(performance.now() - t0)}ms`)
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access

return out.data as Float32Array // TODO(sqs): cast
} catch (error) {
console.log(error)
Expand Down

0 comments on commit 19c905b

Please sign in to comment.