zep-cloud 3.2.0__tar.gz → 3.3.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.
Files changed (95) hide show
  1. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/PKG-INFO +1 -1
  2. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/pyproject.toml +1 -1
  3. zep_cloud-3.3.0/src/zep_cloud/graph/utils.py +144 -0
  4. zep_cloud-3.2.0/src/zep_cloud/graph/utils.py +0 -70
  5. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/LICENSE +0 -0
  6. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/README.md +0 -0
  7. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/__init__.py +0 -0
  8. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/base_client.py +0 -0
  9. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/client.py +0 -0
  10. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/__init__.py +0 -0
  11. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/api_error.py +0 -0
  12. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/client_wrapper.py +0 -0
  13. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/datetime_utils.py +0 -0
  14. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/file.py +0 -0
  15. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/force_multipart.py +0 -0
  16. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/http_client.py +0 -0
  17. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/http_response.py +0 -0
  18. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/jsonable_encoder.py +0 -0
  19. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/pydantic_utilities.py +0 -0
  20. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/query_encoder.py +0 -0
  21. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/remove_none_from_dict.py +0 -0
  22. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/request_options.py +0 -0
  23. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/core/serialization.py +0 -0
  24. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/environment.py +0 -0
  25. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/errors/__init__.py +0 -0
  26. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/errors/bad_request_error.py +0 -0
  27. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/errors/internal_server_error.py +0 -0
  28. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/errors/not_found_error.py +0 -0
  29. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/external_clients/graph.py +0 -0
  30. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/external_clients/ontology.py +0 -0
  31. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/external_clients/user.py +0 -0
  32. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/__init__.py +0 -0
  33. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/client.py +0 -0
  34. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/edge/__init__.py +0 -0
  35. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/edge/client.py +0 -0
  36. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/edge/raw_client.py +0 -0
  37. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/episode/__init__.py +0 -0
  38. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/episode/client.py +0 -0
  39. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/episode/raw_client.py +0 -0
  40. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/node/__init__.py +0 -0
  41. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/node/client.py +0 -0
  42. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/node/raw_client.py +0 -0
  43. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/graph/raw_client.py +0 -0
  44. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/py.typed +0 -0
  45. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/thread/__init__.py +0 -0
  46. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/thread/client.py +0 -0
  47. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/thread/raw_client.py +0 -0
  48. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/thread/types/__init__.py +0 -0
  49. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/thread/types/thread_get_user_context_request_mode.py +0 -0
  50. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/__init__.py +0 -0
  51. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/add_thread_messages_response.py +0 -0
  52. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/add_triple_response.py +0 -0
  53. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/api_error.py +0 -0
  54. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/clone_graph_response.py +0 -0
  55. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/comparison_operator.py +0 -0
  56. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/date_filter.py +0 -0
  57. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/edge_type.py +0 -0
  58. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/entity_edge.py +0 -0
  59. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/entity_edge_source_target.py +0 -0
  60. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/entity_node.py +0 -0
  61. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/entity_property.py +0 -0
  62. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/entity_property_type.py +0 -0
  63. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/entity_type.py +0 -0
  64. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/entity_type_response.py +0 -0
  65. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/episode.py +0 -0
  66. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/episode_data.py +0 -0
  67. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/episode_mentions.py +0 -0
  68. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/episode_response.py +0 -0
  69. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/fact_rating_examples.py +0 -0
  70. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/fact_rating_instruction.py +0 -0
  71. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/graph.py +0 -0
  72. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/graph_data_type.py +0 -0
  73. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/graph_edges_request.py +0 -0
  74. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/graph_list_response.py +0 -0
  75. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/graph_nodes_request.py +0 -0
  76. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/graph_search_results.py +0 -0
  77. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/graph_search_scope.py +0 -0
  78. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/message.py +0 -0
  79. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/message_list_response.py +0 -0
  80. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/models_fact_rating_examples.py +0 -0
  81. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/models_fact_rating_instruction.py +0 -0
  82. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/reranker.py +0 -0
  83. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/role_type.py +0 -0
  84. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/search_filters.py +0 -0
  85. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/success_response.py +0 -0
  86. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/thread.py +0 -0
  87. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/thread_context_response.py +0 -0
  88. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/thread_list_response.py +0 -0
  89. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/user.py +0 -0
  90. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/user_list_response.py +0 -0
  91. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/types/user_node_response.py +0 -0
  92. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/user/__init__.py +0 -0
  93. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/user/client.py +0 -0
  94. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/user/raw_client.py +0 -0
  95. {zep_cloud-3.2.0 → zep_cloud-3.3.0}/src/zep_cloud/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zep-cloud
3
- Version: 3.2.0
3
+ Version: 3.3.0
4
4
  Summary:
5
5
  Requires-Python: >=3.9.0,<4.0
6
6
  Classifier: Intended Audience :: Developers
@@ -3,7 +3,7 @@ name = "zep-cloud"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "zep-cloud"
6
- version = "3.2.0"
6
+ version = "3.3.0"
7
7
  description = ""
8
8
  readme = "README.md"
9
9
  authors = []
@@ -0,0 +1,144 @@
1
+ from datetime import datetime
2
+ from typing import List
3
+
4
+ from zep_cloud import EntityEdge, EntityNode, Episode
5
+
6
+ DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
7
+
8
+
9
+ def parse_iso_datetime(iso_string: str) -> datetime:
10
+ """Parse ISO datetime string, handling Z suffix for UTC."""
11
+ try:
12
+ return datetime.fromisoformat(iso_string)
13
+ except ValueError:
14
+ # Handle Z suffix for Python 3.9 compatibility
15
+ if iso_string.endswith('Z'):
16
+ return datetime.fromisoformat(iso_string[:-1] + '+00:00')
17
+ raise
18
+
19
+ TEMPLATE_STRING = """
20
+ FACTS and ENTITIES{episodes_header} represent relevant context to the current conversation.
21
+
22
+ # These are the most relevant facts and their valid date ranges
23
+ # format: FACT (Date range: from - to)
24
+ <FACTS>
25
+ {facts}
26
+ </FACTS>
27
+
28
+ # These are the most relevant entities
29
+ # Name: ENTITY_NAME
30
+ # Label: entity_label (if present)
31
+ # Attributes: (if present)
32
+ # attr_name: attr_value
33
+ # Summary: entity summary
34
+ <ENTITIES>
35
+ {entities}
36
+ </ENTITIES>
37
+ {episodes_section}
38
+ """
39
+
40
+
41
+ def format_edge_date_range(edge: EntityEdge) -> str:
42
+ """
43
+ Format the date range of an entity edge.
44
+
45
+ Args:
46
+ edge: The entity edge to format.
47
+
48
+ Returns:
49
+ A string representation of the date range.
50
+ """
51
+ valid_at = "date unknown"
52
+ invalid_at = "present"
53
+
54
+ if edge.valid_at is not None:
55
+ valid_at = parse_iso_datetime(edge.valid_at).strftime(DATE_FORMAT)
56
+ if edge.invalid_at is not None:
57
+ invalid_at = parse_iso_datetime(edge.invalid_at).strftime(DATE_FORMAT)
58
+
59
+ return f"{valid_at} - {invalid_at}"
60
+
61
+
62
+ def compose_context_string(edges: List[EntityEdge], nodes: List[EntityNode], episodes: List[Episode]) -> str:
63
+ """
64
+ Compose a search context from entity edges, nodes, and episodes.
65
+
66
+ Args:
67
+ edges: List of entity edges.
68
+ nodes: List of entity nodes.
69
+ episodes: List of episodes.
70
+
71
+ Returns:
72
+ A formatted string containing facts, entities, and episodes.
73
+ """
74
+ facts = []
75
+ for edge in edges:
76
+ fact = f" - {edge.fact} (Date range: {format_edge_date_range(edge)})"
77
+ facts.append(fact)
78
+
79
+ entities = []
80
+ for node in nodes:
81
+ entity_parts = [f"Name: {node.name}"]
82
+
83
+ if hasattr(node, 'labels') and node.labels:
84
+ labels = list(node.labels) # Create a copy to avoid modifying original
85
+ if 'Entity' in labels:
86
+ labels.remove('Entity')
87
+ if labels: # Only add label if there are remaining labels after removing 'Entity'
88
+ entity_parts.append(f"Label: {labels[0]}")
89
+
90
+ if hasattr(node, 'attributes') and node.attributes:
91
+ # Filter out 'labels' from attributes as it's redundant with the Label field
92
+ filtered_attributes = {k: v for k, v in node.attributes.items() if k != 'labels'}
93
+ if filtered_attributes: # Only add attributes section if there are non-label attributes
94
+ entity_parts.append("Attributes:")
95
+ for attr_name, attr_value in filtered_attributes.items():
96
+ entity_parts.append(f" {attr_name}: {attr_value}")
97
+
98
+ if node.summary:
99
+ entity_parts.append(f"Summary: {node.summary}")
100
+
101
+ entity = "\n".join(entity_parts)
102
+ entities.append(entity)
103
+
104
+ # Format episodes
105
+ episodes_list = []
106
+ if episodes:
107
+ for episode in episodes:
108
+ role_prefix = ""
109
+ if hasattr(episode, 'role') and episode.role:
110
+ if hasattr(episode, 'role_type') and episode.role_type:
111
+ role_prefix = f"{episode.role} ({episode.role_type}): "
112
+ else:
113
+ role_prefix = f"{episode.role}: "
114
+ elif hasattr(episode, 'role_type') and episode.role_type:
115
+ role_prefix = f"({episode.role_type}): "
116
+
117
+ # Format timestamp
118
+ episode_created_at = episode.created_at
119
+ if hasattr(episode, 'provided_created_at') and episode.provided_created_at:
120
+ episode_created_at = episode.provided_created_at
121
+
122
+ # Parse timestamp if it's a string (ISO format)
123
+ if isinstance(episode_created_at, str):
124
+ timestamp = parse_iso_datetime(episode_created_at).strftime(DATE_FORMAT)
125
+ else:
126
+ timestamp = episode_created_at.strftime(DATE_FORMAT)
127
+
128
+ episode_str = f" - {role_prefix}{episode.content} ({timestamp})"
129
+ episodes_list.append(episode_str)
130
+
131
+ facts_str = "\n".join(facts) if facts else ""
132
+ entities_str = "\n".join(entities) if entities else ""
133
+ episodes_str = "\n".join(episodes_list) if episodes_list else ""
134
+
135
+ # Determine if episodes section should be included
136
+ episodes_header = ", and EPISODES" if episodes else ""
137
+ episodes_section = f"\n# These are the most relevant episodes\n<EPISODES>\n{episodes_str}\n</EPISODES>" if episodes else ""
138
+
139
+ return TEMPLATE_STRING.format(
140
+ episodes_header=episodes_header,
141
+ facts=facts_str,
142
+ entities=entities_str,
143
+ episodes_section=episodes_section
144
+ )
@@ -1,70 +0,0 @@
1
- from datetime import datetime
2
- from typing import List
3
-
4
- from zep_cloud import EntityEdge, EntityNode
5
-
6
- DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
7
-
8
- TEMPLATE_STRING = """
9
- FACTS and ENTITIES represent relevant context to the current conversation.
10
-
11
- # These are the most relevant facts and their valid date ranges
12
- # format: FACT (Date range: from - to)
13
- <FACTS>
14
- %s
15
- </FACTS>
16
-
17
- # These are the most relevant entities
18
- # ENTITY_NAME: entity summary
19
- <ENTITIES>
20
- %s
21
- </ENTITIES>
22
- """
23
-
24
-
25
- def format_edge_date_range(edge: EntityEdge) -> str:
26
- """
27
- Format the date range of an entity edge.
28
-
29
- Args:
30
- edge: The entity edge to format.
31
-
32
- Returns:
33
- A string representation of the date range.
34
- """
35
- valid_at = "date unknown"
36
- invalid_at = "present"
37
-
38
- if edge.valid_at is not None:
39
- valid_at = datetime.fromisoformat(edge.valid_at).strftime(DATE_FORMAT)
40
- if edge.invalid_at is not None:
41
- invalid_at = datetime.fromisoformat(edge.invalid_at).strftime(DATE_FORMAT)
42
-
43
- return f"{valid_at} - {invalid_at}"
44
-
45
-
46
- def compose_context_string(edges: List[EntityEdge], nodes: List[EntityNode]) -> str:
47
- """
48
- Compose a search context from entity edges and nodes.
49
-
50
- Args:
51
- edges: List of entity edges.
52
- nodes: List of entity nodes.
53
-
54
- Returns:
55
- A formatted string containing facts and entities.
56
- """
57
- facts = []
58
- for edge in edges:
59
- fact = f" - {edge.fact} ({format_edge_date_range(edge)})"
60
- facts.append(fact)
61
-
62
- entities = []
63
- for node in nodes:
64
- entity = f" - {node.name}: {node.summary}"
65
- entities.append(entity)
66
-
67
- facts_str = "\n".join(facts)
68
- entities_str = "\n".join(entities)
69
-
70
- return TEMPLATE_STRING % (facts_str, entities_str)
File without changes
File without changes