memorysync 1.7.3__tar.gz → 1.8.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: memorysync
3
- Version: 1.7.3
3
+ Version: 1.8.0
4
4
  Summary: Official Python client for the MemorySync API.
5
5
  Project-URL: Homepage, https://memorysync.io
6
6
  Project-URL: Documentation, https://docs.memorysync.io
@@ -0,0 +1 @@
1
+ __version__ = "1.8.0"
@@ -193,6 +193,7 @@ class _RequestBuilder:
193
193
  session_id: Optional[str],
194
194
  metadata: Optional[Dict[str, Any]],
195
195
  end_user_id: Optional[str],
196
+ client_ref: Optional[str] = None,
196
197
  ) -> Dict[str, Any]:
197
198
  return _strip_none(
198
199
  {
@@ -203,6 +204,7 @@ class _RequestBuilder:
203
204
  "session_id": session_id,
204
205
  "metadata": metadata,
205
206
  "end_user_id": end_user_id,
207
+ "client_ref": client_ref,
206
208
  }
207
209
  )
208
210
 
@@ -364,7 +366,18 @@ class MemorySyncClient:
364
366
  session_id: Optional[str] = None,
365
367
  metadata: Optional[Dict[str, Any]] = None,
366
368
  end_user_id: Optional[str] = None,
369
+ client_ref: Optional[str] = None,
367
370
  ) -> AddResult:
371
+ """Store one memory candidate.
372
+
373
+ Pass ``client_ref`` -- your own identifier for the record, at most 128
374
+ characters -- and re-sending it is recognised rather than stored a second
375
+ time: the call returns an :class:`AddSkippedResponse` with reason
376
+ ``already_ingested`` and the ids the first write produced. That makes an
377
+ interrupted write safe to retry without first checking whether it landed.
378
+ Near-duplicate detection is always on, but it compares *meaning*, so it is
379
+ a filter and not a guarantee.
380
+ """
368
381
  body = _RequestBuilder.add(
369
382
  text,
370
383
  source=source,
@@ -373,6 +386,7 @@ class MemorySyncClient:
373
386
  session_id=session_id,
374
387
  metadata=metadata,
375
388
  end_user_id=end_user_id,
389
+ client_ref=client_ref,
376
390
  )
377
391
  raw = self._request("POST", "/memory/add", json=body, end_user_override=end_user_id)
378
392
  skipped = _as_skipped(raw, default_reason="no_high_value_content")
@@ -1057,7 +1071,18 @@ class AsyncMemorySyncClient:
1057
1071
  session_id: Optional[str] = None,
1058
1072
  metadata: Optional[Dict[str, Any]] = None,
1059
1073
  end_user_id: Optional[str] = None,
1074
+ client_ref: Optional[str] = None,
1060
1075
  ) -> AddResult:
1076
+ """Store one memory candidate.
1077
+
1078
+ Pass ``client_ref`` -- your own identifier for the record, at most 128
1079
+ characters -- and re-sending it is recognised rather than stored a second
1080
+ time: the call returns an :class:`AddSkippedResponse` with reason
1081
+ ``already_ingested`` and the ids the first write produced. That makes an
1082
+ interrupted write safe to retry without first checking whether it landed.
1083
+ Near-duplicate detection is always on, but it compares *meaning*, so it is
1084
+ a filter and not a guarantee.
1085
+ """
1061
1086
  body = _RequestBuilder.add(
1062
1087
  text,
1063
1088
  source=source,
@@ -1066,6 +1091,7 @@ class AsyncMemorySyncClient:
1066
1091
  session_id=session_id,
1067
1092
  metadata=metadata,
1068
1093
  end_user_id=end_user_id,
1094
+ client_ref=client_ref,
1069
1095
  )
1070
1096
  raw = await self._request("POST", "/memory/add", json=body, end_user_override=end_user_id)
1071
1097
  skipped = _as_skipped(raw, default_reason="no_high_value_content")
@@ -79,6 +79,14 @@ class BulkAddItem:
79
79
  metadata: Optional[Dict[str, Any]] = None
80
80
  importance: Optional[float] = None
81
81
  end_user_id: Optional[str] = None
82
+ #: Your own identifier for this record, at most 128 characters.
83
+ #:
84
+ #: Send it and re-submitting the record is recognised rather than stored a
85
+ #: second time: the item comes back ``skipped`` with reason
86
+ #: ``already_ingested`` and the ids the first submission produced. This is
87
+ #: what makes a large import safe to re-run. Near-duplicate detection is
88
+ #: always on but compares *meaning*, so it is a filter and not a guarantee.
89
+ client_ref: Optional[str] = None
82
90
 
83
91
  def to_dict(self) -> Dict[str, Any]:
84
92
  out: Dict[str, Any] = {"text": self.text}
@@ -94,6 +102,8 @@ class BulkAddItem:
94
102
  out["importance"] = self.importance
95
103
  if self.end_user_id is not None:
96
104
  out["end_user_id"] = self.end_user_id
105
+ if self.client_ref is not None:
106
+ out["client_ref"] = self.client_ref
97
107
  return out
98
108
 
99
109
 
@@ -1 +0,0 @@
1
- __version__ = "1.7.3"
File without changes
File without changes
File without changes
File without changes