hindsight-api 0.1.7__py3-none-any.whl → 0.1.8__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.
hindsight_api/api/http.py CHANGED
@@ -506,9 +506,9 @@ class BankListItem(BaseModel):
506
506
  """Bank list item with profile summary."""
507
507
 
508
508
  bank_id: str
509
- name: str
509
+ name: str | None = None
510
510
  disposition: DispositionTraits
511
- background: str
511
+ background: str | None = None
512
512
  created_at: str | None = None
513
513
  updated_at: str | None = None
514
514
 
@@ -1452,18 +1452,22 @@ def _register_routes(app: FastAPI):
1452
1452
  bank_id,
1453
1453
  )
1454
1454
 
1455
+ def parse_metadata(metadata):
1456
+ """Parse result_metadata which may be a string or dict."""
1457
+ if metadata is None:
1458
+ return {}
1459
+ if isinstance(metadata, str):
1460
+ return json.loads(metadata)
1461
+ return metadata
1462
+
1455
1463
  return {
1456
1464
  "bank_id": bank_id,
1457
1465
  "operations": [
1458
1466
  {
1459
1467
  "id": str(row["operation_id"]),
1460
1468
  "task_type": row["operation_type"],
1461
- "items_count": row["result_metadata"].get("items_count", 0)
1462
- if row["result_metadata"]
1463
- else 0,
1464
- "document_id": row["result_metadata"].get("document_id")
1465
- if row["result_metadata"]
1466
- else None,
1469
+ "items_count": parse_metadata(row["result_metadata"]).get("items_count", 0),
1470
+ "document_id": parse_metadata(row["result_metadata"]).get("document_id"),
1467
1471
  "created_at": row["created_at"].isoformat(),
1468
1472
  "status": row["status"],
1469
1473
  "error_message": row["error_message"],
@@ -1499,7 +1503,7 @@ def _register_routes(app: FastAPI):
1499
1503
  async with acquire_with_retry(pool) as conn:
1500
1504
  # Check if operation exists and belongs to this memory bank
1501
1505
  result = await conn.fetchrow(
1502
- "SELECT bank_id FROM async_operations WHERE id = $1 AND bank_id = $2", op_uuid, bank_id
1506
+ "SELECT bank_id FROM async_operations WHERE operation_id = $1 AND bank_id = $2", op_uuid, bank_id
1503
1507
  )
1504
1508
 
1505
1509
  if not result:
@@ -1508,7 +1512,7 @@ def _register_routes(app: FastAPI):
1508
1512
  )
1509
1513
 
1510
1514
  # Delete the operation
1511
- await conn.execute("DELETE FROM async_operations WHERE id = $1", op_uuid)
1515
+ await conn.execute("DELETE FROM async_operations WHERE operation_id = $1", op_uuid)
1512
1516
 
1513
1517
  return {
1514
1518
  "success": True,
@@ -1769,13 +1773,13 @@ def _register_routes(app: FastAPI):
1769
1773
  async with acquire_with_retry(pool) as conn:
1770
1774
  await conn.execute(
1771
1775
  """
1772
- INSERT INTO async_operations (id, bank_id, task_type, items_count)
1776
+ INSERT INTO async_operations (operation_id, bank_id, operation_type, result_metadata)
1773
1777
  VALUES ($1, $2, $3, $4)
1774
1778
  """,
1775
1779
  operation_id,
1776
1780
  bank_id,
1777
1781
  "retain",
1778
- len(contents),
1782
+ json.dumps({"items_count": len(contents)}),
1779
1783
  )
1780
1784
 
1781
1785
  # Submit task to background queue
@@ -311,7 +311,7 @@ class MemoryEngine:
311
311
  pool = await self._get_pool()
312
312
  async with acquire_with_retry(pool) as conn:
313
313
  result = await conn.fetchrow(
314
- "SELECT id FROM async_operations WHERE id = $1", uuid.UUID(operation_id)
314
+ "SELECT operation_id FROM async_operations WHERE operation_id = $1", uuid.UUID(operation_id)
315
315
  )
316
316
  if not result:
317
317
  # Operation was cancelled, skip processing
@@ -369,7 +369,7 @@ class MemoryEngine:
369
369
  try:
370
370
  pool = await self._get_pool()
371
371
  async with acquire_with_retry(pool) as conn:
372
- await conn.execute("DELETE FROM async_operations WHERE id = $1", uuid.UUID(operation_id))
372
+ await conn.execute("DELETE FROM async_operations WHERE operation_id = $1", uuid.UUID(operation_id))
373
373
  except Exception as e:
374
374
  logger.error(f"Failed to delete async operation record {operation_id}: {e}")
375
375
 
@@ -386,7 +386,7 @@ class MemoryEngine:
386
386
  """
387
387
  UPDATE async_operations
388
388
  SET status = 'failed', error_message = $2
389
- WHERE id = $1
389
+ WHERE operation_id = $1
390
390
  """,
391
391
  uuid.UUID(operation_id),
392
392
  truncated_error,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hindsight-api
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: Hindsight: Agent Memory That Works Like Human Memory
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: alembic>=1.17.1
@@ -18,7 +18,7 @@ hindsight_api/alembic/versions/d9f6a3b4c5e2_rename_bank_to_interactions.py,sha25
18
18
  hindsight_api/alembic/versions/e0a1b2c3d4e5_disposition_to_3_traits.py,sha256=LLj0Tl6Kjw5uZPo7lCcG2IH8lFSPEmc9jG_riMF3Bj0,2370
19
19
  hindsight_api/alembic/versions/rename_personality_to_disposition.py,sha256=gpMSG8hdvqn9__lGgS0EE2de1nki1YAaCEI3pDdJRzA,2281
20
20
  hindsight_api/api/__init__.py,sha256=zoDWA86ttx-UriC35UIgdPswIrau7GuMWTN63wYsUdM,2916
21
- hindsight_api/api/http.py,sha256=eYVnsQwx5LW3MvdcAQjiLw6WwBobw5aGeYSPYLIFllE,70922
21
+ hindsight_api/api/http.py,sha256=fuPpqrfDSEUygP21RWT4bzJF2HBttagR1lrFNfJgyIU,71208
22
22
  hindsight_api/api/mcp.py,sha256=I9C_jUz6d7efMstBfOyoqnnsB94JU6c2mMk6eQ_KDz0,7462
23
23
  hindsight_api/engine/__init__.py,sha256=z6srTnyvGQM0eya7E8r2yagTAc4C7IhHauUK8NM-gW8,1406
24
24
  hindsight_api/engine/cross_encoder.py,sha256=5WmUx9yfJdIwZ0nA218O-mMKQJ7EKaPOtwhMiDbG8KQ,10483
@@ -26,7 +26,7 @@ hindsight_api/engine/db_utils.py,sha256=0T5tL2SZ49JQihfyZYlTDThIfocKzkr1OpxQpJzP
26
26
  hindsight_api/engine/embeddings.py,sha256=IEdP5-p6oTJRRKV2JzUEojByJGShUEmkInCyA9wM8tg,10219
27
27
  hindsight_api/engine/entity_resolver.py,sha256=XHAViwIaEXMUhp9Eifvx0b3MZ4QwiFvH_k_ZHTwczxE,23151
28
28
  hindsight_api/engine/llm_wrapper.py,sha256=-EQnDoMr4BHTcp24dGNiOnYVGA5uGYmGFT5qQHhxGwY,21134
29
- hindsight_api/engine/memory_engine.py,sha256=l6NeQ_xHj8YfOs6Jpr6k6nYCUFRpZYIYZgf8H6JB7U8,135992
29
+ hindsight_api/engine/memory_engine.py,sha256=4EQft1qcUieYPK913gsfInAyghqhk-9XZ77bUJ72cbM,136032
30
30
  hindsight_api/engine/query_analyzer.py,sha256=DKFxmyyVVc59zwKbbGx4D22UVp6TxmD7jAa7cg9FGSU,19641
31
31
  hindsight_api/engine/response_models.py,sha256=QeESHC7oh84SYPDrR6FqHjiGBZnTAzo61IDB-qwVTSY,8737
32
32
  hindsight_api/engine/task_backend.py,sha256=XT0C-QFWfdcOHJjplkoarlnwvz-kCF2l6wAGW1dTJkw,7144
@@ -58,7 +58,7 @@ hindsight_api/engine/search/think_utils.py,sha256=rTRyoefRkZc65gcPQtffKiqHinpi7r
58
58
  hindsight_api/engine/search/trace.py,sha256=UTCmNRfAvIvDFGm5ifkuUk6JOKYrLlA_rPA72Zz_DfI,11217
59
59
  hindsight_api/engine/search/tracer.py,sha256=6OFlkRy_41gr2kgJZ1cmxnerUO069wPfnmiQrMvkOpg,15459
60
60
  hindsight_api/engine/search/types.py,sha256=2cK-5oynPTWc7UxnA7TFnwzNkcujCfOUvVf5VCk_srM,5594
61
- hindsight_api-0.1.7.dist-info/METADATA,sha256=c085oifvdxY8hwMLZ6vGZFRLWH9DmnvKR7KTWKU-dxk,5407
62
- hindsight_api-0.1.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
63
- hindsight_api-0.1.7.dist-info/entry_points.txt,sha256=vqZv5WLHbSx8vyec5RtMlUqtE_ul7DTgEVODSmou6Og,109
64
- hindsight_api-0.1.7.dist-info/RECORD,,
61
+ hindsight_api-0.1.8.dist-info/METADATA,sha256=y5HRP2iNw6qFwOPBGVAv8_leTmN_VMRuh7naPJSQG7I,5407
62
+ hindsight_api-0.1.8.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
63
+ hindsight_api-0.1.8.dist-info/entry_points.txt,sha256=vqZv5WLHbSx8vyec5RtMlUqtE_ul7DTgEVODSmou6Og,109
64
+ hindsight_api-0.1.8.dist-info/RECORD,,