hindsight-client 0.1.16__tar.gz → 0.2.1__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.
- hindsight_client-0.2.1/.openapi-generator/FILES +58 -0
- hindsight_client-0.2.1/.openapi-generator/VERSION +1 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/PKG-INFO +1 -1
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client/hindsight_client.py +58 -25
- hindsight_client-0.2.1/hindsight_client_api/__init__.py +81 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/api_client.py +6 -13
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/configuration.py +4 -15
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/exceptions.py +2 -22
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/__init__.py +2 -1
- hindsight_client-0.2.1/hindsight_client_api/models/entity_input.py +94 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/memory_item.py +17 -2
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/reflect_request.py +12 -3
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/reflect_response.py +9 -2
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/rest.py +60 -38
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/openapi-generator-config.yaml +3 -1
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/pyproject.toml +1 -1
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/tests/test_main_operations.py +45 -0
- hindsight_client-0.1.16/.openapi-generator/FILES +0 -154
- hindsight_client-0.1.16/.openapi-generator/VERSION +0 -1
- hindsight_client-0.1.16/hindsight_client_api/__init__.py +0 -142
- hindsight_client-0.1.16/hindsight_client_api/docs/AddBackgroundRequest.md +0 -31
- hindsight_client-0.1.16/hindsight_client_api/docs/BackgroundResponse.md +0 -31
- hindsight_client-0.1.16/hindsight_client_api/docs/BankListItem.md +0 -35
- hindsight_client-0.1.16/hindsight_client_api/docs/BankListResponse.md +0 -30
- hindsight_client-0.1.16/hindsight_client_api/docs/BankProfileResponse.md +0 -33
- hindsight_client-0.1.16/hindsight_client_api/docs/BankStatsResponse.md +0 -39
- hindsight_client-0.1.16/hindsight_client_api/docs/BanksApi.md +0 -517
- hindsight_client-0.1.16/hindsight_client_api/docs/Budget.md +0 -15
- hindsight_client-0.1.16/hindsight_client_api/docs/CancelOperationResponse.md +0 -32
- hindsight_client-0.1.16/hindsight_client_api/docs/ChunkData.md +0 -33
- hindsight_client-0.1.16/hindsight_client_api/docs/ChunkIncludeOptions.md +0 -30
- hindsight_client-0.1.16/hindsight_client_api/docs/ChunkResponse.md +0 -35
- hindsight_client-0.1.16/hindsight_client_api/docs/CreateBankRequest.md +0 -32
- hindsight_client-0.1.16/hindsight_client_api/docs/DeleteDocumentResponse.md +0 -33
- hindsight_client-0.1.16/hindsight_client_api/docs/DeleteResponse.md +0 -32
- hindsight_client-0.1.16/hindsight_client_api/docs/DispositionTraits.md +0 -32
- hindsight_client-0.1.16/hindsight_client_api/docs/DocumentResponse.md +0 -36
- hindsight_client-0.1.16/hindsight_client_api/docs/DocumentsApi.md +0 -313
- hindsight_client-0.1.16/hindsight_client_api/docs/EntitiesApi.md +0 -230
- hindsight_client-0.1.16/hindsight_client_api/docs/EntityDetailResponse.md +0 -36
- hindsight_client-0.1.16/hindsight_client_api/docs/EntityIncludeOptions.md +0 -30
- hindsight_client-0.1.16/hindsight_client_api/docs/EntityListItem.md +0 -35
- hindsight_client-0.1.16/hindsight_client_api/docs/EntityListResponse.md +0 -30
- hindsight_client-0.1.16/hindsight_client_api/docs/EntityObservationResponse.md +0 -31
- hindsight_client-0.1.16/hindsight_client_api/docs/EntityStateResponse.md +0 -32
- hindsight_client-0.1.16/hindsight_client_api/docs/GraphDataResponse.md +0 -33
- hindsight_client-0.1.16/hindsight_client_api/docs/HTTPValidationError.md +0 -29
- hindsight_client-0.1.16/hindsight_client_api/docs/IncludeOptions.md +0 -31
- hindsight_client-0.1.16/hindsight_client_api/docs/ListDocumentsResponse.md +0 -33
- hindsight_client-0.1.16/hindsight_client_api/docs/ListMemoryUnitsResponse.md +0 -33
- hindsight_client-0.1.16/hindsight_client_api/docs/MemoryApi.md +0 -499
- hindsight_client-0.1.16/hindsight_client_api/docs/MemoryItem.md +0 -34
- hindsight_client-0.1.16/hindsight_client_api/docs/MonitoringApi.md +0 -136
- hindsight_client-0.1.16/hindsight_client_api/docs/OperationResponse.md +0 -36
- hindsight_client-0.1.16/hindsight_client_api/docs/OperationsApi.md +0 -154
- hindsight_client-0.1.16/hindsight_client_api/docs/OperationsListResponse.md +0 -31
- hindsight_client-0.1.16/hindsight_client_api/docs/RecallRequest.md +0 -36
- hindsight_client-0.1.16/hindsight_client_api/docs/RecallResponse.md +0 -33
- hindsight_client-0.1.16/hindsight_client_api/docs/RecallResult.md +0 -40
- hindsight_client-0.1.16/hindsight_client_api/docs/ReflectFact.md +0 -35
- hindsight_client-0.1.16/hindsight_client_api/docs/ReflectIncludeOptions.md +0 -30
- hindsight_client-0.1.16/hindsight_client_api/docs/ReflectRequest.md +0 -33
- hindsight_client-0.1.16/hindsight_client_api/docs/ReflectResponse.md +0 -31
- hindsight_client-0.1.16/hindsight_client_api/docs/RetainRequest.md +0 -31
- hindsight_client-0.1.16/hindsight_client_api/docs/RetainResponse.md +0 -33
- hindsight_client-0.1.16/hindsight_client_api/docs/UpdateDispositionRequest.md +0 -30
- hindsight_client-0.1.16/hindsight_client_api/docs/ValidationError.md +0 -31
- hindsight_client-0.1.16/hindsight_client_api/docs/ValidationErrorLocInner.md +0 -28
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/.gitignore +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/.openapi-generator-ignore +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/README.md +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client/__init__.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/api/__init__.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/api/banks_api.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/api/documents_api.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/api/entities_api.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/api/memory_api.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/api/monitoring_api.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/api/operations_api.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/api_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/add_background_request.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/background_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/bank_list_item.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/bank_list_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/bank_profile_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/bank_stats_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/budget.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/cancel_operation_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/chunk_data.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/chunk_include_options.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/chunk_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/create_bank_request.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/delete_document_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/delete_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/disposition_traits.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/document_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/entity_detail_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/entity_include_options.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/entity_list_item.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/entity_list_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/entity_observation_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/entity_state_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/graph_data_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/http_validation_error.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/include_options.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/list_documents_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/list_memory_units_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/operation_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/operations_list_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/recall_request.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/recall_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/recall_result.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/reflect_fact.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/reflect_include_options.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/retain_request.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/retain_response.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/update_disposition_request.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/validation_error.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/validation_error_loc_inner.py +0 -0
- {hindsight_client-0.1.16 → hindsight_client-0.2.1}/tests/__init__.py +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
hindsight_client_api/__init__.py
|
|
2
|
+
hindsight_client_api/api/__init__.py
|
|
3
|
+
hindsight_client_api/api/banks_api.py
|
|
4
|
+
hindsight_client_api/api/documents_api.py
|
|
5
|
+
hindsight_client_api/api/entities_api.py
|
|
6
|
+
hindsight_client_api/api/memory_api.py
|
|
7
|
+
hindsight_client_api/api/monitoring_api.py
|
|
8
|
+
hindsight_client_api/api/operations_api.py
|
|
9
|
+
hindsight_client_api/api_client.py
|
|
10
|
+
hindsight_client_api/api_response.py
|
|
11
|
+
hindsight_client_api/configuration.py
|
|
12
|
+
hindsight_client_api/exceptions.py
|
|
13
|
+
hindsight_client_api/models/__init__.py
|
|
14
|
+
hindsight_client_api/models/add_background_request.py
|
|
15
|
+
hindsight_client_api/models/background_response.py
|
|
16
|
+
hindsight_client_api/models/bank_list_item.py
|
|
17
|
+
hindsight_client_api/models/bank_list_response.py
|
|
18
|
+
hindsight_client_api/models/bank_profile_response.py
|
|
19
|
+
hindsight_client_api/models/bank_stats_response.py
|
|
20
|
+
hindsight_client_api/models/budget.py
|
|
21
|
+
hindsight_client_api/models/cancel_operation_response.py
|
|
22
|
+
hindsight_client_api/models/chunk_data.py
|
|
23
|
+
hindsight_client_api/models/chunk_include_options.py
|
|
24
|
+
hindsight_client_api/models/chunk_response.py
|
|
25
|
+
hindsight_client_api/models/create_bank_request.py
|
|
26
|
+
hindsight_client_api/models/delete_document_response.py
|
|
27
|
+
hindsight_client_api/models/delete_response.py
|
|
28
|
+
hindsight_client_api/models/disposition_traits.py
|
|
29
|
+
hindsight_client_api/models/document_response.py
|
|
30
|
+
hindsight_client_api/models/entity_detail_response.py
|
|
31
|
+
hindsight_client_api/models/entity_include_options.py
|
|
32
|
+
hindsight_client_api/models/entity_input.py
|
|
33
|
+
hindsight_client_api/models/entity_list_item.py
|
|
34
|
+
hindsight_client_api/models/entity_list_response.py
|
|
35
|
+
hindsight_client_api/models/entity_observation_response.py
|
|
36
|
+
hindsight_client_api/models/entity_state_response.py
|
|
37
|
+
hindsight_client_api/models/graph_data_response.py
|
|
38
|
+
hindsight_client_api/models/http_validation_error.py
|
|
39
|
+
hindsight_client_api/models/include_options.py
|
|
40
|
+
hindsight_client_api/models/list_documents_response.py
|
|
41
|
+
hindsight_client_api/models/list_memory_units_response.py
|
|
42
|
+
hindsight_client_api/models/memory_item.py
|
|
43
|
+
hindsight_client_api/models/operation_response.py
|
|
44
|
+
hindsight_client_api/models/operations_list_response.py
|
|
45
|
+
hindsight_client_api/models/recall_request.py
|
|
46
|
+
hindsight_client_api/models/recall_response.py
|
|
47
|
+
hindsight_client_api/models/recall_result.py
|
|
48
|
+
hindsight_client_api/models/reflect_fact.py
|
|
49
|
+
hindsight_client_api/models/reflect_include_options.py
|
|
50
|
+
hindsight_client_api/models/reflect_request.py
|
|
51
|
+
hindsight_client_api/models/reflect_response.py
|
|
52
|
+
hindsight_client_api/models/retain_request.py
|
|
53
|
+
hindsight_client_api/models/retain_response.py
|
|
54
|
+
hindsight_client_api/models/update_disposition_request.py
|
|
55
|
+
hindsight_client_api/models/validation_error.py
|
|
56
|
+
hindsight_client_api/models/validation_error_loc_inner.py
|
|
57
|
+
hindsight_client_api/rest.py
|
|
58
|
+
hindsight_client_api_README.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7.10.0
|
|
@@ -112,6 +112,7 @@ class Hindsight:
|
|
|
112
112
|
context: Optional[str] = None,
|
|
113
113
|
document_id: Optional[str] = None,
|
|
114
114
|
metadata: Optional[Dict[str, str]] = None,
|
|
115
|
+
entities: Optional[List[Dict[str, str]]] = None,
|
|
115
116
|
) -> RetainResponse:
|
|
116
117
|
"""
|
|
117
118
|
Store a single memory (simplified interface).
|
|
@@ -123,13 +124,14 @@ class Hindsight:
|
|
|
123
124
|
context: Optional context description
|
|
124
125
|
document_id: Optional document ID for grouping
|
|
125
126
|
metadata: Optional user-defined metadata
|
|
127
|
+
entities: Optional list of entities [{"text": "...", "type": "..."}]
|
|
126
128
|
|
|
127
129
|
Returns:
|
|
128
130
|
RetainResponse with success status
|
|
129
131
|
"""
|
|
130
132
|
return self.retain_batch(
|
|
131
133
|
bank_id=bank_id,
|
|
132
|
-
items=[{"content": content, "timestamp": timestamp, "context": context, "metadata": metadata}],
|
|
134
|
+
items=[{"content": content, "timestamp": timestamp, "context": context, "metadata": metadata, "entities": entities}],
|
|
133
135
|
document_id=document_id,
|
|
134
136
|
)
|
|
135
137
|
|
|
@@ -145,24 +147,34 @@ class Hindsight:
|
|
|
145
147
|
|
|
146
148
|
Args:
|
|
147
149
|
bank_id: The memory bank ID
|
|
148
|
-
items: List of memory items with 'content' and optional 'timestamp', 'context', 'metadata', 'document_id'
|
|
150
|
+
items: List of memory items with 'content' and optional 'timestamp', 'context', 'metadata', 'document_id', 'entities'
|
|
149
151
|
document_id: Optional document ID for grouping memories (applied to items that don't have their own)
|
|
150
152
|
retain_async: If True, process asynchronously in background (default: False)
|
|
151
153
|
|
|
152
154
|
Returns:
|
|
153
155
|
RetainResponse with success status and item count
|
|
154
156
|
"""
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
157
|
+
from hindsight_client_api.models.entity_input import EntityInput
|
|
158
|
+
|
|
159
|
+
memory_items = []
|
|
160
|
+
for item in items:
|
|
161
|
+
entities = None
|
|
162
|
+
if item.get("entities"):
|
|
163
|
+
entities = [
|
|
164
|
+
EntityInput(text=e["text"], type=e.get("type"))
|
|
165
|
+
for e in item["entities"]
|
|
166
|
+
]
|
|
167
|
+
memory_items.append(
|
|
168
|
+
memory_item.MemoryItem(
|
|
169
|
+
content=item["content"],
|
|
170
|
+
timestamp=item.get("timestamp"),
|
|
171
|
+
context=item.get("context"),
|
|
172
|
+
metadata=item.get("metadata"),
|
|
173
|
+
# Use item's document_id if provided, otherwise fall back to batch-level document_id
|
|
174
|
+
document_id=item.get("document_id") or document_id,
|
|
175
|
+
entities=entities,
|
|
176
|
+
)
|
|
163
177
|
)
|
|
164
|
-
for item in items
|
|
165
|
-
]
|
|
166
178
|
|
|
167
179
|
request_obj = retain_request.RetainRequest(
|
|
168
180
|
items=memory_items,
|
|
@@ -229,6 +241,8 @@ class Hindsight:
|
|
|
229
241
|
query: str,
|
|
230
242
|
budget: str = "low",
|
|
231
243
|
context: Optional[str] = None,
|
|
244
|
+
max_tokens: Optional[int] = None,
|
|
245
|
+
response_schema: Optional[Dict[str, Any]] = None,
|
|
232
246
|
) -> ReflectResponse:
|
|
233
247
|
"""
|
|
234
248
|
Generate a contextual answer based on bank identity and memories.
|
|
@@ -238,14 +252,21 @@ class Hindsight:
|
|
|
238
252
|
query: The question or prompt
|
|
239
253
|
budget: Budget level for reflection - "low", "mid", or "high" (default: "low")
|
|
240
254
|
context: Optional additional context
|
|
255
|
+
max_tokens: Maximum tokens for the response (server default: 4096)
|
|
256
|
+
response_schema: Optional JSON Schema for structured output. When provided,
|
|
257
|
+
the response will include a 'structured_output' field with the LLM
|
|
258
|
+
response parsed according to this schema.
|
|
241
259
|
|
|
242
260
|
Returns:
|
|
243
|
-
ReflectResponse with answer text
|
|
261
|
+
ReflectResponse with answer text, optionally facts used, and optionally
|
|
262
|
+
structured_output if response_schema was provided
|
|
244
263
|
"""
|
|
245
264
|
request_obj = reflect_request.ReflectRequest(
|
|
246
265
|
query=query,
|
|
247
266
|
budget=budget,
|
|
248
267
|
context=context,
|
|
268
|
+
max_tokens=max_tokens,
|
|
269
|
+
response_schema=response_schema,
|
|
249
270
|
)
|
|
250
271
|
|
|
251
272
|
return _run_async(self._memory_api.reflect(bank_id, request_obj))
|
|
@@ -303,24 +324,34 @@ class Hindsight:
|
|
|
303
324
|
|
|
304
325
|
Args:
|
|
305
326
|
bank_id: The memory bank ID
|
|
306
|
-
items: List of memory items with 'content' and optional 'timestamp', 'context', 'metadata', 'document_id'
|
|
327
|
+
items: List of memory items with 'content' and optional 'timestamp', 'context', 'metadata', 'document_id', 'entities'
|
|
307
328
|
document_id: Optional document ID for grouping memories (applied to items that don't have their own)
|
|
308
329
|
retain_async: If True, process asynchronously in background (default: False)
|
|
309
330
|
|
|
310
331
|
Returns:
|
|
311
332
|
RetainResponse with success status and item count
|
|
312
333
|
"""
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
334
|
+
from hindsight_client_api.models.entity_input import EntityInput
|
|
335
|
+
|
|
336
|
+
memory_items = []
|
|
337
|
+
for item in items:
|
|
338
|
+
entities = None
|
|
339
|
+
if item.get("entities"):
|
|
340
|
+
entities = [
|
|
341
|
+
EntityInput(text=e["text"], type=e.get("type"))
|
|
342
|
+
for e in item["entities"]
|
|
343
|
+
]
|
|
344
|
+
memory_items.append(
|
|
345
|
+
memory_item.MemoryItem(
|
|
346
|
+
content=item["content"],
|
|
347
|
+
timestamp=item.get("timestamp"),
|
|
348
|
+
context=item.get("context"),
|
|
349
|
+
metadata=item.get("metadata"),
|
|
350
|
+
# Use item's document_id if provided, otherwise fall back to batch-level document_id
|
|
351
|
+
document_id=item.get("document_id") or document_id,
|
|
352
|
+
entities=entities,
|
|
353
|
+
)
|
|
321
354
|
)
|
|
322
|
-
for item in items
|
|
323
|
-
]
|
|
324
355
|
|
|
325
356
|
request_obj = retain_request.RetainRequest(
|
|
326
357
|
items=memory_items,
|
|
@@ -337,6 +368,7 @@ class Hindsight:
|
|
|
337
368
|
context: Optional[str] = None,
|
|
338
369
|
document_id: Optional[str] = None,
|
|
339
370
|
metadata: Optional[Dict[str, str]] = None,
|
|
371
|
+
entities: Optional[List[Dict[str, str]]] = None,
|
|
340
372
|
) -> RetainResponse:
|
|
341
373
|
"""
|
|
342
374
|
Store a single memory (async).
|
|
@@ -348,13 +380,14 @@ class Hindsight:
|
|
|
348
380
|
context: Optional context description
|
|
349
381
|
document_id: Optional document ID for grouping
|
|
350
382
|
metadata: Optional user-defined metadata
|
|
383
|
+
entities: Optional list of entities [{"text": "...", "type": "..."}]
|
|
351
384
|
|
|
352
385
|
Returns:
|
|
353
386
|
RetainResponse with success status
|
|
354
387
|
"""
|
|
355
388
|
return await self.aretain_batch(
|
|
356
389
|
bank_id=bank_id,
|
|
357
|
-
items=[{"content": content, "timestamp": timestamp, "context": context, "metadata": metadata}],
|
|
390
|
+
items=[{"content": content, "timestamp": timestamp, "context": context, "metadata": metadata, "entities": entities}],
|
|
358
391
|
document_id=document_id,
|
|
359
392
|
)
|
|
360
393
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
# flake8: noqa
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Hindsight HTTP API
|
|
7
|
+
|
|
8
|
+
HTTP API for Hindsight
|
|
9
|
+
|
|
10
|
+
The version of the OpenAPI document: 0.1.0
|
|
11
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
12
|
+
|
|
13
|
+
Do not edit the class manually.
|
|
14
|
+
""" # noqa: E501
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__version__ = "0.0.7"
|
|
18
|
+
|
|
19
|
+
# import apis into sdk package
|
|
20
|
+
from hindsight_client_api.api.banks_api import BanksApi
|
|
21
|
+
from hindsight_client_api.api.documents_api import DocumentsApi
|
|
22
|
+
from hindsight_client_api.api.entities_api import EntitiesApi
|
|
23
|
+
from hindsight_client_api.api.memory_api import MemoryApi
|
|
24
|
+
from hindsight_client_api.api.monitoring_api import MonitoringApi
|
|
25
|
+
from hindsight_client_api.api.operations_api import OperationsApi
|
|
26
|
+
|
|
27
|
+
# import ApiClient
|
|
28
|
+
from hindsight_client_api.api_response import ApiResponse
|
|
29
|
+
from hindsight_client_api.api_client import ApiClient
|
|
30
|
+
from hindsight_client_api.configuration import Configuration
|
|
31
|
+
from hindsight_client_api.exceptions import OpenApiException
|
|
32
|
+
from hindsight_client_api.exceptions import ApiTypeError
|
|
33
|
+
from hindsight_client_api.exceptions import ApiValueError
|
|
34
|
+
from hindsight_client_api.exceptions import ApiKeyError
|
|
35
|
+
from hindsight_client_api.exceptions import ApiAttributeError
|
|
36
|
+
from hindsight_client_api.exceptions import ApiException
|
|
37
|
+
|
|
38
|
+
# import models into sdk package
|
|
39
|
+
from hindsight_client_api.models.add_background_request import AddBackgroundRequest
|
|
40
|
+
from hindsight_client_api.models.background_response import BackgroundResponse
|
|
41
|
+
from hindsight_client_api.models.bank_list_item import BankListItem
|
|
42
|
+
from hindsight_client_api.models.bank_list_response import BankListResponse
|
|
43
|
+
from hindsight_client_api.models.bank_profile_response import BankProfileResponse
|
|
44
|
+
from hindsight_client_api.models.bank_stats_response import BankStatsResponse
|
|
45
|
+
from hindsight_client_api.models.budget import Budget
|
|
46
|
+
from hindsight_client_api.models.cancel_operation_response import CancelOperationResponse
|
|
47
|
+
from hindsight_client_api.models.chunk_data import ChunkData
|
|
48
|
+
from hindsight_client_api.models.chunk_include_options import ChunkIncludeOptions
|
|
49
|
+
from hindsight_client_api.models.chunk_response import ChunkResponse
|
|
50
|
+
from hindsight_client_api.models.create_bank_request import CreateBankRequest
|
|
51
|
+
from hindsight_client_api.models.delete_document_response import DeleteDocumentResponse
|
|
52
|
+
from hindsight_client_api.models.delete_response import DeleteResponse
|
|
53
|
+
from hindsight_client_api.models.disposition_traits import DispositionTraits
|
|
54
|
+
from hindsight_client_api.models.document_response import DocumentResponse
|
|
55
|
+
from hindsight_client_api.models.entity_detail_response import EntityDetailResponse
|
|
56
|
+
from hindsight_client_api.models.entity_include_options import EntityIncludeOptions
|
|
57
|
+
from hindsight_client_api.models.entity_input import EntityInput
|
|
58
|
+
from hindsight_client_api.models.entity_list_item import EntityListItem
|
|
59
|
+
from hindsight_client_api.models.entity_list_response import EntityListResponse
|
|
60
|
+
from hindsight_client_api.models.entity_observation_response import EntityObservationResponse
|
|
61
|
+
from hindsight_client_api.models.entity_state_response import EntityStateResponse
|
|
62
|
+
from hindsight_client_api.models.graph_data_response import GraphDataResponse
|
|
63
|
+
from hindsight_client_api.models.http_validation_error import HTTPValidationError
|
|
64
|
+
from hindsight_client_api.models.include_options import IncludeOptions
|
|
65
|
+
from hindsight_client_api.models.list_documents_response import ListDocumentsResponse
|
|
66
|
+
from hindsight_client_api.models.list_memory_units_response import ListMemoryUnitsResponse
|
|
67
|
+
from hindsight_client_api.models.memory_item import MemoryItem
|
|
68
|
+
from hindsight_client_api.models.operation_response import OperationResponse
|
|
69
|
+
from hindsight_client_api.models.operations_list_response import OperationsListResponse
|
|
70
|
+
from hindsight_client_api.models.recall_request import RecallRequest
|
|
71
|
+
from hindsight_client_api.models.recall_response import RecallResponse
|
|
72
|
+
from hindsight_client_api.models.recall_result import RecallResult
|
|
73
|
+
from hindsight_client_api.models.reflect_fact import ReflectFact
|
|
74
|
+
from hindsight_client_api.models.reflect_include_options import ReflectIncludeOptions
|
|
75
|
+
from hindsight_client_api.models.reflect_request import ReflectRequest
|
|
76
|
+
from hindsight_client_api.models.reflect_response import ReflectResponse
|
|
77
|
+
from hindsight_client_api.models.retain_request import RetainRequest
|
|
78
|
+
from hindsight_client_api.models.retain_response import RetainResponse
|
|
79
|
+
from hindsight_client_api.models.update_disposition_request import UpdateDispositionRequest
|
|
80
|
+
from hindsight_client_api.models.validation_error import ValidationError
|
|
81
|
+
from hindsight_client_api.models.validation_error_loc_inner import ValidationErrorLocInner
|
|
@@ -21,7 +21,6 @@ import mimetypes
|
|
|
21
21
|
import os
|
|
22
22
|
import re
|
|
23
23
|
import tempfile
|
|
24
|
-
import uuid
|
|
25
24
|
|
|
26
25
|
from urllib.parse import quote
|
|
27
26
|
from typing import Tuple, Optional, List, Dict, Union
|
|
@@ -360,8 +359,6 @@ class ApiClient:
|
|
|
360
359
|
return obj.get_secret_value()
|
|
361
360
|
elif isinstance(obj, self.PRIMITIVE_TYPES):
|
|
362
361
|
return obj
|
|
363
|
-
elif isinstance(obj, uuid.UUID):
|
|
364
|
-
return str(obj)
|
|
365
362
|
elif isinstance(obj, list):
|
|
366
363
|
return [
|
|
367
364
|
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
|
|
@@ -388,10 +385,6 @@ class ApiClient:
|
|
|
388
385
|
else:
|
|
389
386
|
obj_dict = obj.__dict__
|
|
390
387
|
|
|
391
|
-
if isinstance(obj_dict, list):
|
|
392
|
-
# here we handle instances that can either be a list or something else, and only became a real list by calling to_dict()
|
|
393
|
-
return self.sanitize_for_serialization(obj_dict)
|
|
394
|
-
|
|
395
388
|
return {
|
|
396
389
|
key: self.sanitize_for_serialization(val)
|
|
397
390
|
for key, val in obj_dict.items()
|
|
@@ -414,7 +407,7 @@ class ApiClient:
|
|
|
414
407
|
data = json.loads(response_text)
|
|
415
408
|
except ValueError:
|
|
416
409
|
data = response_text
|
|
417
|
-
elif re.match(r'^application/(json|[\w
|
|
410
|
+
elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE):
|
|
418
411
|
if response_text == "":
|
|
419
412
|
data = ""
|
|
420
413
|
else:
|
|
@@ -463,13 +456,13 @@ class ApiClient:
|
|
|
463
456
|
|
|
464
457
|
if klass in self.PRIMITIVE_TYPES:
|
|
465
458
|
return self.__deserialize_primitive(data, klass)
|
|
466
|
-
elif klass
|
|
459
|
+
elif klass == object:
|
|
467
460
|
return self.__deserialize_object(data)
|
|
468
|
-
elif klass
|
|
461
|
+
elif klass == datetime.date:
|
|
469
462
|
return self.__deserialize_date(data)
|
|
470
|
-
elif klass
|
|
463
|
+
elif klass == datetime.datetime:
|
|
471
464
|
return self.__deserialize_datetime(data)
|
|
472
|
-
elif klass
|
|
465
|
+
elif klass == decimal.Decimal:
|
|
473
466
|
return decimal.Decimal(data)
|
|
474
467
|
elif issubclass(klass, Enum):
|
|
475
468
|
return self.__deserialize_enum(data, klass)
|
|
@@ -527,7 +520,7 @@ class ApiClient:
|
|
|
527
520
|
if k in collection_formats:
|
|
528
521
|
collection_format = collection_formats[k]
|
|
529
522
|
if collection_format == 'multi':
|
|
530
|
-
new_params.extend((k,
|
|
523
|
+
new_params.extend((k, str(value)) for value in v)
|
|
531
524
|
else:
|
|
532
525
|
if collection_format == 'ssv':
|
|
533
526
|
delimiter = ' '
|
|
@@ -17,7 +17,7 @@ import http.client as httplib
|
|
|
17
17
|
import logging
|
|
18
18
|
from logging import FileHandler
|
|
19
19
|
import sys
|
|
20
|
-
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict
|
|
20
|
+
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict
|
|
21
21
|
from typing_extensions import NotRequired, Self
|
|
22
22
|
|
|
23
23
|
import urllib3
|
|
@@ -159,10 +159,6 @@ class Configuration:
|
|
|
159
159
|
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
|
|
160
160
|
in PEM format.
|
|
161
161
|
:param retries: Number of retries for API requests.
|
|
162
|
-
:param ca_cert_data: verify the peer using concatenated CA certificate data
|
|
163
|
-
in PEM (str) or DER (bytes) format.
|
|
164
|
-
:param cert_file: the path to a client certificate file, for mTLS.
|
|
165
|
-
:param key_file: the path to a client key file, for mTLS.
|
|
166
162
|
|
|
167
163
|
"""
|
|
168
164
|
|
|
@@ -176,16 +172,13 @@ class Configuration:
|
|
|
176
172
|
username: Optional[str]=None,
|
|
177
173
|
password: Optional[str]=None,
|
|
178
174
|
access_token: Optional[str]=None,
|
|
179
|
-
server_index: Optional[int]=None,
|
|
175
|
+
server_index: Optional[int]=None,
|
|
180
176
|
server_variables: Optional[ServerVariablesT]=None,
|
|
181
177
|
server_operation_index: Optional[Dict[int, int]]=None,
|
|
182
178
|
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
|
|
183
179
|
ignore_operation_servers: bool=False,
|
|
184
180
|
ssl_ca_cert: Optional[str]=None,
|
|
185
181
|
retries: Optional[int] = None,
|
|
186
|
-
ca_cert_data: Optional[Union[str, bytes]] = None,
|
|
187
|
-
cert_file: Optional[str]=None,
|
|
188
|
-
key_file: Optional[str]=None,
|
|
189
182
|
*,
|
|
190
183
|
debug: Optional[bool] = None,
|
|
191
184
|
) -> None:
|
|
@@ -263,14 +256,10 @@ class Configuration:
|
|
|
263
256
|
self.ssl_ca_cert = ssl_ca_cert
|
|
264
257
|
"""Set this to customize the certificate file to verify the peer.
|
|
265
258
|
"""
|
|
266
|
-
self.
|
|
267
|
-
"""Set this to verify the peer using PEM (str) or DER (bytes)
|
|
268
|
-
certificate data.
|
|
269
|
-
"""
|
|
270
|
-
self.cert_file = cert_file
|
|
259
|
+
self.cert_file = None
|
|
271
260
|
"""client certificate file
|
|
272
261
|
"""
|
|
273
|
-
self.key_file =
|
|
262
|
+
self.key_file = None
|
|
274
263
|
"""client key file
|
|
275
264
|
"""
|
|
276
265
|
self.assert_hostname = None
|
|
@@ -150,13 +150,6 @@ class ApiException(OpenApiException):
|
|
|
150
150
|
if http_resp.status == 404:
|
|
151
151
|
raise NotFoundException(http_resp=http_resp, body=body, data=data)
|
|
152
152
|
|
|
153
|
-
# Added new conditions for 409 and 422
|
|
154
|
-
if http_resp.status == 409:
|
|
155
|
-
raise ConflictException(http_resp=http_resp, body=body, data=data)
|
|
156
|
-
|
|
157
|
-
if http_resp.status == 422:
|
|
158
|
-
raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
|
|
159
|
-
|
|
160
153
|
if 500 <= http_resp.status <= 599:
|
|
161
154
|
raise ServiceException(http_resp=http_resp, body=body, data=data)
|
|
162
155
|
raise ApiException(http_resp=http_resp, body=body, data=data)
|
|
@@ -169,11 +162,8 @@ class ApiException(OpenApiException):
|
|
|
169
162
|
error_message += "HTTP response headers: {0}\n".format(
|
|
170
163
|
self.headers)
|
|
171
164
|
|
|
172
|
-
if self.body:
|
|
173
|
-
error_message += "HTTP response body: {0}\n".format(self.body)
|
|
174
|
-
|
|
175
|
-
if self.data:
|
|
176
|
-
error_message += "HTTP response data: {0}\n".format(self.data)
|
|
165
|
+
if self.data or self.body:
|
|
166
|
+
error_message += "HTTP response body: {0}\n".format(self.data or self.body)
|
|
177
167
|
|
|
178
168
|
return error_message
|
|
179
169
|
|
|
@@ -198,16 +188,6 @@ class ServiceException(ApiException):
|
|
|
198
188
|
pass
|
|
199
189
|
|
|
200
190
|
|
|
201
|
-
class ConflictException(ApiException):
|
|
202
|
-
"""Exception for HTTP 409 Conflict."""
|
|
203
|
-
pass
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
class UnprocessableEntityException(ApiException):
|
|
207
|
-
"""Exception for HTTP 422 Unprocessable Entity."""
|
|
208
|
-
pass
|
|
209
|
-
|
|
210
|
-
|
|
211
191
|
def render_path(path_to_item):
|
|
212
192
|
"""Returns a string representation of a path"""
|
|
213
193
|
result = ""
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
Do not edit the class manually.
|
|
13
13
|
""" # noqa: E501
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
# import models into model package
|
|
16
17
|
from hindsight_client_api.models.add_background_request import AddBackgroundRequest
|
|
17
18
|
from hindsight_client_api.models.background_response import BackgroundResponse
|
|
@@ -31,6 +32,7 @@ from hindsight_client_api.models.disposition_traits import DispositionTraits
|
|
|
31
32
|
from hindsight_client_api.models.document_response import DocumentResponse
|
|
32
33
|
from hindsight_client_api.models.entity_detail_response import EntityDetailResponse
|
|
33
34
|
from hindsight_client_api.models.entity_include_options import EntityIncludeOptions
|
|
35
|
+
from hindsight_client_api.models.entity_input import EntityInput
|
|
34
36
|
from hindsight_client_api.models.entity_list_item import EntityListItem
|
|
35
37
|
from hindsight_client_api.models.entity_list_response import EntityListResponse
|
|
36
38
|
from hindsight_client_api.models.entity_observation_response import EntityObservationResponse
|
|
@@ -55,4 +57,3 @@ from hindsight_client_api.models.retain_response import RetainResponse
|
|
|
55
57
|
from hindsight_client_api.models.update_disposition_request import UpdateDispositionRequest
|
|
56
58
|
from hindsight_client_api.models.validation_error import ValidationError
|
|
57
59
|
from hindsight_client_api.models.validation_error_loc_inner import ValidationErrorLocInner
|
|
58
|
-
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Hindsight HTTP API
|
|
5
|
+
|
|
6
|
+
HTTP API for Hindsight
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class EntityInput(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
Entity to associate with retained content.
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
text: StrictStr = Field(description="The entity name/text")
|
|
30
|
+
type: Optional[StrictStr] = None
|
|
31
|
+
__properties: ClassVar[List[str]] = ["text", "type"]
|
|
32
|
+
|
|
33
|
+
model_config = ConfigDict(
|
|
34
|
+
populate_by_name=True,
|
|
35
|
+
validate_assignment=True,
|
|
36
|
+
protected_namespaces=(),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def to_str(self) -> str:
|
|
41
|
+
"""Returns the string representation of the model using alias"""
|
|
42
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
43
|
+
|
|
44
|
+
def to_json(self) -> str:
|
|
45
|
+
"""Returns the JSON representation of the model using alias"""
|
|
46
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
47
|
+
return json.dumps(self.to_dict())
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
51
|
+
"""Create an instance of EntityInput from a JSON string"""
|
|
52
|
+
return cls.from_dict(json.loads(json_str))
|
|
53
|
+
|
|
54
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
55
|
+
"""Return the dictionary representation of the model using alias.
|
|
56
|
+
|
|
57
|
+
This has the following differences from calling pydantic's
|
|
58
|
+
`self.model_dump(by_alias=True)`:
|
|
59
|
+
|
|
60
|
+
* `None` is only added to the output dict for nullable fields that
|
|
61
|
+
were set at model initialization. Other fields with value `None`
|
|
62
|
+
are ignored.
|
|
63
|
+
"""
|
|
64
|
+
excluded_fields: Set[str] = set([
|
|
65
|
+
])
|
|
66
|
+
|
|
67
|
+
_dict = self.model_dump(
|
|
68
|
+
by_alias=True,
|
|
69
|
+
exclude=excluded_fields,
|
|
70
|
+
exclude_none=True,
|
|
71
|
+
)
|
|
72
|
+
# set to None if type (nullable) is None
|
|
73
|
+
# and model_fields_set contains the field
|
|
74
|
+
if self.type is None and "type" in self.model_fields_set:
|
|
75
|
+
_dict['type'] = None
|
|
76
|
+
|
|
77
|
+
return _dict
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
81
|
+
"""Create an instance of EntityInput from a dict"""
|
|
82
|
+
if obj is None:
|
|
83
|
+
return None
|
|
84
|
+
|
|
85
|
+
if not isinstance(obj, dict):
|
|
86
|
+
return cls.model_validate(obj)
|
|
87
|
+
|
|
88
|
+
_obj = cls.model_validate({
|
|
89
|
+
"text": obj.get("text"),
|
|
90
|
+
"type": obj.get("type")
|
|
91
|
+
})
|
|
92
|
+
return _obj
|
|
93
|
+
|
|
94
|
+
|
{hindsight_client-0.1.16 → hindsight_client-0.2.1}/hindsight_client_api/models/memory_item.py
RENAMED
|
@@ -20,6 +20,7 @@ import json
|
|
|
20
20
|
from datetime import datetime
|
|
21
21
|
from pydantic import BaseModel, ConfigDict, StrictStr
|
|
22
22
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
23
|
+
from hindsight_client_api.models.entity_input import EntityInput
|
|
23
24
|
from typing import Optional, Set
|
|
24
25
|
from typing_extensions import Self
|
|
25
26
|
|
|
@@ -32,7 +33,8 @@ class MemoryItem(BaseModel):
|
|
|
32
33
|
context: Optional[StrictStr] = None
|
|
33
34
|
metadata: Optional[Dict[str, StrictStr]] = None
|
|
34
35
|
document_id: Optional[StrictStr] = None
|
|
35
|
-
|
|
36
|
+
entities: Optional[List[EntityInput]] = None
|
|
37
|
+
__properties: ClassVar[List[str]] = ["content", "timestamp", "context", "metadata", "document_id", "entities"]
|
|
36
38
|
|
|
37
39
|
model_config = ConfigDict(
|
|
38
40
|
populate_by_name=True,
|
|
@@ -73,6 +75,13 @@ class MemoryItem(BaseModel):
|
|
|
73
75
|
exclude=excluded_fields,
|
|
74
76
|
exclude_none=True,
|
|
75
77
|
)
|
|
78
|
+
# override the default output from pydantic by calling `to_dict()` of each item in entities (list)
|
|
79
|
+
_items = []
|
|
80
|
+
if self.entities:
|
|
81
|
+
for _item_entities in self.entities:
|
|
82
|
+
if _item_entities:
|
|
83
|
+
_items.append(_item_entities.to_dict())
|
|
84
|
+
_dict['entities'] = _items
|
|
76
85
|
# set to None if timestamp (nullable) is None
|
|
77
86
|
# and model_fields_set contains the field
|
|
78
87
|
if self.timestamp is None and "timestamp" in self.model_fields_set:
|
|
@@ -93,6 +102,11 @@ class MemoryItem(BaseModel):
|
|
|
93
102
|
if self.document_id is None and "document_id" in self.model_fields_set:
|
|
94
103
|
_dict['document_id'] = None
|
|
95
104
|
|
|
105
|
+
# set to None if entities (nullable) is None
|
|
106
|
+
# and model_fields_set contains the field
|
|
107
|
+
if self.entities is None and "entities" in self.model_fields_set:
|
|
108
|
+
_dict['entities'] = None
|
|
109
|
+
|
|
96
110
|
return _dict
|
|
97
111
|
|
|
98
112
|
@classmethod
|
|
@@ -109,7 +123,8 @@ class MemoryItem(BaseModel):
|
|
|
109
123
|
"timestamp": obj.get("timestamp"),
|
|
110
124
|
"context": obj.get("context"),
|
|
111
125
|
"metadata": obj.get("metadata"),
|
|
112
|
-
"document_id": obj.get("document_id")
|
|
126
|
+
"document_id": obj.get("document_id"),
|
|
127
|
+
"entities": [EntityInput.from_dict(_item) for _item in obj["entities"]] if obj.get("entities") is not None else None
|
|
113
128
|
})
|
|
114
129
|
return _obj
|
|
115
130
|
|