File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 11__all__ = ["__version__" ]
22__version__ = "0.0.1"
3-
4-
Original file line number Diff line number Diff line change @@ -94,14 +94,21 @@ def score(a: List[float], b: List[float]) -> float:
9494 with bucket .open ("r" , encoding = "utf-8" ) as f :
9595 for line in f :
9696 data = orjson .loads (line )
97- if data .get ("namespace" ) != req .namespace or data .get ("project_id" ) != req .project_id :
97+ if (
98+ data .get ("namespace" ) != req .namespace
99+ or data .get ("project_id" ) != req .project_id
100+ ):
98101 continue
99102 item_vec = _embed_text (data .get ("text" , "" ))
100103 data ["_score" ] = score (query_vec , item_vec )
101- results .append (MemoryItem (** {k : v for k , v in data .items () if k != "_score" }))
104+ results .append (
105+ MemoryItem (** {k : v for k , v in data .items () if k != "_score" })
106+ )
102107
103108 # Sort by score descending based on cached scores; recompute on the fly for simplicity
104- results .sort (key = lambda it : - sum ((x - y ) ** 2 for x , y in zip (_embed_text (req .query ), _embed_text (it .text ))))
109+ results .sort (
110+ key = lambda it : - sum (
111+ (x - y ) ** 2 for x , y in zip (_embed_text (req .query ), _embed_text (it .text ))
112+ )
113+ )
105114 return SearchResponse (results = results [: max (1 , req .top_k )])
106-
107-
You can’t perform that action at this time.
0 commit comments