Skip to content

Commit

Permalink
fix issues for cloud js example
Browse files Browse the repository at this point in the history
  • Loading branch information
QianZhu committed Jan 20, 2025
1 parent 3034cf9 commit b002250
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 4 additions & 5 deletions examples/js-transformers/lancedb_cloud/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

'use strict'

import * as lancedb from "@lancedb/lancedb"

async function example() {

const lancedb = require('vectordb')


// Import transformers and the all-MiniLM-L6-v2 model (https://huggingface.co/Xenova/all-MiniLM-L6-v2)
const { pipeline } = await import('@xenova/transformers')
const pipe = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');
Expand Down Expand Up @@ -64,9 +63,9 @@ async function example() {
let query = (await embed_fun.embed(['a sweet fruit to eat']))[0]
const results = await table
.search(query)
.metricType("cosine")
.distanceType("cosine")
.limit(2)
.execute()
.toArray()
console.log(results.map(r => r.text))
}

Expand Down
9 changes: 5 additions & 4 deletions examples/js-transformers/walkthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This example shows how to use the [transformers.js](https://github.com/xenova/tr
### Setting up
First, install the dependencies:
```bash
npm install vectordb
npm install @lancedb/lancedb
npm i @xenova/transformers
```

Expand All @@ -17,7 +17,8 @@ We will also be using the [all-MiniLM-L6-v2](https://huggingface.co/Xenova/all-M
Within our `index.js` file we will import the necessary libraries and define our model and database:

```javascript
const lancedb = require('vectordb')
import * as lancedb from "@lancedb/lancedb"

const { pipeline } = await import('@xenova/transformers')
const pipe = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2');
```
Expand Down Expand Up @@ -75,9 +76,9 @@ Now, we can perform the search using the `search` function. LanceDB automaticall
// Query the table
const results = await table
.search("a sweet fruit to eat")
.metricType("cosine")
.distanceType("cosine")
.limit(2)
.execute()
.toArray()
console.log(results.map(r => r.text))
```
```bash
Expand Down

0 comments on commit b002250

Please sign in to comment.