From 01a76b3013a6bf31c48c9217b7f4827a25cf9a71 Mon Sep 17 00:00:00 2001 From: choccccy Date: Fri, 14 Jun 2024 15:31:06 -0600 Subject: [PATCH 1/3] even more matching --- pylib/embedding/pgvector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylib/embedding/pgvector.py b/pylib/embedding/pgvector.py index 86563d0..2b0fea2 100644 --- a/pylib/embedding/pgvector.py +++ b/pylib/embedding/pgvector.py @@ -199,7 +199,7 @@ def match_exact(key, val): ''' Filter specifier to only return rows where the given top-level key exists in metadata, and matches the given value ''' - assert key.isalnum() + assert key.strip('-_').isalnum() if isinstance(val, str): cast = '' elif isinstance(val, bool): @@ -220,7 +220,7 @@ def match_oneof(key, options: tuple[str]): ''' options = tuple(options) assert options - assert key.isalnum() + assert key.strip('-_').isalnum() option1 = options[0] if isinstance(option1, str): cast = '' From 1c9c28951dd744948dcda5c0fd455d6fecf8f8fa Mon Sep 17 00:00:00 2001 From: choccccy Date: Fri, 14 Jun 2024 15:42:33 -0600 Subject: [PATCH 2/3] i hate underscores --- pylib/embedding/pgvector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylib/embedding/pgvector.py b/pylib/embedding/pgvector.py index 2b0fea2..6aac0ff 100644 --- a/pylib/embedding/pgvector.py +++ b/pylib/embedding/pgvector.py @@ -199,7 +199,7 @@ def match_exact(key, val): ''' Filter specifier to only return rows where the given top-level key exists in metadata, and matches the given value ''' - assert key.strip('-_').isalnum() + assert key.replace('_', '').replace('-', '').isalnum(), 'key_' if isinstance(val, str): cast = '' elif isinstance(val, bool): @@ -220,7 +220,7 @@ def match_oneof(key, options: tuple[str]): ''' options = tuple(options) assert options - assert key.strip('-_').isalnum() + assert key.replace('_', '').replace('-', '').isalnum(), 'key_' option1 = options[0] if isinstance(option1, str): cast = '' From c72933cf7cc0a16db1e6e93b2ac761e15e68982f Mon Sep 17 00:00:00 2001 From: choccccy Date: Fri, 14 Jun 2024 15:51:46 -0600 Subject: [PATCH 3/3] better assert for match fail --- pylib/embedding/pgvector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylib/embedding/pgvector.py b/pylib/embedding/pgvector.py index 6aac0ff..c71308a 100644 --- a/pylib/embedding/pgvector.py +++ b/pylib/embedding/pgvector.py @@ -199,7 +199,7 @@ def match_exact(key, val): ''' Filter specifier to only return rows where the given top-level key exists in metadata, and matches the given value ''' - assert key.replace('_', '').replace('-', '').isalnum(), 'key_' + assert key.replace('_', '').replace('-', '').isalnum(), 'key contains nonalphanumeric, "-", or "_" characters' if isinstance(val, str): cast = '' elif isinstance(val, bool): @@ -220,7 +220,7 @@ def match_oneof(key, options: tuple[str]): ''' options = tuple(options) assert options - assert key.replace('_', '').replace('-', '').isalnum(), 'key_' + assert key.replace('_', '').replace('-', '').isalnum(), 'key contains nonalphanumeric, "-", or "_" characters' option1 = options[0] if isinstance(option1, str): cast = ''