Skip to content

Commit

Permalink
adds build
Browse files Browse the repository at this point in the history
  • Loading branch information
micheleriva committed Sep 26, 2024
1 parent e3e910a commit 36063f1
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/plugin-embeddings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ npm i @orama/plugin-embeddings
- `@tensorflow/tfjs-node`
- `@tensorflow/tfjs-backend-webgl`
- `@tensorflow/tfjs-backend-cpu`
- `@tensorflow/tfjs-node-gpu`
- `@tensorflow/tfjs-backend-wasm`

For example, if you're running Orama on the browser, we highly recommend using `@tensorflow/tfjs-backend-webgl`:
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-embeddings/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
"access": "public"
},
"devDependencies": {
"@orama/orama": "workspace:*",
"@types/node": "^20.9.0",
"tsup": "^7.2.0",
"typescript": "^5.0.0"
},
"dependencies": {
"@orama/orama": "workspace:*",
"@tensorflow-models/universal-sentence-encoder": "^1.3.3",
"@tensorflow/tfjs": "^4.21.0",
"@tensorflow/tfjs-backend-cpu": "^4.21.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-embeddings/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AnyOrama, SearchParams, TypedDocument, OramaPluginAsync, PartialSchemaDeep } from '@orama/orama'
import use from '@tensorflow-models/universal-sentence-encoder'
import { load as loadModel } from '@tensorflow-models/universal-sentence-encoder'

export type PluginEmbeddingsParams = {
embeddings: {
Expand Down Expand Up @@ -28,7 +28,7 @@ function getPropertiesValues(schema: object, properties: string[]) {
export const embeddingsType = 'vector[512]'

export async function pluginEmbeddings(pluginParams: PluginEmbeddingsParams): OramaPluginAsync {
const model = await use.load()
const model = await loadModel()

return {
name: 'orama-plugin-embeddings',
Expand Down
20 changes: 20 additions & 0 deletions packages/plugin-embeddings/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"allowJs": true,
"target": "ES5",
"module": "NodeNext",
"outDir": "dist",
"jsx": "react",
"noImplicitAny": false,
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"esModuleInterop": true,
"declaration": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"sourceMap": true,
"moduleResolution": "nodenext"
},
"include": ["src/*.ts", "src/**/*.ts", "src/*.tsx", "src/**/*.tsx"]
}
17 changes: 17 additions & 0 deletions packages/plugin-embeddings/tsup.lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from 'tsup'

const entry = new URL('src/index.ts', import.meta.url).pathname
const outDir = new URL('dist', import.meta.url).pathname

export default defineConfig({
entry: [entry],
splitting: false,
sourcemap: true,
minify: true,
format: ['cjs', 'esm', 'iife'],
globalName: 'pluginEmbeddings',
dts: true,
clean: true,
bundle: true,
outDir
})
36 changes: 18 additions & 18 deletions pnpm-lock.yaml

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

4 changes: 4 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"dependsOn": ["@orama/orama#build"],
"outputs": ["dist/**"]
},
"@orama/plugin-embeddings#build": {
"dependsOn": ["@orama/orama#build"],
"outputs": ["dist/**"]
},
"@orama/tokenizers#build": {
"dependsOn": ["@orama/orama#build"]
},
Expand Down

0 comments on commit 36063f1

Please sign in to comment.