Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sqs committed Dec 25, 2023
1 parent eff9aaa commit 0b34059
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion provider/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dependencies": {
"@opencodegraph/provider": "workspace:*",
"@xenova/transformers": "^2.12.1",
"env-paths": "^3.0.0"
"env-paths": "^3.0.0",
"onnxruntime-web": "*"
}
}
12 changes: 11 additions & 1 deletion provider/docs/src/corpus/search/embeddings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { cos_sim, pipeline } from '@xenova/transformers'
import { cos_sim, env, pipeline } from '@xenova/transformers'
import * as onnxWeb from 'onnxruntime-web'
import { memo, noopCache, type CorpusCache } from '../cache/cache'
import { type CorpusSearchResult, type StoredCorpus } from '../corpus'

// Force use of wasm backend for parity between Node.js and web.
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
env.onnx = onnxWeb.env
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
;(env as any).onnx.wasm.numThreads = 1

export async function embeddingsSearch(
storage: StoredCorpus,
query: string,
Expand Down

0 comments on commit 0b34059

Please sign in to comment.