diff --git a/reference.md b/reference.md index 799785f..ba15252 100644 --- a/reference.md +++ b/reference.md @@ -136,6 +136,19 @@ client.batch.create()
+**ignore_roles:** `typing.Optional[typing.Sequence[RoleType]]` + +Optional list of message role types to skip during graph ingestion for +thread_message items in this batch. The messages are still stored and +retained as context, but no graph extraction is performed for them. +Has no effect on graph_episode items. + +
+
+ +
+
+ **metadata:** `typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]`
@@ -2633,6 +2646,76 @@ client.graph.update(
+ + + + +
client.graph.warm(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Hints Zep to warm a graph for low-latency search +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from zep_cloud import Zep + +client = Zep( + api_key="YOUR_API_KEY", +) +client.graph.warm( + graph_id="graphId", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**graph_id:** `str` — The graph_id of the graph to warm. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
diff --git a/src/zep_cloud/batch/client.py b/src/zep_cloud/batch/client.py index 6a81005..dcf2d84 100644 --- a/src/zep_cloud/batch/client.py +++ b/src/zep_cloud/batch/client.py @@ -9,6 +9,7 @@ from ..types.batch_item_list_response import BatchItemListResponse from ..types.batch_list_response import BatchListResponse from ..types.batch_summary import BatchSummary +from ..types.role_type import RoleType from ..types.success_response import SuccessResponse from .raw_client import AsyncRawBatchClient, RawBatchClient @@ -80,6 +81,7 @@ def list( def create( self, *, + ignore_roles: typing.Optional[typing.Sequence[RoleType]] = OMIT, metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> BatchSummary: @@ -88,6 +90,12 @@ def create( Parameters ---------- + ignore_roles : typing.Optional[typing.Sequence[RoleType]] + Optional list of message role types to skip during graph ingestion for + thread_message items in this batch. The messages are still stored and + retained as context, but no graph extraction is performed for them. + Has no effect on graph_episode items. + metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] request_options : typing.Optional[RequestOptions] @@ -107,7 +115,9 @@ def create( ) client.batch.create() """ - _response = self._raw_client.create(metadata=metadata, request_options=request_options) + _response = self._raw_client.create( + ignore_roles=ignore_roles, metadata=metadata, request_options=request_options + ) return _response.data def get(self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> BatchSummary: @@ -375,6 +385,7 @@ async def main() -> None: async def create( self, *, + ignore_roles: typing.Optional[typing.Sequence[RoleType]] = OMIT, metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> BatchSummary: @@ -383,6 +394,12 @@ async def create( Parameters ---------- + ignore_roles : typing.Optional[typing.Sequence[RoleType]] + Optional list of message role types to skip during graph ingestion for + thread_message items in this batch. The messages are still stored and + retained as context, but no graph extraction is performed for them. + Has no effect on graph_episode items. + metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] request_options : typing.Optional[RequestOptions] @@ -410,7 +427,9 @@ async def main() -> None: asyncio.run(main()) """ - _response = await self._raw_client.create(metadata=metadata, request_options=request_options) + _response = await self._raw_client.create( + ignore_roles=ignore_roles, metadata=metadata, request_options=request_options + ) return _response.data async def get(self, batch_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> BatchSummary: diff --git a/src/zep_cloud/batch/raw_client.py b/src/zep_cloud/batch/raw_client.py index e13a90d..f87e878 100644 --- a/src/zep_cloud/batch/raw_client.py +++ b/src/zep_cloud/batch/raw_client.py @@ -21,6 +21,7 @@ from ..types.batch_item_list_response import BatchItemListResponse from ..types.batch_list_response import BatchListResponse from ..types.batch_summary import BatchSummary +from ..types.role_type import RoleType from ..types.success_response import SuccessResponse # this is used as the default value for optional parameters @@ -126,6 +127,7 @@ def list( def create( self, *, + ignore_roles: typing.Optional[typing.Sequence[RoleType]] = OMIT, metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> HttpResponse[BatchSummary]: @@ -134,6 +136,12 @@ def create( Parameters ---------- + ignore_roles : typing.Optional[typing.Sequence[RoleType]] + Optional list of message role types to skip during graph ingestion for + thread_message items in this batch. The messages are still stored and + retained as context, but no graph extraction is performed for them. + Has no effect on graph_episode items. + metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] request_options : typing.Optional[RequestOptions] @@ -148,6 +156,7 @@ def create( "batches", method="POST", json={ + "ignore_roles": ignore_roles, "metadata": metadata, }, headers={ @@ -811,6 +820,7 @@ async def list( async def create( self, *, + ignore_roles: typing.Optional[typing.Sequence[RoleType]] = OMIT, metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> AsyncHttpResponse[BatchSummary]: @@ -819,6 +829,12 @@ async def create( Parameters ---------- + ignore_roles : typing.Optional[typing.Sequence[RoleType]] + Optional list of message role types to skip during graph ingestion for + thread_message items in this batch. The messages are still stored and + retained as context, but no graph extraction is performed for them. + Has no effect on graph_episode items. + metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] request_options : typing.Optional[RequestOptions] @@ -833,6 +849,7 @@ async def create( "batches", method="POST", json={ + "ignore_roles": ignore_roles, "metadata": metadata, }, headers={ diff --git a/src/zep_cloud/graph/client.py b/src/zep_cloud/graph/client.py index e258862..b9f72dd 100644 --- a/src/zep_cloud/graph/client.py +++ b/src/zep_cloud/graph/client.py @@ -1013,6 +1013,37 @@ def update( ) return _response.data + def warm(self, graph_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> SuccessResponse: + """ + Hints Zep to warm a graph for low-latency search + + Parameters + ---------- + graph_id : str + The graph_id of the graph to warm. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SuccessResponse + Warm hint accepted + + Examples + -------- + from zep_cloud import Zep + + client = Zep( + api_key="YOUR_API_KEY", + ) + client.graph.warm( + graph_id="graphId", + ) + """ + _response = self._raw_client.warm(graph_id, request_options=request_options) + return _response.data + class AsyncGraphClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -2120,3 +2151,42 @@ async def main() -> None: graph_id, description=description, name=name, request_options=request_options ) return _response.data + + async def warm(self, graph_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> SuccessResponse: + """ + Hints Zep to warm a graph for low-latency search + + Parameters + ---------- + graph_id : str + The graph_id of the graph to warm. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + SuccessResponse + Warm hint accepted + + Examples + -------- + import asyncio + + from zep_cloud import AsyncZep + + client = AsyncZep( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.graph.warm( + graph_id="graphId", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.warm(graph_id, request_options=request_options) + return _response.data diff --git a/src/zep_cloud/graph/raw_client.py b/src/zep_cloud/graph/raw_client.py index 112e15c..4e48005 100644 --- a/src/zep_cloud/graph/raw_client.py +++ b/src/zep_cloud/graph/raw_client.py @@ -1679,6 +1679,71 @@ def update( status_code=_response.status_code, headers=dict(_response.headers), body=_response_json ) + def warm( + self, graph_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> HttpResponse[SuccessResponse]: + """ + Hints Zep to warm a graph for low-latency search + + Parameters + ---------- + graph_id : str + The graph_id of the graph to warm. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[SuccessResponse] + Warm hint accepted + """ + _response = self._client_wrapper.httpx_client.request( + f"graph/{jsonable_encoder(graph_id)}/warm", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SuccessResponse, + parse_obj_as( + type_=SuccessResponse, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) + class AsyncRawGraphClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): @@ -3319,3 +3384,68 @@ async def update( raise core_api_error_ApiError( status_code=_response.status_code, headers=dict(_response.headers), body=_response_json ) + + async def warm( + self, graph_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AsyncHttpResponse[SuccessResponse]: + """ + Hints Zep to warm a graph for low-latency search + + Parameters + ---------- + graph_id : str + The graph_id of the graph to warm. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[SuccessResponse] + Warm hint accepted + """ + _response = await self._client_wrapper.httpx_client.request( + f"graph/{jsonable_encoder(graph_id)}/warm", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + SuccessResponse, + parse_obj_as( + type_=SuccessResponse, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 404: + raise NotFoundError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 500: + raise InternalServerError( + headers=dict(_response.headers), + body=typing.cast( + types_api_error_ApiError, + parse_obj_as( + type_=types_api_error_ApiError, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.text + ) + raise core_api_error_ApiError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response_json + ) diff --git a/src/zep_cloud/types/batch_item_status.py b/src/zep_cloud/types/batch_item_status.py index 4247df0..276314d 100644 --- a/src/zep_cloud/types/batch_item_status.py +++ b/src/zep_cloud/types/batch_item_status.py @@ -3,5 +3,5 @@ import typing BatchItemStatus = typing.Union[ - typing.Literal["pending", "queued", "processing", "succeeded", "failed", "skipped"], typing.Any + typing.Literal["pending", "queued", "processing", "succeeded", "failed", "skipped", "canceled"], typing.Any ] diff --git a/src/zep_cloud/types/batch_progress.py b/src/zep_cloud/types/batch_progress.py index 477331e..981ff21 100644 --- a/src/zep_cloud/types/batch_progress.py +++ b/src/zep_cloud/types/batch_progress.py @@ -7,6 +7,7 @@ class BatchProgress(UniversalBaseModel): + canceled_items: typing.Optional[int] = None failed_items: typing.Optional[int] = None percent_complete: typing.Optional[float] = None processing_items: typing.Optional[int] = None diff --git a/src/zep_cloud/types/batch_status.py b/src/zep_cloud/types/batch_status.py index 400d3d5..deacee6 100644 --- a/src/zep_cloud/types/batch_status.py +++ b/src/zep_cloud/types/batch_status.py @@ -3,5 +3,5 @@ import typing BatchStatus = typing.Union[ - typing.Literal["draft", "invalid", "queued", "processing", "succeeded", "partial", "failed"], typing.Any + typing.Literal["draft", "invalid", "queued", "processing", "succeeded", "partial", "failed", "canceled"], typing.Any ] diff --git a/src/zep_cloud/types/batch_summary.py b/src/zep_cloud/types/batch_summary.py index f085774..aaf0d40 100644 --- a/src/zep_cloud/types/batch_summary.py +++ b/src/zep_cloud/types/batch_summary.py @@ -6,12 +6,14 @@ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel from .batch_progress import BatchProgress from .batch_status import BatchStatus +from .role_type import RoleType class BatchSummary(UniversalBaseModel): batch_id: typing.Optional[str] = None completed_at: typing.Optional[str] = None created_at: typing.Optional[str] = None + ignore_roles: typing.Optional[typing.List[RoleType]] = None item_count: typing.Optional[int] = None metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = None processed_at: typing.Optional[str] = None