hy-memory 2.0.5.dev2__py3-none-any.whl → 2.0.5.dev3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hy_memory/client.py CHANGED
@@ -3469,6 +3469,66 @@ class HyMemoryClient:
3469
3469
  "offset": offset,
3470
3470
  }
3471
3471
 
3472
+ async def _search_explicit_raw_layer(
3473
+ self,
3474
+ query: str,
3475
+ *,
3476
+ user_ids: List[str],
3477
+ agent_ids: List[str],
3478
+ session_ids: List[str],
3479
+ include_sources: List[str],
3480
+ exclude_sources: List[str],
3481
+ limit: int,
3482
+ min_score: float,
3483
+ created_after: Optional[float],
3484
+ request_id: str,
3485
+ t0: float,
3486
+ query_embedding: Optional[List[float]],
3487
+ ) -> Dict[str, Any]:
3488
+ """Implement `search(..., layers=['l1_raw'])` without a second API."""
3489
+ from .models.memory import MemoryLayer, MemoryStatus
3490
+
3491
+ embedding = query_embedding or await self._embed_service.embed(query)
3492
+ fetch = min(max(limit * (10 if session_ids else 2), limit), 10_000)
3493
+ hits = await self._vector_store.search(
3494
+ query_embedding=embedding,
3495
+ user_ids=user_ids,
3496
+ agent_ids=agent_ids,
3497
+ include_sources=include_sources,
3498
+ exclude_sources=exclude_sources,
3499
+ layers=[MemoryLayer.L1_RAW],
3500
+ limit=fetch,
3501
+ score_threshold=min_score,
3502
+ status_filter=[MemoryStatus.ACTIVE],
3503
+ only_latest=False,
3504
+ created_after=created_after,
3505
+ )
3506
+ sessions = set(session_ids)
3507
+ rows: List[Dict[str, Any]] = []
3508
+ for hit in hits:
3509
+ node = hit.get("node")
3510
+ if node is None or node.layer != MemoryLayer.L1_RAW:
3511
+ continue
3512
+ if sessions and node.session_id not in sessions:
3513
+ continue
3514
+ row = self._raw_node_to_public(node)
3515
+ rows.append(
3516
+ {
3517
+ "memory_id": row.pop("raw_id"),
3518
+ **row,
3519
+ "layer": MemoryLayer.L1_RAW.value,
3520
+ "status": MemoryStatus.ACTIVE.value,
3521
+ "score": round(float(hit.get("score", 0.0)), 4),
3522
+ }
3523
+ )
3524
+ if len(rows) >= limit:
3525
+ break
3526
+ return {
3527
+ "request_id": request_id,
3528
+ "memories": {"schema": [], "proactive": [], "normal": rows},
3529
+ "elapsed_ms": round((time.perf_counter() - t0) * 1000, 2),
3530
+ }
3531
+
3472
3532
  @staticmethod
3473
3533
  def _public_search_views(
3474
3534
  result_memories: List[Dict[str, Any]],
@@ -4129,6 +4189,22 @@ class HyMemoryClient:
4129
4189
  effective_search_layers = [MemoryLayer.L1_RAW] if lite_mode else layers
4130
4190
  effective_schema_limit = 0 if lite_mode else schema_limit
4131
4191
  effective_intention_limit = 0 if lite_mode else intention_limit
4192
+ normalized_search_layers = self._normalize_layers(effective_search_layers)
4193
+ if normalized_search_layers == [MemoryLayer.L1_RAW]:
4194
+ return await self._search_explicit_raw_layer(
4195
+ effective_target_query,
4196
+ user_ids=effective_user_ids,
4197
+ agent_ids=effective_agent_ids,
4198
+ session_ids=effective_session_ids,
4199
+ include_sources=effective_include_sources,
4200
+ exclude_sources=effective_exclude_sources,
4201
+ limit=limit,
4202
+ min_score=min_score,
4203
+ created_after=effective_created_after,
4204
+ request_id=request_id,
4205
+ t0=t0,
4206
+ query_embedding=query_embedding,
4207
+ )
4132
4208
 
4133
4209
  read_req = ReadRequest(
4134
4210
  query=effective_target_query,
@@ -4149,7 +4225,7 @@ class HyMemoryClient:
4149
4225
  layers=(
4150
4226
  [
4151
4227
  layer.value
4152
- for layer in self._normalize_layers(effective_search_layers)
4228
+ for layer in normalized_search_layers
4153
4229
  ]
4154
4230
  if effective_search_layers else None
4155
4231
  ),
@@ -4174,7 +4250,7 @@ class HyMemoryClient:
4174
4250
  _wanted_layers = (
4175
4251
  {
4176
4252
  layer.value
4177
- for layer in self._normalize_layers(effective_search_layers)
4253
+ for layer in normalized_search_layers
4178
4254
  }
4179
4255
  if effective_search_layers else None
4180
4256
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hy-memory
3
- Version: 2.0.5.dev2
3
+ Version: 2.0.5.dev3
4
4
  Summary: HY Memory - Industrial-grade dual-system cognitive memory framework
5
5
  Author: alvinfei
6
6
  License-Expression: Apache-2.0
@@ -1,5 +1,5 @@
1
1
  hy_memory/__init__.py,sha256=idVBktG5xzToAXl6WDsAmZbBKX3_Q5D5iUtkKcdfmm0,4031
2
- hy_memory/client.py,sha256=2posxO_sWtNXPO5w2ixBr2pSXv58JLVdiqEHMK7fTf8,301567
2
+ hy_memory/client.py,sha256=Smkf7Ybx-cJff8QaxXJlMlB2EPHhZuu_Lle-6GX1vfc,304458
3
3
  hy_memory/config.py,sha256=J051sHyMnTysxWajFORNnGhy6SRKq8n6ZVXSS44lhGA,67809
4
4
  hy_memory/inspector.py,sha256=Uj-mrxi_Piluq4DGVHCHzMfA1QSJLEOMBpiotDjqJSs,18380
5
5
  hy_memory/metrics.py,sha256=sGhhV_aDEuws7ks4c-pI_z5o2rayKkJcNC6J1b9sPQY,16648
@@ -128,8 +128,8 @@ hy_memory/utils/time_window.py,sha256=MGAAWLyxHHwLrNthmYDdnH5PA-pQP9ZdcoQUfpzJof
128
128
  hy_memory/utils/token_count.py,sha256=WibfD9KNuERMrcEPNFZTNo0JCpE72XPaUSlD48Wz1mk,2388
129
129
  hy_memory/utils/trace_file_writer.py,sha256=bS_Kbzzy49eLr5G7HwBKLZqU9j3P6vGjtBWUWa8MIiY,217
130
130
  hy_memory/utils/tracer.py,sha256=dVAwue7zwMax7KQFOfXpD-4pdfrVfiFFxbLhTrqu5XU,12595
131
- hy_memory-2.0.5.dev2.dist-info/licenses/LICENSE,sha256=ywv3qL-z2K0y7z9CI4IMqXf6eLeIKEWewwrzNfsrYN0,9650
132
- hy_memory-2.0.5.dev2.dist-info/METADATA,sha256=W0pOsgjOKa9BsoJ2qbi55MkS__CvV-QReHwqKyKIC0k,18340
133
- hy_memory-2.0.5.dev2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
134
- hy_memory-2.0.5.dev2.dist-info/top_level.txt,sha256=YipheDT9yI2XTaR3lQcsXb3P9MOkd3uN2JHGtlUbnFU,10
135
- hy_memory-2.0.5.dev2.dist-info/RECORD,,
131
+ hy_memory-2.0.5.dev3.dist-info/licenses/LICENSE,sha256=ywv3qL-z2K0y7z9CI4IMqXf6eLeIKEWewwrzNfsrYN0,9650
132
+ hy_memory-2.0.5.dev3.dist-info/METADATA,sha256=MQgEHncVKTokCWQj0cl8JU1yBxDLt6hUoZjDGEmBWhs,18340
133
+ hy_memory-2.0.5.dev3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
134
+ hy_memory-2.0.5.dev3.dist-info/top_level.txt,sha256=YipheDT9yI2XTaR3lQcsXb3P9MOkd3uN2JHGtlUbnFU,10
135
+ hy_memory-2.0.5.dev3.dist-info/RECORD,,