File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,11 +23,6 @@ def __init__(
2323 def _get_namespace (self ):
2424 return (self .user_id , self .entity_type )
2525
26- def _filter (self , metadata : dict ) -> dict :
27- return {
28- "metadata" : metadata ,
29- }
30-
3126 async def _set (
3227 self , key : str , value : Source | Project | Document , ttl : int | None = None
3328 ) -> bool :
@@ -39,6 +34,16 @@ async def _set(
3934 )
4035 logger .info (f"Set { self .entity_type } { key } successfully" )
4136 return True
37+
38+ def _format (self , item : SearchItem ) -> Any :
39+ if self .entity_type == "documents" :
40+ return Document .model_validate (item .value )
41+ elif self .entity_type == "sources" :
42+ return Source .model_validate (item .value )
43+ elif self .entity_type == "projects" :
44+ return Project .model_validate (item .value )
45+ else :
46+ raise ValueError (f"Invalid entity type: { self .entity_type } " )
4247
4348 async def _delete (self , key : str ) -> bool :
4449 await self .store .adelete (self ._get_namespace (), key )
You can’t perform that action at this time.
0 commit comments