diff --git a/examples/chat_history/memory.py b/examples/chat_history/memory.py index 4e742fae..d2a0459d 100644 --- a/examples/chat_history/memory.py +++ b/examples/chat_history/memory.py @@ -51,7 +51,9 @@ async def main() -> None: print(f"\n---Creating session: {session_id}") await client.memory.add_session( - session_id=session_id, user_id=user_id, metadata={"foo": "bar"} + session_id=session_id, + user_id=user_id, + metadata={"foo": "bar"}, ) # Update session metadata @@ -92,6 +94,10 @@ async def main() -> None: ) print(f"Classification: {classification}") + all_session_facts = await client.memory.get_session_facts(session_id) + for f in all_session_facts.facts: + print(f"{f.fact}\n") + # Get Memory for session print(f"\n---Get Perpetual Memory for Session: {session_id}") memory = await client.memory.get(session_id, memory_type="perpetual") @@ -106,6 +112,13 @@ async def main() -> None: ) print("summaryResult: ", summary_result) + query = "What are Jane's favorite shoe brands?" + print(f"\n---Searching over facts for: '{query}'") + facts_result = await client.memory.search_sessions( + session_ids=[session_id], text=query, search_scope="facts" + ) + print("facts_result: ", facts_result) + print("\n---Searching over summaries with MMR Reranking") summary_mmr_result = await client.memory.search_sessions( session_ids=[session_id], text=query, search_scope="summary", search_type="mmr" diff --git a/pyproject.toml b/pyproject.toml index 1e3f0a2d..a636626f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "zep-cloud" -version = "1.0.6" +version = "1.0.7" description = "" readme = "README.md" authors = [] diff --git a/src/zep_cloud/__init__.py b/src/zep_cloud/__init__.py index 3419b6cc..17b5e3c0 100644 --- a/src/zep_cloud/__init__.py +++ b/src/zep_cloud/__init__.py @@ -12,6 +12,10 @@ EndSessionResponse, EndSessionsResponse, Fact, + FactRatingExamples, + FactRatingInstruction, + FactResponse, + FactsResponse, Memory, MemorySearchResult, MemoryType, @@ -51,6 +55,10 @@ "EndSessionResponse", "EndSessionsResponse", "Fact", + "FactRatingExamples", + "FactRatingInstruction", + "FactResponse", + "FactsResponse", "InternalServerError", "Memory", "MemorySearchResult", diff --git a/src/zep_cloud/core/client_wrapper.py b/src/zep_cloud/core/client_wrapper.py index f6d367b2..9f6e3690 100644 --- a/src/zep_cloud/core/client_wrapper.py +++ b/src/zep_cloud/core/client_wrapper.py @@ -17,7 +17,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "zep-cloud", - "X-Fern-SDK-Version": "1.0.6", + "X-Fern-SDK-Version": "1.0.7", } headers["Authorization"] = f"Api-Key {self.api_key}" return headers diff --git a/src/zep_cloud/memory/client.py b/src/zep_cloud/memory/client.py index 16da8cb5..d96c87d1 100644 --- a/src/zep_cloud/memory/client.py +++ b/src/zep_cloud/memory/client.py @@ -17,6 +17,9 @@ from ..types.classify_session_response import ClassifySessionResponse from ..types.end_session_response import EndSessionResponse from ..types.end_sessions_response import EndSessionsResponse +from ..types.fact_rating_instruction import FactRatingInstruction +from ..types.fact_response import FactResponse +from ..types.facts_response import FactsResponse from ..types.memory import Memory from ..types.memory_search_result import MemorySearchResult from ..types.memory_type import MemoryType @@ -39,10 +42,101 @@ class MemoryClient: def __init__(self, *, client_wrapper: SyncClientWrapper): self._client_wrapper = client_wrapper + def get_fact(self, fact_uuid: str, *, request_options: typing.Optional[RequestOptions] = None) -> FactResponse: + """ + get fact by uuid + + Parameters + ---------- + fact_uuid : str + Fact UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + FactResponse + The fact with the specified UUID. + + Examples + -------- + from zep_cloud.client import Zep + + client = Zep( + api_key="YOUR_API_KEY", + ) + client.memory.get_fact( + fact_uuid="factUUID", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"facts/{jsonable_encoder(fact_uuid)}", method="GET", request_options=request_options + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FactResponse, _response.json()) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + def delete_fact(self, fact_uuid: str, *, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + delete a fact + + Parameters + ---------- + fact_uuid : str + Fact UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + Deleted + + Examples + -------- + from zep_cloud.client import Zep + + client = Zep( + api_key="YOUR_API_KEY", + ) + client.memory.delete_fact( + fact_uuid="factUUID", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"facts/{jsonable_encoder(fact_uuid)}", method="DELETE", request_options=request_options + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(str, _response.json()) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + def add_session( self, *, session_id: str, + fact_rating_instruction: typing.Optional[FactRatingInstruction] = OMIT, metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, user_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -55,6 +149,9 @@ def add_session( session_id : str The unique identifier of the session. + fact_rating_instruction : typing.Optional[FactRatingInstruction] + Optional instruction to use for fact rating. + metadata : typing.Optional[typing.Dict[str, typing.Any]] The metadata associated with the session. @@ -83,7 +180,12 @@ def add_session( _response = self._client_wrapper.httpx_client.request( "sessions", method="POST", - json={"metadata": metadata, "session_id": session_id, "user_id": user_id}, + json={ + "fact_rating_instruction": fact_rating_instruction, + "metadata": metadata, + "session_id": session_id, + "user_id": user_id, + }, request_options=request_options, omit=OMIT, ) @@ -226,6 +328,7 @@ def search_sessions( self, *, limit: typing.Optional[int] = None, + min_fact_rating: typing.Optional[float] = OMIT, min_score: typing.Optional[float] = OMIT, mmr_lambda: typing.Optional[float] = OMIT, record_filter: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, @@ -244,6 +347,8 @@ def search_sessions( limit : typing.Optional[int] The maximum number of search results to return. Defaults to None (no limit). + min_fact_rating : typing.Optional[float] + min_score : typing.Optional[float] mmr_lambda : typing.Optional[float] @@ -284,6 +389,7 @@ def search_sessions( method="POST", params={"limit": limit}, json={ + "min_fact_rating": min_fact_rating, "min_score": min_score, "mmr_lambda": mmr_lambda, "record_filter": record_filter, @@ -358,6 +464,7 @@ def update_session( session_id: str, *, metadata: typing.Dict[str, typing.Any], + fact_rating_instruction: typing.Optional[FactRatingInstruction] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> Session: """ @@ -371,6 +478,10 @@ def update_session( metadata : typing.Dict[str, typing.Any] The metadata to update + fact_rating_instruction : typing.Optional[FactRatingInstruction] + Optional instruction to use for fact rating. + Fact rating instructions can not be unset. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -394,7 +505,7 @@ def update_session( _response = self._client_wrapper.httpx_client.request( f"sessions/{jsonable_encoder(session_id)}", method="PATCH", - json={"metadata": metadata}, + json={"fact_rating_instruction": fact_rating_instruction, "metadata": metadata}, request_options=request_options, omit=OMIT, ) @@ -634,12 +745,70 @@ def extract_data( raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + def get_session_facts( + self, + session_id: str, + *, + min_rating: typing.Optional[float] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> FactsResponse: + """ + get facts for a session + + Parameters + ---------- + session_id : str + Session ID + + min_rating : typing.Optional[float] + Minimum rating by which to filter facts + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + FactsResponse + The facts for the session. + + Examples + -------- + from zep_cloud.client import Zep + + client = Zep( + api_key="YOUR_API_KEY", + ) + client.memory.get_session_facts( + session_id="sessionId", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"sessions/{jsonable_encoder(session_id)}/facts", + method="GET", + params={"minRating": min_rating}, + request_options=request_options, + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FactsResponse, _response.json()) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + def get( self, session_id: str, *, memory_type: typing.Optional[MemoryType] = None, lastn: typing.Optional[int] = None, + min_rating: typing.Optional[float] = None, request_options: typing.Optional[RequestOptions] = None, ) -> Memory: """ @@ -656,6 +825,9 @@ def get( lastn : typing.Optional[int] The number of most recent memory entries to retrieve. + min_rating : typing.Optional[float] + The minimum rating by which to filter facts + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -678,7 +850,7 @@ def get( _response = self._client_wrapper.httpx_client.request( f"sessions/{jsonable_encoder(session_id)}/memory", method="GET", - params={"memoryType": memory_type, "lastn": lastn}, + params={"memoryType": memory_type, "lastn": lastn, "minRating": min_rating}, request_options=request_options, ) if 200 <= _response.status_code < 300: @@ -994,6 +1166,7 @@ def search( *, limit: typing.Optional[int] = None, metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + min_fact_rating: typing.Optional[float] = OMIT, min_score: typing.Optional[float] = OMIT, mmr_lambda: typing.Optional[float] = OMIT, search_scope: typing.Optional[SearchScope] = OMIT, @@ -1015,6 +1188,8 @@ def search( metadata : typing.Optional[typing.Dict[str, typing.Any]] Metadata Filter + min_fact_rating : typing.Optional[float] + min_score : typing.Optional[float] mmr_lambda : typing.Optional[float] @@ -1050,6 +1225,7 @@ def search( params={"limit": limit}, json={ "metadata": metadata, + "min_fact_rating": min_fact_rating, "min_score": min_score, "mmr_lambda": mmr_lambda, "search_scope": search_scope, @@ -1182,10 +1358,103 @@ class AsyncMemoryClient: def __init__(self, *, client_wrapper: AsyncClientWrapper): self._client_wrapper = client_wrapper + async def get_fact( + self, fact_uuid: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> FactResponse: + """ + get fact by uuid + + Parameters + ---------- + fact_uuid : str + Fact UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + FactResponse + The fact with the specified UUID. + + Examples + -------- + from zep_cloud.client import AsyncZep + + client = AsyncZep( + api_key="YOUR_API_KEY", + ) + await client.memory.get_fact( + fact_uuid="factUUID", + ) + """ + _response = await self._client_wrapper.httpx_client.request( + f"facts/{jsonable_encoder(fact_uuid)}", method="GET", request_options=request_options + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FactResponse, _response.json()) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + async def delete_fact(self, fact_uuid: str, *, request_options: typing.Optional[RequestOptions] = None) -> str: + """ + delete a fact + + Parameters + ---------- + fact_uuid : str + Fact UUID + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + str + Deleted + + Examples + -------- + from zep_cloud.client import AsyncZep + + client = AsyncZep( + api_key="YOUR_API_KEY", + ) + await client.memory.delete_fact( + fact_uuid="factUUID", + ) + """ + _response = await self._client_wrapper.httpx_client.request( + f"facts/{jsonable_encoder(fact_uuid)}", method="DELETE", request_options=request_options + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(str, _response.json()) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + async def add_session( self, *, session_id: str, + fact_rating_instruction: typing.Optional[FactRatingInstruction] = OMIT, metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, user_id: typing.Optional[str] = OMIT, request_options: typing.Optional[RequestOptions] = None, @@ -1198,6 +1467,9 @@ async def add_session( session_id : str The unique identifier of the session. + fact_rating_instruction : typing.Optional[FactRatingInstruction] + Optional instruction to use for fact rating. + metadata : typing.Optional[typing.Dict[str, typing.Any]] The metadata associated with the session. @@ -1226,7 +1498,12 @@ async def add_session( _response = await self._client_wrapper.httpx_client.request( "sessions", method="POST", - json={"metadata": metadata, "session_id": session_id, "user_id": user_id}, + json={ + "fact_rating_instruction": fact_rating_instruction, + "metadata": metadata, + "session_id": session_id, + "user_id": user_id, + }, request_options=request_options, omit=OMIT, ) @@ -1369,6 +1646,7 @@ async def search_sessions( self, *, limit: typing.Optional[int] = None, + min_fact_rating: typing.Optional[float] = OMIT, min_score: typing.Optional[float] = OMIT, mmr_lambda: typing.Optional[float] = OMIT, record_filter: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, @@ -1387,6 +1665,8 @@ async def search_sessions( limit : typing.Optional[int] The maximum number of search results to return. Defaults to None (no limit). + min_fact_rating : typing.Optional[float] + min_score : typing.Optional[float] mmr_lambda : typing.Optional[float] @@ -1427,6 +1707,7 @@ async def search_sessions( method="POST", params={"limit": limit}, json={ + "min_fact_rating": min_fact_rating, "min_score": min_score, "mmr_lambda": mmr_lambda, "record_filter": record_filter, @@ -1501,6 +1782,7 @@ async def update_session( session_id: str, *, metadata: typing.Dict[str, typing.Any], + fact_rating_instruction: typing.Optional[FactRatingInstruction] = OMIT, request_options: typing.Optional[RequestOptions] = None, ) -> Session: """ @@ -1514,6 +1796,10 @@ async def update_session( metadata : typing.Dict[str, typing.Any] The metadata to update + fact_rating_instruction : typing.Optional[FactRatingInstruction] + Optional instruction to use for fact rating. + Fact rating instructions can not be unset. + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1537,7 +1823,7 @@ async def update_session( _response = await self._client_wrapper.httpx_client.request( f"sessions/{jsonable_encoder(session_id)}", method="PATCH", - json={"metadata": metadata}, + json={"fact_rating_instruction": fact_rating_instruction, "metadata": metadata}, request_options=request_options, omit=OMIT, ) @@ -1777,12 +2063,70 @@ async def extract_data( raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + async def get_session_facts( + self, + session_id: str, + *, + min_rating: typing.Optional[float] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> FactsResponse: + """ + get facts for a session + + Parameters + ---------- + session_id : str + Session ID + + min_rating : typing.Optional[float] + Minimum rating by which to filter facts + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + FactsResponse + The facts for the session. + + Examples + -------- + from zep_cloud.client import AsyncZep + + client = AsyncZep( + api_key="YOUR_API_KEY", + ) + await client.memory.get_session_facts( + session_id="sessionId", + ) + """ + _response = await self._client_wrapper.httpx_client.request( + f"sessions/{jsonable_encoder(session_id)}/facts", + method="GET", + params={"minRating": min_rating}, + request_options=request_options, + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(FactsResponse, _response.json()) # type: ignore + if _response.status_code == 404: + raise NotFoundError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + async def get( self, session_id: str, *, memory_type: typing.Optional[MemoryType] = None, lastn: typing.Optional[int] = None, + min_rating: typing.Optional[float] = None, request_options: typing.Optional[RequestOptions] = None, ) -> Memory: """ @@ -1799,6 +2143,9 @@ async def get( lastn : typing.Optional[int] The number of most recent memory entries to retrieve. + min_rating : typing.Optional[float] + The minimum rating by which to filter facts + request_options : typing.Optional[RequestOptions] Request-specific configuration. @@ -1821,7 +2168,7 @@ async def get( _response = await self._client_wrapper.httpx_client.request( f"sessions/{jsonable_encoder(session_id)}/memory", method="GET", - params={"memoryType": memory_type, "lastn": lastn}, + params={"memoryType": memory_type, "lastn": lastn, "minRating": min_rating}, request_options=request_options, ) if 200 <= _response.status_code < 300: @@ -2139,6 +2486,7 @@ async def search( *, limit: typing.Optional[int] = None, metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT, + min_fact_rating: typing.Optional[float] = OMIT, min_score: typing.Optional[float] = OMIT, mmr_lambda: typing.Optional[float] = OMIT, search_scope: typing.Optional[SearchScope] = OMIT, @@ -2160,6 +2508,8 @@ async def search( metadata : typing.Optional[typing.Dict[str, typing.Any]] Metadata Filter + min_fact_rating : typing.Optional[float] + min_score : typing.Optional[float] mmr_lambda : typing.Optional[float] @@ -2195,6 +2545,7 @@ async def search( params={"limit": limit}, json={ "metadata": metadata, + "min_fact_rating": min_fact_rating, "min_score": min_score, "mmr_lambda": mmr_lambda, "search_scope": search_scope, diff --git a/src/zep_cloud/types/__init__.py b/src/zep_cloud/types/__init__.py index 6f3008df..a9af3111 100644 --- a/src/zep_cloud/types/__init__.py +++ b/src/zep_cloud/types/__init__.py @@ -11,6 +11,10 @@ from .end_session_response import EndSessionResponse from .end_sessions_response import EndSessionsResponse from .fact import Fact +from .fact_rating_examples import FactRatingExamples +from .fact_rating_instruction import FactRatingInstruction +from .fact_response import FactResponse +from .facts_response import FactsResponse from .memory import Memory from .memory_search_result import MemorySearchResult from .memory_type import MemoryType @@ -43,6 +47,10 @@ "EndSessionResponse", "EndSessionsResponse", "Fact", + "FactRatingExamples", + "FactRatingInstruction", + "FactResponse", + "FactsResponse", "Memory", "MemorySearchResult", "MemoryType", diff --git a/src/zep_cloud/types/fact.py b/src/zep_cloud/types/fact.py index 2d70e9fb..3664eb06 100644 --- a/src/zep_cloud/types/fact.py +++ b/src/zep_cloud/types/fact.py @@ -10,6 +10,7 @@ class Fact(pydantic_v1.BaseModel): created_at: typing.Optional[str] = None fact: typing.Optional[str] = None + rating: typing.Optional[float] = None uuid_: typing.Optional[str] = pydantic_v1.Field(alias="uuid", default=None) def json(self, **kwargs: typing.Any) -> str: diff --git a/src/zep_cloud/types/fact_rating_examples.py b/src/zep_cloud/types/fact_rating_examples.py new file mode 100644 index 00000000..7e7679cb --- /dev/null +++ b/src/zep_cloud/types/fact_rating_examples.py @@ -0,0 +1,31 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class FactRatingExamples(pydantic_v1.BaseModel): + high: typing.Optional[str] = None + low: typing.Optional[str] = None + medium: typing.Optional[str] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/zep_cloud/types/fact_rating_instruction.py b/src/zep_cloud/types/fact_rating_instruction.py new file mode 100644 index 00000000..85d70a46 --- /dev/null +++ b/src/zep_cloud/types/fact_rating_instruction.py @@ -0,0 +1,45 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .fact_rating_examples import FactRatingExamples + + +class FactRatingInstruction(pydantic_v1.BaseModel): + examples: typing.Optional[FactRatingExamples] = pydantic_v1.Field(default=None) + """ + Examples is a list of examples that demonstrate how facts might be rated based on your instruction. You should provide + an example of a highly rated example, a low rated example, and a medium (or in between example). For example, if you are rating + based on relevance to a trip planning application, your examples might be: + High: "Joe's dream vacation is Bali" + Medium: "Joe has a fear of flying", + Low: "Joe's favorite food is Japanese", + """ + + instruction: typing.Optional[str] = pydantic_v1.Field(default=None) + """ + A string describing how to rate facts as they apply to your application. A trip planning application may + use something like "relevancy to planning a trip, the user's preferences when traveling, + or the user's travel history." + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/zep_cloud/types/fact_response.py b/src/zep_cloud/types/fact_response.py new file mode 100644 index 00000000..cfc5419f --- /dev/null +++ b/src/zep_cloud/types/fact_response.py @@ -0,0 +1,30 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .fact import Fact + + +class FactResponse(pydantic_v1.BaseModel): + fact: typing.Optional[Fact] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/zep_cloud/types/facts_response.py b/src/zep_cloud/types/facts_response.py new file mode 100644 index 00000000..c9f54e86 --- /dev/null +++ b/src/zep_cloud/types/facts_response.py @@ -0,0 +1,30 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .fact import Fact + + +class FactsResponse(pydantic_v1.BaseModel): + facts: typing.Optional[typing.List[Fact]] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/zep_cloud/types/session.py b/src/zep_cloud/types/session.py index 6ae67985..34b442fa 100644 --- a/src/zep_cloud/types/session.py +++ b/src/zep_cloud/types/session.py @@ -5,6 +5,7 @@ from ..core.datetime_utils import serialize_datetime from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .fact_rating_instruction import FactRatingInstruction class Session(pydantic_v1.BaseModel): @@ -12,6 +13,7 @@ class Session(pydantic_v1.BaseModel): created_at: typing.Optional[str] = None deleted_at: typing.Optional[str] = None ended_at: typing.Optional[str] = None + fact_rating_instruction: typing.Optional[FactRatingInstruction] = None fact_version_uuid: typing.Optional[str] = None facts: typing.Optional[typing.List[str]] = None id: typing.Optional[int] = None