antonlytics 2.1.0__tar.gz → 2.2.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.
- {antonlytics-2.1.0 → antonlytics-2.2.0}/PKG-INFO +1 -1
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics/__init__.py +1 -1
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics/agent.py +73 -25
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics.egg-info/PKG-INFO +1 -1
- {antonlytics-2.1.0 → antonlytics-2.2.0}/pyproject.toml +1 -1
- {antonlytics-2.1.0 → antonlytics-2.2.0}/setup.py +1 -1
- {antonlytics-2.1.0 → antonlytics-2.2.0}/.gitignore +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/.pyre/pyre.stderr +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/LICENSE +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/MANIFEST.in +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/Makefile +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/README.md +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics/exceptions.py +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics/http_client.py +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics/integrations/__init__.py +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics/integrations/langchain.py +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics.egg-info/SOURCES.txt +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics.egg-info/dependency_links.txt +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics.egg-info/requires.txt +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/antonlytics.egg-info/top_level.txt +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/examples/langchain_quickstart.py +0 -0
- {antonlytics-2.1.0 → antonlytics-2.2.0}/setup.cfg +0 -0
|
@@ -7,5 +7,5 @@ Simple SDK for giving your AI agent persistent memory.
|
|
|
7
7
|
from .agent import Agent
|
|
8
8
|
from .exceptions import AntonlyticsError, APIError, AuthenticationError
|
|
9
9
|
|
|
10
|
-
__version__ = "2.
|
|
10
|
+
__version__ = "2.2.0"
|
|
11
11
|
__all__ = ["Agent", "AntonlyticsError", "APIError", "AuthenticationError"]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Agent class for interacting with Antonlytics API.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Dict, Any, Optional, List
|
|
5
|
+
from typing import Dict, Any, Optional, List, Iterator
|
|
6
6
|
from .http_client import HTTPClient
|
|
7
7
|
from .exceptions import AntonlyticsError
|
|
8
8
|
|
|
@@ -121,41 +121,89 @@ class Agent:
|
|
|
121
121
|
|
|
122
122
|
return self.client.post('/api/v1/memory/chat/', payload)
|
|
123
123
|
|
|
124
|
-
def get_memory(
|
|
124
|
+
def get_memory(
|
|
125
|
+
self,
|
|
126
|
+
query: Optional[str] = None,
|
|
127
|
+
*,
|
|
128
|
+
max_entities: int = 10_000,
|
|
129
|
+
page_size: int = 500,
|
|
130
|
+
) -> Dict[str, Any]:
|
|
125
131
|
"""
|
|
126
132
|
Get memory context for your own agent/model.
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
|
|
134
|
+
Two modes:
|
|
135
|
+
- ``query`` provided: semantic top-K retrieval (single shot, server-ranked).
|
|
136
|
+
Returns the most relevant entities and their relationships.
|
|
137
|
+
- ``query=None``: enumerates the full project graph via cursor pagination,
|
|
138
|
+
auto-iterating pages internally. Stops at ``max_entities`` for safety.
|
|
139
|
+
|
|
129
140
|
Args:
|
|
130
|
-
query: Optional natural language query
|
|
131
|
-
|
|
141
|
+
query: Optional natural language query for ranked retrieval.
|
|
142
|
+
max_entities: Safety ceiling for full-graph mode (default 10000).
|
|
143
|
+
page_size: Pagination page size for full-graph mode (1-1000, default 500).
|
|
144
|
+
|
|
132
145
|
Returns:
|
|
133
|
-
Dict with entities and relationships
|
|
134
|
-
|
|
146
|
+
Dict with entities and relationships.
|
|
147
|
+
|
|
135
148
|
Example:
|
|
136
|
-
>>> #
|
|
137
|
-
>>> memory = agent.get_memory()
|
|
138
|
-
>>>
|
|
139
|
-
>>> #
|
|
140
|
-
>>>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
...
|
|
149
|
+
>>> # Top-K retrieval for prompt context
|
|
150
|
+
>>> memory = agent.get_memory(query="What did Sarah say?")
|
|
151
|
+
>>>
|
|
152
|
+
>>> # Full project dump (auto-paginated)
|
|
153
|
+
>>> all_memory = agent.get_memory()
|
|
154
|
+
>>>
|
|
155
|
+
>>> # For very large projects, stream pages:
|
|
156
|
+
>>> for page in agent.iter_memory(page_size=500):
|
|
157
|
+
... process(page)
|
|
145
158
|
"""
|
|
146
159
|
if query:
|
|
147
160
|
response = self.client.post('/api/v1/memory/query/', {
|
|
148
161
|
'question': query,
|
|
149
|
-
'project_id': self.project_id
|
|
150
|
-
})
|
|
151
|
-
return response.get('graph_context', {})
|
|
152
|
-
else:
|
|
153
|
-
# Get all memory
|
|
154
|
-
response = self.client.post('/api/v1/memory/query/', {
|
|
155
|
-
'question': 'What do you know?',
|
|
156
|
-
'project_id': self.project_id
|
|
162
|
+
'project_id': self.project_id,
|
|
157
163
|
})
|
|
158
164
|
return response.get('graph_context', {})
|
|
165
|
+
|
|
166
|
+
# Full-graph mode: auto-paginate via /memory/list/.
|
|
167
|
+
entities: List[Dict[str, Any]] = []
|
|
168
|
+
relationships: List[Dict[str, Any]] = []
|
|
169
|
+
for page in self.iter_memory(page_size=page_size):
|
|
170
|
+
entities.extend(page.get('entities', []))
|
|
171
|
+
relationships.extend(page.get('relationships', []))
|
|
172
|
+
if len(entities) >= max_entities:
|
|
173
|
+
entities = entities[:max_entities]
|
|
174
|
+
break
|
|
175
|
+
return {'entities': entities, 'relationships': relationships}
|
|
176
|
+
|
|
177
|
+
def iter_memory(self, page_size: int = 500) -> Iterator[Dict[str, Any]]:
|
|
178
|
+
"""
|
|
179
|
+
Stream the full project graph one page at a time.
|
|
180
|
+
|
|
181
|
+
Yields a dict ``{entities, relationships, next_cursor, has_more}`` per page.
|
|
182
|
+
Iteration stops automatically when the server reports no more pages.
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
page_size: Rows per page (1-1000, default 500).
|
|
186
|
+
|
|
187
|
+
Example:
|
|
188
|
+
>>> for page in agent.iter_memory(page_size=200):
|
|
189
|
+
... for entity in page["entities"]:
|
|
190
|
+
... print(entity["name"])
|
|
191
|
+
"""
|
|
192
|
+
cursor: Optional[str] = None
|
|
193
|
+
while True:
|
|
194
|
+
payload: Dict[str, Any] = {
|
|
195
|
+
'project_id': self.project_id,
|
|
196
|
+
'limit': page_size,
|
|
197
|
+
}
|
|
198
|
+
if cursor:
|
|
199
|
+
payload['cursor'] = cursor
|
|
200
|
+
page = self.client.post('/api/v1/memory/list/', payload)
|
|
201
|
+
yield page
|
|
202
|
+
if not page.get('has_more'):
|
|
203
|
+
break
|
|
204
|
+
cursor = page.get('next_cursor')
|
|
205
|
+
if not cursor:
|
|
206
|
+
break
|
|
159
207
|
|
|
160
208
|
def set_system_prompt(self, prompt: str) -> Dict[str, Any]:
|
|
161
209
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|