🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pgml-sdks/rust/pgml/javascript/tests/typescript-tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (!DATABASE_URL) {
}
const LOG_LEVEL = process.env.LOG_LEVEL ? process.env.LOG_LEVEL : "ERROR";

pgml.js_init_logger(DATABASE_URL, LOG_LEVEL);
pgml.js_init_logger(LOG_LEVEL);

const generate_dummy_documents = (count: number) => {
let docs = [];
Expand Down Expand Up @@ -127,9 +127,10 @@ it("pipeline to dict", async () => {
let model = pgml.newModel("text-embedding-ada-002", "openai");
let splitter = pgml.newSplitter();
let pipeline = pgml.newPipeline("test_j_p_ptd_0", model, splitter);
let collection = pgml.newCollection("test_j_c_ptd_1");
let collection = pgml.newCollection("test_j_c_ptd_2");
await collection.add_pipeline(pipeline);
let pipeline_dict = await pipeline.to_dict();
console.log(JSON.stringify(pipeline_dict))
expect(pipeline_dict["name"]).toBe("test_j_p_ptd_0");
await collection.archive();
});
4 changes: 2 additions & 2 deletions pgml-sdks/rust/pgml/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ impl Collection {
FROM
%s p
INNER JOIN pgml.models m ON p.model_id = m.id
INNER JOIN pgml.sdk_splitters s ON p.splitter_id = s.id
INNER JOIN pgml.splitters s ON p.splitter_id = s.id
WHERE
p.active = TRUE
"#,
Expand Down Expand Up @@ -1002,7 +1002,7 @@ impl Collection {
FROM
%s p
INNER JOIN pgml.models m ON p.model_id = m.id
INNER JOIN pgml.sdk_splitters s ON p.splitter_id = s.id
INNER JOIN pgml.splitters s ON p.splitter_id = s.id
WHERE
p.active = TRUE
AND p.name = $1
Expand Down
2 changes: 1 addition & 1 deletion pgml-sdks/rust/pgml/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl Pipeline {
self.model = Some(model);

let splitter: models::Splitter =
sqlx::query_as("SELECT * FROM pgml.sdk_splitters WHERE id = $1")
sqlx::query_as("SELECT * FROM pgml.splitters WHERE id = $1")
.bind(p.splitter_id)
.fetch_one(&pool)
.await?;
Expand Down
10 changes: 5 additions & 5 deletions pgml-sdks/rust/pgml/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS %s (
name text NOT NULL,
created_at timestamp NOT NULL DEFAULT now(),
model_id int8 NOT NULL REFERENCES pgml.models ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
splitter_id int8 NOT NULL REFERENCES pgml.sdk_splitters ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
splitter_id int8 NOT NULL REFERENCES pgml.splitters ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
active BOOLEAN NOT NULL DEFAULT TRUE,
parameters jsonb NOT NULL DEFAULT '{}',
UNIQUE (name)
Expand All @@ -37,7 +37,7 @@ CREATE TABLE IF NOT EXISTS %s (
"#;

pub const CREATE_SPLITTERS_TABLE: &str = r#"
CREATE TABLE IF NOT EXISTS pgml.sdk_splitters (
CREATE TABLE IF NOT EXISTS pgml.splitters (
id serial8 PRIMARY KEY,
created_at timestamp NOT NULL DEFAULT now(),
name text NOT NULL,
Expand All @@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS pgml.sdk_splitters (
pub const CREATE_CHUNKS_TABLE: &str = r#"CREATE TABLE IF NOT EXISTS %s (
id serial8 PRIMARY KEY, created_at timestamp NOT NULL DEFAULT now(),
document_id int8 NOT NULL REFERENCES %s ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
splitter_id int8 NOT NULL REFERENCES pgml.sdk_splitters ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
splitter_id int8 NOT NULL REFERENCES pgml.splitters ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
chunk_index int8 NOT NULL,
chunk text NOT NULL,
UNIQUE (document_id, splitter_id, chunk_index)
Expand Down Expand Up @@ -241,7 +241,7 @@ WITH splitter as (
name,
parameters
FROM
pgml.sdk_splitters
pgml.splitters
WHERE
id = $1
)
Expand Down Expand Up @@ -291,7 +291,7 @@ WITH splitter as (
name,
parameters
FROM
pgml.sdk_splitters
pgml.splitters
WHERE
id = $1
)
Expand Down
4 changes: 2 additions & 2 deletions pgml-sdks/rust/pgml/src/splitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Splitter {
.expect("Cannot verify splitter without project info");

let splitter: Option<models::Splitter> = sqlx::query_as(
"SELECT * FROM pgml.sdk_splitters WHERE project_id = $1 AND name = $2 and parameters = $3",
"SELECT * FROM pgml.splitters WHERE project_id = $1 AND name = $2 and parameters = $3",
)
.bind(project_info.id)
.bind(&self.name)
Expand All @@ -85,7 +85,7 @@ impl Splitter {
s
} else {
sqlx::query_as(
"INSERT INTO pgml.sdk_splitters (project_id, name, parameters) VALUES ($1, $2, $3) RETURNING *",
"INSERT INTO pgml.splitters (project_id, name, parameters) VALUES ($1, $2, $3) RETURNING *",
)
.bind(project_info.id)
.bind(&self.name)
Expand Down