From 15c01f08c0774f6afe4a67012afbc027c11b2dd1 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Wed, 6 Nov 2024 18:45:36 +0530 Subject: [PATCH 1/3] feat: add title search. --- videodb/_constants.py | 2 ++ videodb/collection.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/videodb/_constants.py b/videodb/_constants.py index 0f469c6..b5eab1c 100644 --- a/videodb/_constants.py +++ b/videodb/_constants.py @@ -15,6 +15,7 @@ class SearchType: semantic = "semantic" keyword = "keyword" scene = "scene" + llm = "llm" class IndexType: @@ -68,6 +69,7 @@ class ApiPath: describe = "describe" storage = "storage" download = "download" + title = "title" class Status: diff --git a/videodb/collection.py b/videodb/collection.py index b610009..4bb4211 100644 --- a/videodb/collection.py +++ b/videodb/collection.py @@ -106,6 +106,18 @@ def search( score_threshold: Optional[float] = None, dynamic_score_percentage: Optional[float] = None, ) -> SearchResult: + if search_type == SearchType.llm: + search_data = self._connection.post( + path=f"{ApiPath.collection}/{self.id}/{ApiPath.search}/{ApiPath.title}", + data={ + "query": query, + "search_type": search_type, + }, + ) + return [ + Video(self._connection, **result.get("video")) for result in search_data + ] + search = SearchFactory(self._connection).get_search(search_type) return search.search_inside_collection( collection_id=self.id, From c4acaf844b050ef3244461d9210b504254bb5a8d Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:10:56 +0530 Subject: [PATCH 2/3] refactor: add search_title method --- videodb/collection.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/videodb/collection.py b/videodb/collection.py index 4bb4211..b5eeece 100644 --- a/videodb/collection.py +++ b/videodb/collection.py @@ -106,18 +106,6 @@ def search( score_threshold: Optional[float] = None, dynamic_score_percentage: Optional[float] = None, ) -> SearchResult: - if search_type == SearchType.llm: - search_data = self._connection.post( - path=f"{ApiPath.collection}/{self.id}/{ApiPath.search}/{ApiPath.title}", - data={ - "query": query, - "search_type": search_type, - }, - ) - return [ - Video(self._connection, **result.get("video")) for result in search_data - ] - search = SearchFactory(self._connection).get_search(search_type) return search.search_inside_collection( collection_id=self.id, @@ -129,6 +117,18 @@ def search( dynamic_score_percentage=dynamic_score_percentage, ) + def search_title(self, query) -> List[Video]: + search_data = self._connection.post( + path=f"{ApiPath.collection}/{self.id}/{ApiPath.search}/{ApiPath.title}", + data={ + "query": query, + "search_type": SearchType.llm, + }, + ) + return [ + Video(self._connection, **result.get("video")) for result in search_data + ] + def upload( self, file_path: str = None, From 668988a6038ef1772252f01c62b3947d0e1b4219 Mon Sep 17 00:00:00 2001 From: Ankit raj <113342181+ankit-v2-3@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:23:05 +0530 Subject: [PATCH 3/3] build: update version --- videodb/__about__.py | 2 +- videodb/collection.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/videodb/__about__.py b/videodb/__about__.py index f7bd32b..4189509 100644 --- a/videodb/__about__.py +++ b/videodb/__about__.py @@ -1,7 +1,7 @@ """ About information for videodb sdk""" -__version__ = "0.2.5" +__version__ = "0.2.6" __title__ = "videodb" __author__ = "videodb" __email__ = "contact@videodb.io" diff --git a/videodb/collection.py b/videodb/collection.py index b5eeece..db45f24 100644 --- a/videodb/collection.py +++ b/videodb/collection.py @@ -126,7 +126,8 @@ def search_title(self, query) -> List[Video]: }, ) return [ - Video(self._connection, **result.get("video")) for result in search_data + {"video": Video(self._connection, **result.get("video"))} + for result in search_data ] def upload(