Closed dcsan closed 7 months ago
Hi @dcsan, Cloudflare Workers aren't officially supported, but this makes sense for Node.js and Bun as well, so updated in the commit above.
awesome, thanks! so until there is a new release, I assume to use this I should directly install from the repo like:
npm i https://github.com/pgvector/pgvector-node
do you have a release process / script in the repo? I don't see anything there.
oof, now i get this:
✘ [ERROR] service core:user:knowbase-api: Uncaught Error: Dynamic require of "node:util" is not supported
at null.<anonymous> (index.js:13:9)
at null.<anonymous> (index.js:10590:17) in node_modules/pgvector/src/drizzle-orm/index.js
at null.<anonymous> (index.js:19:50) in __require2
at null.<anonymous> (index.js:81123:34)
and the first line import points to this:
in my own code i'm using import
syntax:
import { vector } from "pgvector/drizzle-orm"
Removed that require
since it's unused, but I'm guessing you'll run into the same error in a different file. I don't fully understand the error message, but you could try applying this diff to see if it fixes it (or produces a different error).
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -1,4 +1,4 @@
-const util = require('node:util');
+const { format } = require('node:util');
function fromSql(value) {
return value.substring(1, value.length - 1).split(',').map((v) => parseFloat(v));
@@ -17,7 +17,7 @@ function sqlType(dimensions) {
throw new Error('expected integer');
}
- return util.format('vector(%d)', dimensions);
+ return format('vector(%d)', dimensions);
}
module.exports = {fromSql, toSql, sqlType};
when trying to use this extension with a cloudflare worker I run into this error:
now cloudflare has implemented these node compatability layer
https://developers.cloudflare.com/workers/runtime-apis/nodejs/util/
but it requires any imports, including in
node_module
packages to prefix the import withnode: ..
https://developers.cloudflare.com/workers/runtime-apis/nodejs/
I was wondering if this is something that could be implemented? how would this work - as a special build for running in the cloudflare env?