Skip to content

Commit 9d97e38

Browse files
authored
Adjustments to npm publishing (#791)
1 parent b5a048a commit 9d97e38

File tree

6 files changed

+60
-53
lines changed

6 files changed

+60
-53
lines changed

.github/workflows/javascript-sdk.yml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,38 @@ jobs:
4141
name: node-artifacts
4242
path: pgml-sdks/rust/pgml/javascript/${{ matrix.neon-out-name }}
4343
retention-days: 1
44-
publish-javascript-sdk:
45-
needs: build-javascript-sdk
46-
runs-on: "ubuntu-22.04"
47-
defaults:
48-
run:
49-
working-directory: pgml-sdks/rust/pgml/javascript
50-
steps:
51-
- uses: actions/checkout@v3
52-
- uses: actions-rs/toolchain@v1
53-
with:
54-
toolchain: stable
55-
- name: Validate cargo is working
56-
uses: postgresml/gh-actions-cargo@master
57-
with:
58-
command: version
59-
- name: Create artifact directory
60-
run: mkdir dist
61-
- name: Download artifacts
62-
uses: actions/download-artifact@v3
63-
with:
64-
name: node-artifacts
65-
path: pgml-sdks/rust/pgml/javascript/dist
66-
- uses: actions/setup-node@v3
67-
with:
68-
node-version: '20.x'
69-
registry-url: 'https://registry.npmjs.org'
70-
- name: Generate types declaration
71-
run: |
72-
npm i
73-
npm run build
74-
rm index.node
75-
- run: npm ci
76-
- run: npm publish
77-
env:
78-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
# publish-javascript-sdk:
45+
# needs: build-javascript-sdk
46+
# runs-on: "ubuntu-22.04"
47+
# defaults:
48+
# run:
49+
# working-directory: pgml-sdks/rust/pgml/javascript
50+
# steps:
51+
# - uses: actions/checkout@v3
52+
# - uses: actions-rs/toolchain@v1
53+
# with:
54+
# toolchain: stable
55+
# - name: Validate cargo is working
56+
# uses: postgresml/gh-actions-cargo@master
57+
# with:
58+
# command: version
59+
# - name: Create artifact directory
60+
# run: mkdir dist
61+
# - name: Download artifacts
62+
# uses: actions/download-artifact@v3
63+
# with:
64+
# name: node-artifacts
65+
# path: pgml-sdks/rust/pgml/javascript/dist
66+
# - uses: actions/setup-node@v3
67+
# with:
68+
# node-version: '20.x'
69+
# registry-url: 'https://registry.npmjs.org'
70+
# - name: Generate types declaration
71+
# run: |
72+
# npm i
73+
# npm run build
74+
# rm index.node
75+
# - run: npm ci
76+
# - run: npm publish
77+
# env:
78+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

pgml-sdks/rust/pgml/javascript/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ try {
1010
if (type == "Darwin" && arch == "x64") {
1111
const pgml = require("./dist/x86_64-apple-darwin-index.node")
1212
module.exports = pgml
13+
} else if (type == "Darwin" && arch == "arm64") {
14+
const pgml = require("./dist/aarch64-apple-darwin-index.node")
15+
module.exports = pgml
1316
} else if (type == "Windows" && arch == "x64") {
1417
const pgml = require("./dist/x86_64-pc-windows-gnu-index.node")
1518
module.exports = pgml

pgml-sdks/rust/pgml/javascript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pgml",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Open Source Alternative for Building End-to-End Vector Search Applications without OpenAI & Pinecone",
55
"keywords": ["postgres", "machine learning", "vector databases", "embeddings"],
66
"main": "index.js",

pgml-sdks/rust/pgml/python/tests/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ async def main():
1414
await collection.register_text_splitter("recursive_character", {"chunk_size": 1500, "chunk_overlap": 40})
1515
splitters = await collection.get_text_splitters()
1616
print(splitters)
17-
await collection.generate_chunks(2)
17+
await collection.generate_chunks()
1818
await collection.register_model("embedding", "intfloat/e5-small")
1919
models = await collection.get_models()
2020
print(models)
2121
await collection.generate_embeddings()
22-
results = await collection.vector_search("small", {}, 2);
22+
results = await collection.vector_search("small")
2323
print(results)
2424
await db.archive_collection(collection_name)
2525

pgml-sdks/rust/pgml/src/collection.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,16 +731,17 @@ impl Collection {
731731
}
732732
};
733733

734+
let model_name = self.get_model_name(model_id).await?.expect("Model with id: {} does not exist");
735+
734736
let results: Vec<(f64, String, sqlx::types::Json<HashMap<String, String>>)> =
735737
sqlx::query_as(&query_builder!(
736738
queries::VECTOR_SEARCH,
737-
self.models_table_name,
738739
embeddings_table_name,
739740
embeddings_table_name,
740741
self.chunks_table_name,
741742
self.documents_table_name
742743
))
743-
.bind(model_id)
744+
.bind(model_name)
744745
.bind(query)
745746
.bind(query_params)
746747
.bind(top_k)
@@ -751,6 +752,20 @@ impl Collection {
751752
Ok(results)
752753
}
753754

755+
async fn get_model_name(&self, model_id: i64) -> anyhow::Result<Option<String>> {
756+
let model: Option<models::Model> = sqlx::query_as(&query_builder!(
757+
"SELECT * from %s WHERE id = $1",
758+
self.models_table_name
759+
))
760+
.bind(model_id)
761+
.fetch_optional(self.pool.borrow())
762+
.await?;
763+
match model {
764+
Some(m) => Ok(Some(m.name)),
765+
None => Ok(None),
766+
}
767+
}
768+
754769
fn generate_table_names(name: &str) -> (String, String, String, String, String) {
755770
[
756771
".documents",

pgml-sdks/rust/pgml/src/queries.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,11 @@ WHERE
122122
"#;
123123

124124
pub const VECTOR_SEARCH: &str = r#"
125-
WITH model AS (
126-
SELECT
127-
name
128-
FROM
129-
%s
130-
WHERE
131-
id = $1
132-
),
133-
query_cte AS (
125+
WITH query_cte AS (
134126
SELECT
135127
pgml.embed(
136128
transformer => (
137-
SELECT
138-
name
139-
from
140-
model
129+
$1
141130
),
142131
text => $2,
143132
kwargs => $3

0 commit comments

Comments
 (0)