Skip to content

Commit 12258f5

Browse files
Fix code formatting for CI
- Apply black formatting to Python files - Fix ruff and black linting issues - CI should now pass all checks
1 parent 2fdc263 commit 12258f5

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
__all__ = ["__version__"]
22
__version__ = "0.0.1"
3-
4-

src/contextforge_memory/main.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff 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-

0 commit comments

Comments
 (0)