Skip to content

Commit fd64139

Browse files
authored
Merge pull request #3264 from esen/fix_pg_memory_query
Fix PG query: Use only 'text' subfield name, field name is not needed here
2 parents a457d61 + 71a9c74 commit fd64139

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

packages/adapter-pglite/src/index.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -828,12 +828,12 @@ export class PGLiteDatabaseAdapter
828828
SELECT
829829
embedding,
830830
COALESCE(
831-
content->$2->>$3,
831+
content->>$2,
832832
''
833833
) as content_text
834834
FROM memories
835-
WHERE type = $4
836-
AND content->$2->>$3 IS NOT NULL
835+
WHERE type = $3
836+
AND content->>$2 IS NOT NULL
837837
)
838838
SELECT
839839
embedding,
@@ -845,17 +845,16 @@ export class PGLiteDatabaseAdapter
845845
WHERE levenshtein(
846846
$1,
847847
content_text
848-
) <= $6 -- Add threshold check
848+
) <= $5 -- Add threshold check
849849
ORDER BY levenshtein_score
850-
LIMIT $5
850+
LIMIT $4
851851
`;
852852

853853
const { rows } = await this.query<{
854854
embedding: number[];
855855
levenshtein_score: number;
856856
}>(sql, [
857857
opts.query_input,
858-
opts.query_field_name,
859858
opts.query_field_sub_name,
860859
opts.query_table_name,
861860
opts.query_match_count,

packages/adapter-postgres/src/index.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1016,12 +1016,12 @@ export class PostgresDatabaseAdapter
10161016
SELECT
10171017
embedding,
10181018
COALESCE(
1019-
content->$2->>$3,
1019+
content->>$2,
10201020
''
10211021
) as content_text
10221022
FROM memories
1023-
WHERE type = $4
1024-
AND content->$2->>$3 IS NOT NULL
1023+
WHERE type = $3
1024+
AND content->>$2 IS NOT NULL
10251025
)
10261026
SELECT
10271027
embedding,
@@ -1033,14 +1033,13 @@ export class PostgresDatabaseAdapter
10331033
WHERE levenshtein(
10341034
$1,
10351035
content_text
1036-
) <= $6 -- Add threshold check
1036+
) <= $5 -- Add threshold check
10371037
ORDER BY levenshtein_score
1038-
LIMIT $5
1038+
LIMIT $4
10391039
`;
10401040

10411041
const { rows } = await this.pool.query(sql, [
10421042
opts.query_input,
1043-
opts.query_field_name,
10441043
opts.query_field_sub_name,
10451044
opts.query_table_name,
10461045
opts.query_match_count,

0 commit comments

Comments
 (0)