acontext 0.1.8__py3-none-any.whl → 0.1.9__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.
@@ -224,6 +224,7 @@ class AsyncSessionsAPI:
224
224
  *,
225
225
  blob: MessageBlob,
226
226
  format: Literal["acontext", "openai", "anthropic", "gemini"] = "openai",
227
+ meta: dict[str, Any] | None = None,
227
228
  file_field: str | None = None,
228
229
  file: (
229
230
  FileUpload
@@ -238,12 +239,15 @@ class AsyncSessionsAPI:
238
239
  session_id: The UUID of the session.
239
240
  blob: The message blob in Acontext, OpenAI, Anthropic, or Gemini format.
240
241
  format: The format of the message blob. Defaults to "openai".
242
+ meta: Optional user-provided metadata for the message. This metadata is stored
243
+ separately from the message content and can be retrieved via get_messages().metas
244
+ or updated via patch_message_meta(). Works with all formats.
241
245
  file_field: The field name for file upload. Only used when format is "acontext".
242
246
  Required if file is provided. Defaults to None.
243
247
  file: Optional file upload. Only used when format is "acontext". Defaults to None.
244
248
 
245
249
  Returns:
246
- The created Message object.
250
+ The created Message object. The msg.meta field contains only user-provided metadata.
247
251
 
248
252
  Raises:
249
253
  ValueError: If format is invalid, file/file_field provided for non-acontext format,
@@ -264,6 +268,9 @@ class AsyncSessionsAPI:
264
268
  payload: dict[str, Any] = {
265
269
  "format": format,
266
270
  }
271
+ if meta is not None:
272
+ payload["meta"] = meta
273
+
267
274
  if format == "acontext":
268
275
  if isinstance(blob, Mapping):
269
276
  payload["blob"] = blob
@@ -412,3 +419,83 @@ class AsyncSessionsAPI:
412
419
  "GET", f"/session/{session_id}/observing_status"
413
420
  )
414
421
  return MessageObservingStatus.model_validate(data)
422
+
423
+ async def patch_message_meta(
424
+ self,
425
+ session_id: str,
426
+ message_id: str,
427
+ *,
428
+ meta: dict[str, Any],
429
+ ) -> dict[str, Any]:
430
+ """Update message metadata using patch semantics.
431
+
432
+ Only updates keys present in the meta dict. Existing keys not in the request
433
+ are preserved. To delete a key, pass None as its value.
434
+
435
+ Args:
436
+ session_id: The UUID of the session.
437
+ message_id: The UUID of the message.
438
+ meta: Dictionary of metadata keys to add, update, or delete.
439
+ Pass None as a value to delete that key.
440
+
441
+ Returns:
442
+ The complete user metadata after the patch operation.
443
+
444
+ Example:
445
+ >>> # Add/update keys
446
+ >>> updated = await client.sessions.patch_message_meta(
447
+ ... session_id, message_id,
448
+ ... meta={"status": "processed", "score": 0.95}
449
+ ... )
450
+ >>> # Delete a key
451
+ >>> updated = await client.sessions.patch_message_meta(
452
+ ... session_id, message_id,
453
+ ... meta={"old_key": None} # Deletes "old_key"
454
+ ... )
455
+ """
456
+ payload = {"meta": meta}
457
+ data = await self._requester.request(
458
+ "PATCH",
459
+ f"/session/{session_id}/messages/{message_id}/meta",
460
+ json_data=payload,
461
+ )
462
+ return data.get("meta", {}) # type: ignore
463
+
464
+ async def patch_configs(
465
+ self,
466
+ session_id: str,
467
+ *,
468
+ configs: dict[str, Any],
469
+ ) -> dict[str, Any]:
470
+ """Update session configs using patch semantics.
471
+
472
+ Only updates keys present in the configs dict. Existing keys not in the request
473
+ are preserved. To delete a key, pass None as its value.
474
+
475
+ Args:
476
+ session_id: The UUID of the session.
477
+ configs: Dictionary of config keys to add, update, or delete.
478
+ Pass None as a value to delete that key.
479
+
480
+ Returns:
481
+ The complete configs after the patch operation.
482
+
483
+ Example:
484
+ >>> # Add/update keys
485
+ >>> updated = await client.sessions.patch_configs(
486
+ ... session_id,
487
+ ... configs={"agent": "bot2", "temperature": 0.8}
488
+ ... )
489
+ >>> # Delete a key
490
+ >>> updated = await client.sessions.patch_configs(
491
+ ... session_id,
492
+ ... configs={"old_key": None} # Deletes "old_key"
493
+ ... )
494
+ """
495
+ payload = {"configs": configs}
496
+ data = await self._requester.request(
497
+ "PATCH",
498
+ f"/session/{session_id}/configs",
499
+ json_data=payload,
500
+ )
501
+ return data.get("configs", {}) # type: ignore
@@ -224,6 +224,7 @@ class SessionsAPI:
224
224
  *,
225
225
  blob: MessageBlob,
226
226
  format: Literal["acontext", "openai", "anthropic", "gemini"] = "openai",
227
+ meta: dict[str, Any] | None = None,
227
228
  file_field: str | None = None,
228
229
  file: (
229
230
  FileUpload
@@ -238,12 +239,15 @@ class SessionsAPI:
238
239
  session_id: The UUID of the session.
239
240
  blob: The message blob in Acontext, OpenAI, Anthropic, or Gemini format.
240
241
  format: The format of the message blob. Defaults to "openai".
242
+ meta: Optional user-provided metadata for the message. This metadata is stored
243
+ separately from the message content and can be retrieved via get_messages().metas
244
+ or updated via patch_message_meta(). Works with all formats.
241
245
  file_field: The field name for file upload. Only used when format is "acontext".
242
246
  Required if file is provided. Defaults to None.
243
247
  file: Optional file upload. Only used when format is "acontext". Defaults to None.
244
248
 
245
249
  Returns:
246
- The created Message object.
250
+ The created Message object. The msg.meta field contains only user-provided metadata.
247
251
 
248
252
  Raises:
249
253
  ValueError: If format is invalid, file/file_field provided for non-acontext format,
@@ -265,6 +269,9 @@ class SessionsAPI:
265
269
  payload: dict[str, Any] = {
266
270
  "format": format,
267
271
  }
272
+ if meta is not None:
273
+ payload["meta"] = meta
274
+
268
275
  if format == "acontext":
269
276
  if isinstance(blob, Mapping):
270
277
  payload["blob"] = blob
@@ -406,3 +413,83 @@ class SessionsAPI:
406
413
  """
407
414
  data = self._requester.request("GET", f"/session/{session_id}/observing_status")
408
415
  return MessageObservingStatus.model_validate(data)
416
+
417
+ def patch_message_meta(
418
+ self,
419
+ session_id: str,
420
+ message_id: str,
421
+ *,
422
+ meta: dict[str, Any],
423
+ ) -> dict[str, Any]:
424
+ """Update message metadata using patch semantics.
425
+
426
+ Only updates keys present in the meta dict. Existing keys not in the request
427
+ are preserved. To delete a key, pass None as its value.
428
+
429
+ Args:
430
+ session_id: The UUID of the session.
431
+ message_id: The UUID of the message.
432
+ meta: Dictionary of metadata keys to add, update, or delete.
433
+ Pass None as a value to delete that key.
434
+
435
+ Returns:
436
+ The complete user metadata after the patch operation.
437
+
438
+ Example:
439
+ >>> # Add/update keys
440
+ >>> updated = client.sessions.patch_message_meta(
441
+ ... session_id, message_id,
442
+ ... meta={"status": "processed", "score": 0.95}
443
+ ... )
444
+ >>> # Delete a key
445
+ >>> updated = client.sessions.patch_message_meta(
446
+ ... session_id, message_id,
447
+ ... meta={"old_key": None} # Deletes "old_key"
448
+ ... )
449
+ """
450
+ payload = {"meta": meta}
451
+ data = self._requester.request(
452
+ "PATCH",
453
+ f"/session/{session_id}/messages/{message_id}/meta",
454
+ json_data=payload,
455
+ )
456
+ return data.get("meta", {}) # type: ignore
457
+
458
+ def patch_configs(
459
+ self,
460
+ session_id: str,
461
+ *,
462
+ configs: dict[str, Any],
463
+ ) -> dict[str, Any]:
464
+ """Update session configs using patch semantics.
465
+
466
+ Only updates keys present in the configs dict. Existing keys not in the request
467
+ are preserved. To delete a key, pass None as its value.
468
+
469
+ Args:
470
+ session_id: The UUID of the session.
471
+ configs: Dictionary of config keys to add, update, or delete.
472
+ Pass None as a value to delete that key.
473
+
474
+ Returns:
475
+ The complete configs after the patch operation.
476
+
477
+ Example:
478
+ >>> # Add/update keys
479
+ >>> updated = client.sessions.patch_configs(
480
+ ... session_id,
481
+ ... configs={"agent": "bot2", "temperature": 0.8}
482
+ ... )
483
+ >>> # Delete a key
484
+ >>> updated = client.sessions.patch_configs(
485
+ ... session_id,
486
+ ... configs={"old_key": None} # Deletes "old_key"
487
+ ... )
488
+ """
489
+ payload = {"configs": configs}
490
+ data = self._requester.request(
491
+ "PATCH",
492
+ f"/session/{session_id}/configs",
493
+ json_data=payload,
494
+ )
495
+ return data.get("configs", {}) # type: ignore
acontext/types/session.py CHANGED
@@ -245,6 +245,10 @@ class GetMessagesOutput(BaseModel):
245
245
  ...,
246
246
  description="List of message UUIDs corresponding to each item in the same order",
247
247
  )
248
+ metas: list[dict[str, Any]] = Field(
249
+ default_factory=list,
250
+ description="List of user-provided metadata for each message (same order as items/ids)",
251
+ )
248
252
  next_cursor: str | None = Field(None, description="Cursor for pagination")
249
253
  has_more: bool = Field(..., description="Whether there are more items")
250
254
  this_time_tokens: int = Field(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: acontext
3
- Version: 0.1.8
3
+ Version: 0.1.9
4
4
  Summary: Python SDK for the Acontext API
5
5
  Keywords: acontext,sdk,client,api
6
6
  Requires-Dist: httpx>=0.28.1
@@ -17,22 +17,22 @@ acontext/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  acontext/resources/__init__.py,sha256=NN5rlry2o_GdqxbiKq0oeVLi6NE6i1k0MwA0Nw0MOO8,739
18
18
  acontext/resources/async_disks.py,sha256=rc8hSdVsZ1UbrK2kwxmEMZyP0aEMsvjyZ70cYddpiF8,12051
19
19
  acontext/resources/async_sandboxes.py,sha256=GC-HhkgNl70P4W-eD9lSRE-aPYoOPqRes_9hvGvQf9g,2852
20
- acontext/resources/async_sessions.py,sha256=UhnAFh13wJrvXBqFeK1bTXsdT5YAj-q3LDQ96_IhJvA,15921
20
+ acontext/resources/async_sessions.py,sha256=-edVKXjDFTQkt37xGX20YUNYjq6ed5LpVPgzXMAwN5U,19117
21
21
  acontext/resources/async_skills.py,sha256=eRn3NjBhR6_6GmEyZO_nKc0OnHgR_TeIHxqGX_73lwo,5999
22
22
  acontext/resources/async_users.py,sha256=CjW_Xz-UnNf449Hr1j3YeGgtIVZi2ePY5-r7Uj3wMIc,2005
23
23
  acontext/resources/disks.py,sha256=YyAzm6A00T4A3dI8YTEAOxwm6bnCnp8gWIoZ4lLGN5w,11859
24
24
  acontext/resources/sandboxes.py,sha256=BWaSK2MrkVvKgVeHJZyIbvaiEqXREIa7X5LJxOoxUts,2781
25
- acontext/resources/sessions.py,sha256=wdrTi8c_6PsgA9X4izLOuU4xV7MDONV-wExWWUb_LJo,15678
25
+ acontext/resources/sessions.py,sha256=MDnuwu1KUYe0s7RnbzTGl1xMICudXzWQ73vBEKtgN7Y,18826
26
26
  acontext/resources/skills.py,sha256=CZFgJhRDtGlbDcTBKNxFkG4DlqoaJb0c_ymfV12QKdM,5930
27
27
  acontext/resources/users.py,sha256=vZfBHd2ARmd9d5d8n5rLaMUT5z2bMO82k7OcqMaFqxk,1946
28
28
  acontext/types/__init__.py,sha256=Qwz8d8Z060bSRWaR5QavgVoQviBHqQ9UqvDme_nbDpM,1611
29
29
  acontext/types/common.py,sha256=CbJdF8c9jbSCtDhVTxCLOzXaSe836C_AUrmMEFA8aHA,563
30
30
  acontext/types/disk.py,sha256=jdQqQ8HF3cwl_Y1dh98TOXZKfcdN_gSzaSrCE8PKT-0,2250
31
31
  acontext/types/sandbox.py,sha256=vbgpwjbVjjY3uwXxSbOP8IfC65lhkJ_4BYA19dqj5FE,2248
32
- acontext/types/session.py,sha256=WqhEtrg1jwknIiQ9TipUeLONS4bY_J_C7Xd_TrYlsWg,11003
32
+ acontext/types/session.py,sha256=2CD-okvwScQFUWfMGQ6RpNWpaNGpz0lbmhnm8cWaLgQ,11177
33
33
  acontext/types/skill.py,sha256=v7OAvtkwTeZAkLG7NQMcwFoSJ4g-HDWjPZ4EoMyU3mk,2779
34
34
  acontext/types/user.py,sha256=dBzHCqULSJ3Sqw7T8nA0U8Sctz76Pd0hm1qsHvtEIBQ,1264
35
35
  acontext/uploads.py,sha256=6twnqQOY_eerNuEjeSKsE_3S0IfJUiczXtAy4aXqDl8,1379
36
- acontext-0.1.8.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
37
- acontext-0.1.8.dist-info/METADATA,sha256=oWNmr7kXtegIBZRwOwYR2bkb_gL0Ms0vp55fO0EPtqQ,888
38
- acontext-0.1.8.dist-info/RECORD,,
36
+ acontext-0.1.9.dist-info/WHEEL,sha256=iHtWm8nRfs0VRdCYVXocAWFW8ppjHL-uTJkAdZJKOBM,80
37
+ acontext-0.1.9.dist-info/METADATA,sha256=k6W8Q89F_3FXpPYezcQs_iyhb8utr60cR3BGJpCe0Xw,888
38
+ acontext-0.1.9.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: uv 0.9.28
2
+ Generator: uv 0.9.30
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any