usecortex-ai 0.3.3__py3-none-any.whl → 0.3.5__py3-none-any.whl
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.
- usecortex_ai/__init__.py +16 -2
- usecortex_ai/search/client.py +36 -4
- usecortex_ai/search/raw_client.py +40 -8
- usecortex_ai/sources/client.py +97 -0
- usecortex_ai/sources/raw_client.py +273 -0
- usecortex_ai/types/__init__.py +16 -2
- usecortex_ai/types/add_user_memory_response.py +6 -1
- usecortex_ai/types/entity.py +42 -0
- usecortex_ai/types/extended_context.py +5 -2
- usecortex_ai/types/graph_relations_response.py +33 -0
- usecortex_ai/types/processing_status.py +6 -1
- usecortex_ai/types/relation_evidence.py +52 -0
- usecortex_ai/types/retrieve_mode.py +5 -0
- usecortex_ai/types/retrieve_response.py +34 -0
- usecortex_ai/types/retrieve_user_memory_response.py +6 -0
- usecortex_ai/types/search_chunk.py +6 -0
- usecortex_ai/types/{generate_user_memory_response.py → triple_with_evidence.py} +10 -7
- usecortex_ai/types/user_assistant_pair.py +27 -0
- usecortex_ai/types/webpage_scrape_request.py +27 -0
- usecortex_ai/upload/client.py +276 -0
- usecortex_ai/upload/raw_client.py +1179 -339
- usecortex_ai/user_memory/client.py +77 -149
- usecortex_ai/user_memory/raw_client.py +74 -329
- {usecortex_ai-0.3.3.dist-info → usecortex_ai-0.3.5.dist-info}/METADATA +1 -1
- {usecortex_ai-0.3.3.dist-info → usecortex_ai-0.3.5.dist-info}/RECORD +28 -21
- {usecortex_ai-0.3.3.dist-info → usecortex_ai-0.3.5.dist-info}/WHEEL +0 -0
- {usecortex_ai-0.3.3.dist-info → usecortex_ai-0.3.5.dist-info}/licenses/LICENSE +0 -0
- {usecortex_ai-0.3.3.dist-info → usecortex_ai-0.3.5.dist-info}/top_level.txt +0 -0
|
@@ -6,9 +6,9 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
|
6
6
|
from ..core.request_options import RequestOptions
|
|
7
7
|
from ..types.add_user_memory_response import AddUserMemoryResponse
|
|
8
8
|
from ..types.delete_user_memory_response import DeleteUserMemoryResponse
|
|
9
|
-
from ..types.generate_user_memory_response import GenerateUserMemoryResponse
|
|
10
9
|
from ..types.list_user_memories_response import ListUserMemoriesResponse
|
|
11
10
|
from ..types.retrieve_user_memory_response import RetrieveUserMemoryResponse
|
|
11
|
+
from ..types.user_assistant_pair import UserAssistantPair
|
|
12
12
|
from .raw_client import AsyncRawUserMemoryClient, RawUserMemoryClient
|
|
13
13
|
|
|
14
14
|
# this is used as the default value for optional parameters
|
|
@@ -133,14 +133,14 @@ class UserMemoryClient:
|
|
|
133
133
|
request_options: typing.Optional[RequestOptions] = None,
|
|
134
134
|
) -> RetrieveUserMemoryResponse:
|
|
135
135
|
"""
|
|
136
|
-
Find relevant user memories using semantic search.
|
|
136
|
+
Find relevant user memories using semantic search and knowledge graph.
|
|
137
137
|
|
|
138
|
-
This endpoint performs
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
This endpoint performs parallel searches:
|
|
139
|
+
1. Semantic search in Weaviate across all stored user memories
|
|
140
|
+
2. Entity-based search in the knowledge graph for memory entities
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
Results from both sources are combined and ranked by relevance to provide
|
|
143
|
+
comprehensive memory retrieval.
|
|
144
144
|
|
|
145
145
|
Parameters
|
|
146
146
|
----------
|
|
@@ -184,91 +184,50 @@ class UserMemoryClient:
|
|
|
184
184
|
)
|
|
185
185
|
return _response.data
|
|
186
186
|
|
|
187
|
-
def
|
|
187
|
+
def add_user_memory(
|
|
188
188
|
self,
|
|
189
189
|
*,
|
|
190
190
|
tenant_id: str,
|
|
191
|
-
user_message: str,
|
|
192
|
-
user_name: str,
|
|
193
191
|
sub_tenant_id: typing.Optional[str] = None,
|
|
192
|
+
raw_text: typing.Optional[str] = OMIT,
|
|
193
|
+
user_assistant_pairs: typing.Optional[typing.Sequence[UserAssistantPair]] = OMIT,
|
|
194
|
+
expiry_time: typing.Optional[int] = OMIT,
|
|
195
|
+
infer: typing.Optional[bool] = OMIT,
|
|
196
|
+
custom_instructions: typing.Optional[str] = OMIT,
|
|
194
197
|
request_options: typing.Optional[RequestOptions] = None,
|
|
195
|
-
) ->
|
|
198
|
+
) -> AddUserMemoryResponse:
|
|
196
199
|
"""
|
|
197
|
-
|
|
200
|
+
Store new user memories for future reference.
|
|
198
201
|
|
|
199
|
-
This endpoint
|
|
200
|
-
|
|
201
|
-
|
|
202
|
+
This endpoint allows you to add memories in two formats:
|
|
203
|
+
1. Raw text string - A single text-based memory
|
|
204
|
+
2. User/Assistant pairs array - Conversation pairs that will be chunked as a single memory
|
|
202
205
|
|
|
203
|
-
|
|
204
|
-
|
|
206
|
+
The stored memories will be chunked, indexed in both Weaviate and the knowledge graph,
|
|
207
|
+
and made available for semantic search and graph-based retrieval.
|
|
205
208
|
|
|
206
209
|
Parameters
|
|
207
210
|
----------
|
|
208
211
|
tenant_id : str
|
|
209
212
|
Unique identifier for the tenant/organization
|
|
210
213
|
|
|
211
|
-
user_message : str
|
|
212
|
-
Your query or context for AI memory generation
|
|
213
|
-
|
|
214
|
-
user_name : str
|
|
215
|
-
Your name to personalize the generated memories
|
|
216
|
-
|
|
217
214
|
sub_tenant_id : typing.Optional[str]
|
|
218
215
|
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
219
216
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
Returns
|
|
224
|
-
-------
|
|
225
|
-
GenerateUserMemoryResponse
|
|
226
|
-
Successful Response
|
|
227
|
-
|
|
228
|
-
Examples
|
|
229
|
-
--------
|
|
230
|
-
from usecortex-ai import CortexAI
|
|
231
|
-
|
|
232
|
-
client = CortexAI(token="YOUR_TOKEN", )
|
|
233
|
-
client.user_memory.generate_user_memory(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567', user_message='I prefer detailed technical explanations and works in the Pacific timezone', user_name='John Doe', )
|
|
234
|
-
"""
|
|
235
|
-
_response = self._raw_client.generate_user_memory(
|
|
236
|
-
tenant_id=tenant_id,
|
|
237
|
-
user_message=user_message,
|
|
238
|
-
user_name=user_name,
|
|
239
|
-
sub_tenant_id=sub_tenant_id,
|
|
240
|
-
request_options=request_options,
|
|
241
|
-
)
|
|
242
|
-
return _response.data
|
|
243
|
-
|
|
244
|
-
def add_user_memory(
|
|
245
|
-
self,
|
|
246
|
-
*,
|
|
247
|
-
tenant_id: str,
|
|
248
|
-
user_memory: str,
|
|
249
|
-
sub_tenant_id: typing.Optional[str] = None,
|
|
250
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
251
|
-
) -> AddUserMemoryResponse:
|
|
252
|
-
"""
|
|
253
|
-
Store a new user memory for future reference.
|
|
254
|
-
|
|
255
|
-
This endpoint allows you to manually add a memory that will be stored and
|
|
256
|
-
can be retrieved later through memory search. Use this to save important
|
|
257
|
-
preferences, context, or information that you want the system to remember.
|
|
217
|
+
raw_text : typing.Optional[str]
|
|
218
|
+
Single raw text memory to store
|
|
258
219
|
|
|
259
|
-
|
|
260
|
-
|
|
220
|
+
user_assistant_pairs : typing.Optional[typing.Sequence[UserAssistantPair]]
|
|
221
|
+
Array of user/assistant conversation pairs to store as a single memory
|
|
261
222
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
tenant_id : str
|
|
265
|
-
Unique identifier for the tenant/organization
|
|
223
|
+
expiry_time : typing.Optional[int]
|
|
224
|
+
Expiry time in seconds for the memory (optional)
|
|
266
225
|
|
|
267
|
-
|
|
268
|
-
|
|
226
|
+
infer : typing.Optional[bool]
|
|
227
|
+
If true, process and compress chunks into inferred representations before indexing (default: False)
|
|
269
228
|
|
|
270
|
-
|
|
271
|
-
|
|
229
|
+
custom_instructions : typing.Optional[str]
|
|
230
|
+
Custom instructions to guide cortex
|
|
272
231
|
|
|
273
232
|
request_options : typing.Optional[RequestOptions]
|
|
274
233
|
Request-specific configuration.
|
|
@@ -283,10 +242,17 @@ class UserMemoryClient:
|
|
|
283
242
|
from usecortex-ai import CortexAI
|
|
284
243
|
|
|
285
244
|
client = CortexAI(token="YOUR_TOKEN", )
|
|
286
|
-
client.user_memory.add_user_memory(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567',
|
|
245
|
+
client.user_memory.add_user_memory(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567', )
|
|
287
246
|
"""
|
|
288
247
|
_response = self._raw_client.add_user_memory(
|
|
289
|
-
tenant_id=tenant_id,
|
|
248
|
+
tenant_id=tenant_id,
|
|
249
|
+
sub_tenant_id=sub_tenant_id,
|
|
250
|
+
raw_text=raw_text,
|
|
251
|
+
user_assistant_pairs=user_assistant_pairs,
|
|
252
|
+
expiry_time=expiry_time,
|
|
253
|
+
infer=infer,
|
|
254
|
+
custom_instructions=custom_instructions,
|
|
255
|
+
request_options=request_options,
|
|
290
256
|
)
|
|
291
257
|
return _response.data
|
|
292
258
|
|
|
@@ -417,14 +383,14 @@ class AsyncUserMemoryClient:
|
|
|
417
383
|
request_options: typing.Optional[RequestOptions] = None,
|
|
418
384
|
) -> RetrieveUserMemoryResponse:
|
|
419
385
|
"""
|
|
420
|
-
Find relevant user memories using semantic search.
|
|
386
|
+
Find relevant user memories using semantic search and knowledge graph.
|
|
421
387
|
|
|
422
|
-
This endpoint performs
|
|
423
|
-
|
|
424
|
-
|
|
388
|
+
This endpoint performs parallel searches:
|
|
389
|
+
1. Semantic search in Weaviate across all stored user memories
|
|
390
|
+
2. Entity-based search in the knowledge graph for memory entities
|
|
425
391
|
|
|
426
|
-
|
|
427
|
-
|
|
392
|
+
Results from both sources are combined and ranked by relevance to provide
|
|
393
|
+
comprehensive memory retrieval.
|
|
428
394
|
|
|
429
395
|
Parameters
|
|
430
396
|
----------
|
|
@@ -472,95 +438,50 @@ class AsyncUserMemoryClient:
|
|
|
472
438
|
)
|
|
473
439
|
return _response.data
|
|
474
440
|
|
|
475
|
-
async def
|
|
441
|
+
async def add_user_memory(
|
|
476
442
|
self,
|
|
477
443
|
*,
|
|
478
444
|
tenant_id: str,
|
|
479
|
-
user_message: str,
|
|
480
|
-
user_name: str,
|
|
481
445
|
sub_tenant_id: typing.Optional[str] = None,
|
|
446
|
+
raw_text: typing.Optional[str] = OMIT,
|
|
447
|
+
user_assistant_pairs: typing.Optional[typing.Sequence[UserAssistantPair]] = OMIT,
|
|
448
|
+
expiry_time: typing.Optional[int] = OMIT,
|
|
449
|
+
infer: typing.Optional[bool] = OMIT,
|
|
450
|
+
custom_instructions: typing.Optional[str] = OMIT,
|
|
482
451
|
request_options: typing.Optional[RequestOptions] = None,
|
|
483
|
-
) ->
|
|
452
|
+
) -> AddUserMemoryResponse:
|
|
484
453
|
"""
|
|
485
|
-
|
|
454
|
+
Store new user memories for future reference.
|
|
486
455
|
|
|
487
|
-
This endpoint
|
|
488
|
-
|
|
489
|
-
|
|
456
|
+
This endpoint allows you to add memories in two formats:
|
|
457
|
+
1. Raw text string - A single text-based memory
|
|
458
|
+
2. User/Assistant pairs array - Conversation pairs that will be chunked as a single memory
|
|
490
459
|
|
|
491
|
-
|
|
492
|
-
|
|
460
|
+
The stored memories will be chunked, indexed in both Weaviate and the knowledge graph,
|
|
461
|
+
and made available for semantic search and graph-based retrieval.
|
|
493
462
|
|
|
494
463
|
Parameters
|
|
495
464
|
----------
|
|
496
465
|
tenant_id : str
|
|
497
466
|
Unique identifier for the tenant/organization
|
|
498
467
|
|
|
499
|
-
user_message : str
|
|
500
|
-
Your query or context for AI memory generation
|
|
501
|
-
|
|
502
|
-
user_name : str
|
|
503
|
-
Your name to personalize the generated memories
|
|
504
|
-
|
|
505
468
|
sub_tenant_id : typing.Optional[str]
|
|
506
469
|
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
|
|
507
470
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
Returns
|
|
512
|
-
-------
|
|
513
|
-
GenerateUserMemoryResponse
|
|
514
|
-
Successful Response
|
|
515
|
-
|
|
516
|
-
Examples
|
|
517
|
-
--------
|
|
518
|
-
import asyncio
|
|
519
|
-
|
|
520
|
-
from usecortex-ai import AsyncCortexAI
|
|
521
|
-
|
|
522
|
-
client = AsyncCortexAI(token="YOUR_TOKEN", )
|
|
523
|
-
async def main() -> None:
|
|
524
|
-
await client.user_memory.generate_user_memory(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567', user_message='I prefer detailed technical explanations and works in the Pacific timezone', user_name='John Doe', )
|
|
525
|
-
asyncio.run(main())
|
|
526
|
-
"""
|
|
527
|
-
_response = await self._raw_client.generate_user_memory(
|
|
528
|
-
tenant_id=tenant_id,
|
|
529
|
-
user_message=user_message,
|
|
530
|
-
user_name=user_name,
|
|
531
|
-
sub_tenant_id=sub_tenant_id,
|
|
532
|
-
request_options=request_options,
|
|
533
|
-
)
|
|
534
|
-
return _response.data
|
|
535
|
-
|
|
536
|
-
async def add_user_memory(
|
|
537
|
-
self,
|
|
538
|
-
*,
|
|
539
|
-
tenant_id: str,
|
|
540
|
-
user_memory: str,
|
|
541
|
-
sub_tenant_id: typing.Optional[str] = None,
|
|
542
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
543
|
-
) -> AddUserMemoryResponse:
|
|
544
|
-
"""
|
|
545
|
-
Store a new user memory for future reference.
|
|
546
|
-
|
|
547
|
-
This endpoint allows you to manually add a memory that will be stored and
|
|
548
|
-
can be retrieved later through memory search. Use this to save important
|
|
549
|
-
preferences, context, or information that you want the system to remember.
|
|
471
|
+
raw_text : typing.Optional[str]
|
|
472
|
+
Single raw text memory to store
|
|
550
473
|
|
|
551
|
-
|
|
552
|
-
|
|
474
|
+
user_assistant_pairs : typing.Optional[typing.Sequence[UserAssistantPair]]
|
|
475
|
+
Array of user/assistant conversation pairs to store as a single memory
|
|
553
476
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
tenant_id : str
|
|
557
|
-
Unique identifier for the tenant/organization
|
|
477
|
+
expiry_time : typing.Optional[int]
|
|
478
|
+
Expiry time in seconds for the memory (optional)
|
|
558
479
|
|
|
559
|
-
|
|
560
|
-
|
|
480
|
+
infer : typing.Optional[bool]
|
|
481
|
+
If true, process and compress chunks into inferred representations before indexing (default: False)
|
|
561
482
|
|
|
562
|
-
|
|
563
|
-
|
|
483
|
+
custom_instructions : typing.Optional[str]
|
|
484
|
+
Custom instructions to guide cortex
|
|
564
485
|
|
|
565
486
|
request_options : typing.Optional[RequestOptions]
|
|
566
487
|
Request-specific configuration.
|
|
@@ -578,10 +499,17 @@ class AsyncUserMemoryClient:
|
|
|
578
499
|
|
|
579
500
|
client = AsyncCortexAI(token="YOUR_TOKEN", )
|
|
580
501
|
async def main() -> None:
|
|
581
|
-
await client.user_memory.add_user_memory(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567',
|
|
502
|
+
await client.user_memory.add_user_memory(tenant_id='tenant_1234', sub_tenant_id='sub_tenant_4567', )
|
|
582
503
|
asyncio.run(main())
|
|
583
504
|
"""
|
|
584
505
|
_response = await self._raw_client.add_user_memory(
|
|
585
|
-
tenant_id=tenant_id,
|
|
506
|
+
tenant_id=tenant_id,
|
|
507
|
+
sub_tenant_id=sub_tenant_id,
|
|
508
|
+
raw_text=raw_text,
|
|
509
|
+
user_assistant_pairs=user_assistant_pairs,
|
|
510
|
+
expiry_time=expiry_time,
|
|
511
|
+
infer=infer,
|
|
512
|
+
custom_instructions=custom_instructions,
|
|
513
|
+
request_options=request_options,
|
|
586
514
|
)
|
|
587
515
|
return _response.data
|