usecortex-ai 0.4.0__py3-none-any.whl → 0.5.1__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.
Files changed (38) hide show
  1. usecortex_ai/__init__.py +10 -4
  2. usecortex_ai/client.py +0 -4
  3. usecortex_ai/dashboard/client.py +2 -30
  4. usecortex_ai/dashboard/raw_client.py +0 -28
  5. usecortex_ai/embeddings/client.py +8 -58
  6. usecortex_ai/embeddings/raw_client.py +8 -58
  7. usecortex_ai/fetch/__init__.py +3 -0
  8. usecortex_ai/fetch/client.py +42 -165
  9. usecortex_ai/fetch/raw_client.py +38 -341
  10. usecortex_ai/fetch/types/__init__.py +7 -0
  11. usecortex_ai/fetch/types/fetch_list_knowledge_response.py +8 -0
  12. usecortex_ai/raw_client.py +0 -4
  13. usecortex_ai/search/client.py +40 -108
  14. usecortex_ai/search/raw_client.py +40 -108
  15. usecortex_ai/sources/client.py +2 -16
  16. usecortex_ai/sources/raw_client.py +2 -16
  17. usecortex_ai/tenant/client.py +4 -108
  18. usecortex_ai/tenant/raw_client.py +2 -106
  19. usecortex_ai/types/__init__.py +8 -2
  20. usecortex_ai/types/forceful_relations_payload.py +27 -0
  21. usecortex_ai/types/list_content_kind.py +5 -0
  22. usecortex_ai/types/list_user_memories_response.py +32 -0
  23. usecortex_ai/types/memory_item.py +7 -1
  24. usecortex_ai/types/retrieval_result.py +4 -0
  25. usecortex_ai/types/retrieve_mode.py +1 -1
  26. usecortex_ai/types/user_memory.py +31 -0
  27. usecortex_ai/types/vector_store_chunk.py +5 -0
  28. usecortex_ai/upload/__init__.py +0 -3
  29. usecortex_ai/upload/client.py +34 -204
  30. usecortex_ai/upload/raw_client.py +30 -382
  31. {usecortex_ai-0.4.0.dist-info → usecortex_ai-0.5.1.dist-info}/METADATA +1 -1
  32. {usecortex_ai-0.4.0.dist-info → usecortex_ai-0.5.1.dist-info}/RECORD +35 -32
  33. {usecortex_ai-0.4.0.dist-info → usecortex_ai-0.5.1.dist-info}/WHEEL +1 -1
  34. usecortex_ai/types/app_sources_upload_data.py +0 -39
  35. usecortex_ai/upload/types/__init__.py +0 -7
  36. usecortex_ai/upload/types/body_upload_app_ingestion_upload_app_post_app_sources.py +0 -7
  37. {usecortex_ai-0.4.0.dist-info → usecortex_ai-0.5.1.dist-info}/licenses/LICENSE +0 -0
  38. {usecortex_ai-0.4.0.dist-info → usecortex_ai-0.5.1.dist-info}/top_level.txt +0 -0
@@ -16,9 +16,10 @@ from ..errors.service_unavailable_error import ServiceUnavailableError
16
16
  from ..errors.unauthorized_error import UnauthorizedError
17
17
  from ..errors.unprocessable_entity_error import UnprocessableEntityError
18
18
  from ..types.fetch_mode import FetchMode
19
+ from ..types.list_content_kind import ListContentKind
19
20
  from ..types.source_fetch_response import SourceFetchResponse
20
21
  from ..types.source_graph_relations_response import SourceGraphRelationsResponse
21
- from ..types.source_list_response import SourceListResponse
22
+ from .types.fetch_list_knowledge_response import FetchListKnowledgeResponse
22
23
 
23
24
  # this is used as the default value for optional parameters
24
25
  OMIT = typing.cast(typing.Any, ...)
@@ -28,184 +29,46 @@ class RawFetchClient:
28
29
  def __init__(self, *, client_wrapper: SyncClientWrapper):
29
30
  self._client_wrapper = client_wrapper
30
31
 
31
- def sources(
32
+ def list_knowledge(
32
33
  self,
33
34
  *,
34
35
  tenant_id: str,
35
- sub_tenant_id: typing.Optional[str] = None,
36
- request_options: typing.Optional[RequestOptions] = None,
37
- ) -> HttpResponse[SourceListResponse]:
38
- """
39
- Retrieve all sources for a specific tenant and subtenant combination.
40
-
41
- Use this endpoint to fetch a complete list of all sources associated
42
- with your tenant. This includes documents, files, and other content
43
- you've uploaded for processing.
44
-
45
- You can optionally specify a sub-tenant to narrow down the results to
46
- sources within that specific sub-tenant scope.
47
-
48
- Parameters
49
- ----------
50
- tenant_id : str
51
- Unique identifier for the tenant/organization
52
-
53
- sub_tenant_id : typing.Optional[str]
54
- Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
55
-
56
- request_options : typing.Optional[RequestOptions]
57
- Request-specific configuration.
58
-
59
- Returns
60
- -------
61
- HttpResponse[SourceListResponse]
62
- Successful Response
63
- """
64
- _response = self._client_wrapper.httpx_client.request(
65
- "list/list-sources",
66
- method="GET",
67
- params={
68
- "tenant_id": tenant_id,
69
- "sub_tenant_id": sub_tenant_id,
70
- },
71
- request_options=request_options,
72
- )
73
- try:
74
- if 200 <= _response.status_code < 300:
75
- _data = typing.cast(
76
- SourceListResponse,
77
- parse_obj_as(
78
- type_=SourceListResponse, # type: ignore
79
- object_=_response.json(),
80
- ),
81
- )
82
- return HttpResponse(response=_response, data=_data)
83
- if _response.status_code == 400:
84
- raise BadRequestError(
85
- headers=dict(_response.headers),
86
- body=typing.cast(
87
- typing.Optional[typing.Any],
88
- parse_obj_as(
89
- type_=typing.Optional[typing.Any], # type: ignore
90
- object_=_response.json(),
91
- ),
92
- ),
93
- )
94
- if _response.status_code == 401:
95
- raise UnauthorizedError(
96
- headers=dict(_response.headers),
97
- body=typing.cast(
98
- typing.Optional[typing.Any],
99
- parse_obj_as(
100
- type_=typing.Optional[typing.Any], # type: ignore
101
- object_=_response.json(),
102
- ),
103
- ),
104
- )
105
- if _response.status_code == 403:
106
- raise ForbiddenError(
107
- headers=dict(_response.headers),
108
- body=typing.cast(
109
- typing.Optional[typing.Any],
110
- parse_obj_as(
111
- type_=typing.Optional[typing.Any], # type: ignore
112
- object_=_response.json(),
113
- ),
114
- ),
115
- )
116
- if _response.status_code == 404:
117
- raise NotFoundError(
118
- headers=dict(_response.headers),
119
- body=typing.cast(
120
- typing.Optional[typing.Any],
121
- parse_obj_as(
122
- type_=typing.Optional[typing.Any], # type: ignore
123
- object_=_response.json(),
124
- ),
125
- ),
126
- )
127
- if _response.status_code == 422:
128
- raise UnprocessableEntityError(
129
- headers=dict(_response.headers),
130
- body=typing.cast(
131
- typing.Optional[typing.Any],
132
- parse_obj_as(
133
- type_=typing.Optional[typing.Any], # type: ignore
134
- object_=_response.json(),
135
- ),
136
- ),
137
- )
138
- if _response.status_code == 500:
139
- raise InternalServerError(
140
- headers=dict(_response.headers),
141
- body=typing.cast(
142
- typing.Optional[typing.Any],
143
- parse_obj_as(
144
- type_=typing.Optional[typing.Any], # type: ignore
145
- object_=_response.json(),
146
- ),
147
- ),
148
- )
149
- if _response.status_code == 503:
150
- raise ServiceUnavailableError(
151
- headers=dict(_response.headers),
152
- body=typing.cast(
153
- typing.Optional[typing.Any],
154
- parse_obj_as(
155
- type_=typing.Optional[typing.Any], # type: ignore
156
- object_=_response.json(),
157
- ),
158
- ),
159
- )
160
- _response_json = _response.json()
161
- except JSONDecodeError:
162
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
163
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
164
-
165
- def source_by_ids(
166
- self,
167
- *,
168
- source_ids: typing.Sequence[str],
169
- tenant_id: str,
170
36
  sub_tenant_id: typing.Optional[str] = OMIT,
37
+ kind: typing.Optional[ListContentKind] = OMIT,
38
+ source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
171
39
  request_options: typing.Optional[RequestOptions] = None,
172
- ) -> HttpResponse[SourceListResponse]:
40
+ ) -> HttpResponse[FetchListKnowledgeResponse]:
173
41
  """
174
- Retrieve specific sources by their IDs.
175
-
176
- Use this endpoint to fetch one or more sources by providing their
177
- unique identifiers. This is useful when you need detailed information
178
- about specific documents or content you've previously uploaded.
179
-
180
- Provide the source IDs in the request body along with your tenant
181
- information to get the exact sources you need.
182
-
183
42
  Parameters
184
43
  ----------
185
- source_ids : typing.Sequence[str]
186
- List of source IDs to fetch.
187
-
188
44
  tenant_id : str
189
45
  Tenant ID
190
46
 
191
47
  sub_tenant_id : typing.Optional[str]
192
48
  Sub-tenant ID
193
49
 
50
+ kind : typing.Optional[ListContentKind]
51
+ Whether to list normal sources or user memories.
52
+
53
+ source_ids : typing.Optional[typing.Sequence[str]]
54
+ Optional list of IDs to fetch. If omitted, returns all.
55
+
194
56
  request_options : typing.Optional[RequestOptions]
195
57
  Request-specific configuration.
196
58
 
197
59
  Returns
198
60
  -------
199
- HttpResponse[SourceListResponse]
61
+ HttpResponse[FetchListKnowledgeResponse]
200
62
  Successful Response
201
63
  """
202
64
  _response = self._client_wrapper.httpx_client.request(
203
- "list/list-sources-by-id",
65
+ "list/data",
204
66
  method="POST",
205
67
  json={
206
- "source_ids": source_ids,
207
68
  "tenant_id": tenant_id,
208
69
  "sub_tenant_id": sub_tenant_id,
70
+ "kind": kind,
71
+ "source_ids": source_ids,
209
72
  },
210
73
  headers={
211
74
  "content-type": "application/json",
@@ -216,9 +79,9 @@ class RawFetchClient:
216
79
  try:
217
80
  if 200 <= _response.status_code < 300:
218
81
  _data = typing.cast(
219
- SourceListResponse,
82
+ FetchListKnowledgeResponse,
220
83
  parse_obj_as(
221
- type_=SourceListResponse, # type: ignore
84
+ type_=FetchListKnowledgeResponse, # type: ignore
222
85
  object_=_response.json(),
223
86
  ),
224
87
  )
@@ -314,13 +177,6 @@ class RawFetchClient:
314
177
  request_options: typing.Optional[RequestOptions] = None,
315
178
  ) -> HttpResponse[SourceGraphRelationsResponse]:
316
179
  """
317
- Retrieve relations for a specific source.
318
-
319
- Use this endpoint to fetch all relations associated with a specific source.
320
- This is useful when you need to understand the relationships between entities within a source.
321
-
322
- Provide the source ID in the request body along with your tenant information to get the relations for that source.
323
-
324
180
  Parameters
325
181
  ----------
326
182
  source_id : str
@@ -341,7 +197,7 @@ class RawFetchClient:
341
197
  Successful Response
342
198
  """
343
199
  _response = self._client_wrapper.httpx_client.request(
344
- "list/graph-relations-by-id",
200
+ "list/graph_relations_by_id",
345
201
  method="GET",
346
202
  params={
347
203
  "source_id": source_id,
@@ -453,13 +309,6 @@ class RawFetchClient:
453
309
  request_options: typing.Optional[RequestOptions] = None,
454
310
  ) -> HttpResponse[SourceFetchResponse]:
455
311
  """
456
- Fetch the content of a source ingested.
457
-
458
- This endpoint can return:
459
- - File content directly (as string or base64)
460
- - A presigned URL to access the file
461
- - Both content and presigned URL
462
-
463
312
  Parameters
464
313
  ----------
465
314
  tenant_id : str
@@ -486,7 +335,7 @@ class RawFetchClient:
486
335
  Successful Response
487
336
  """
488
337
  _response = self._client_wrapper.httpx_client.request(
489
- "fetch/fetch-source-content",
338
+ "fetch/content",
490
339
  method="POST",
491
340
  json={
492
341
  "tenant_id": tenant_id,
@@ -598,184 +447,46 @@ class AsyncRawFetchClient:
598
447
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
599
448
  self._client_wrapper = client_wrapper
600
449
 
601
- async def sources(
450
+ async def list_knowledge(
602
451
  self,
603
452
  *,
604
453
  tenant_id: str,
605
- sub_tenant_id: typing.Optional[str] = None,
606
- request_options: typing.Optional[RequestOptions] = None,
607
- ) -> AsyncHttpResponse[SourceListResponse]:
608
- """
609
- Retrieve all sources for a specific tenant and subtenant combination.
610
-
611
- Use this endpoint to fetch a complete list of all sources associated
612
- with your tenant. This includes documents, files, and other content
613
- you've uploaded for processing.
614
-
615
- You can optionally specify a sub-tenant to narrow down the results to
616
- sources within that specific sub-tenant scope.
617
-
618
- Parameters
619
- ----------
620
- tenant_id : str
621
- Unique identifier for the tenant/organization
622
-
623
- sub_tenant_id : typing.Optional[str]
624
- Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
625
-
626
- request_options : typing.Optional[RequestOptions]
627
- Request-specific configuration.
628
-
629
- Returns
630
- -------
631
- AsyncHttpResponse[SourceListResponse]
632
- Successful Response
633
- """
634
- _response = await self._client_wrapper.httpx_client.request(
635
- "list/list-sources",
636
- method="GET",
637
- params={
638
- "tenant_id": tenant_id,
639
- "sub_tenant_id": sub_tenant_id,
640
- },
641
- request_options=request_options,
642
- )
643
- try:
644
- if 200 <= _response.status_code < 300:
645
- _data = typing.cast(
646
- SourceListResponse,
647
- parse_obj_as(
648
- type_=SourceListResponse, # type: ignore
649
- object_=_response.json(),
650
- ),
651
- )
652
- return AsyncHttpResponse(response=_response, data=_data)
653
- if _response.status_code == 400:
654
- raise BadRequestError(
655
- headers=dict(_response.headers),
656
- body=typing.cast(
657
- typing.Optional[typing.Any],
658
- parse_obj_as(
659
- type_=typing.Optional[typing.Any], # type: ignore
660
- object_=_response.json(),
661
- ),
662
- ),
663
- )
664
- if _response.status_code == 401:
665
- raise UnauthorizedError(
666
- headers=dict(_response.headers),
667
- body=typing.cast(
668
- typing.Optional[typing.Any],
669
- parse_obj_as(
670
- type_=typing.Optional[typing.Any], # type: ignore
671
- object_=_response.json(),
672
- ),
673
- ),
674
- )
675
- if _response.status_code == 403:
676
- raise ForbiddenError(
677
- headers=dict(_response.headers),
678
- body=typing.cast(
679
- typing.Optional[typing.Any],
680
- parse_obj_as(
681
- type_=typing.Optional[typing.Any], # type: ignore
682
- object_=_response.json(),
683
- ),
684
- ),
685
- )
686
- if _response.status_code == 404:
687
- raise NotFoundError(
688
- headers=dict(_response.headers),
689
- body=typing.cast(
690
- typing.Optional[typing.Any],
691
- parse_obj_as(
692
- type_=typing.Optional[typing.Any], # type: ignore
693
- object_=_response.json(),
694
- ),
695
- ),
696
- )
697
- if _response.status_code == 422:
698
- raise UnprocessableEntityError(
699
- headers=dict(_response.headers),
700
- body=typing.cast(
701
- typing.Optional[typing.Any],
702
- parse_obj_as(
703
- type_=typing.Optional[typing.Any], # type: ignore
704
- object_=_response.json(),
705
- ),
706
- ),
707
- )
708
- if _response.status_code == 500:
709
- raise InternalServerError(
710
- headers=dict(_response.headers),
711
- body=typing.cast(
712
- typing.Optional[typing.Any],
713
- parse_obj_as(
714
- type_=typing.Optional[typing.Any], # type: ignore
715
- object_=_response.json(),
716
- ),
717
- ),
718
- )
719
- if _response.status_code == 503:
720
- raise ServiceUnavailableError(
721
- headers=dict(_response.headers),
722
- body=typing.cast(
723
- typing.Optional[typing.Any],
724
- parse_obj_as(
725
- type_=typing.Optional[typing.Any], # type: ignore
726
- object_=_response.json(),
727
- ),
728
- ),
729
- )
730
- _response_json = _response.json()
731
- except JSONDecodeError:
732
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
733
- raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
734
-
735
- async def source_by_ids(
736
- self,
737
- *,
738
- source_ids: typing.Sequence[str],
739
- tenant_id: str,
740
454
  sub_tenant_id: typing.Optional[str] = OMIT,
455
+ kind: typing.Optional[ListContentKind] = OMIT,
456
+ source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
741
457
  request_options: typing.Optional[RequestOptions] = None,
742
- ) -> AsyncHttpResponse[SourceListResponse]:
458
+ ) -> AsyncHttpResponse[FetchListKnowledgeResponse]:
743
459
  """
744
- Retrieve specific sources by their IDs.
745
-
746
- Use this endpoint to fetch one or more sources by providing their
747
- unique identifiers. This is useful when you need detailed information
748
- about specific documents or content you've previously uploaded.
749
-
750
- Provide the source IDs in the request body along with your tenant
751
- information to get the exact sources you need.
752
-
753
460
  Parameters
754
461
  ----------
755
- source_ids : typing.Sequence[str]
756
- List of source IDs to fetch.
757
-
758
462
  tenant_id : str
759
463
  Tenant ID
760
464
 
761
465
  sub_tenant_id : typing.Optional[str]
762
466
  Sub-tenant ID
763
467
 
468
+ kind : typing.Optional[ListContentKind]
469
+ Whether to list normal sources or user memories.
470
+
471
+ source_ids : typing.Optional[typing.Sequence[str]]
472
+ Optional list of IDs to fetch. If omitted, returns all.
473
+
764
474
  request_options : typing.Optional[RequestOptions]
765
475
  Request-specific configuration.
766
476
 
767
477
  Returns
768
478
  -------
769
- AsyncHttpResponse[SourceListResponse]
479
+ AsyncHttpResponse[FetchListKnowledgeResponse]
770
480
  Successful Response
771
481
  """
772
482
  _response = await self._client_wrapper.httpx_client.request(
773
- "list/list-sources-by-id",
483
+ "list/data",
774
484
  method="POST",
775
485
  json={
776
- "source_ids": source_ids,
777
486
  "tenant_id": tenant_id,
778
487
  "sub_tenant_id": sub_tenant_id,
488
+ "kind": kind,
489
+ "source_ids": source_ids,
779
490
  },
780
491
  headers={
781
492
  "content-type": "application/json",
@@ -786,9 +497,9 @@ class AsyncRawFetchClient:
786
497
  try:
787
498
  if 200 <= _response.status_code < 300:
788
499
  _data = typing.cast(
789
- SourceListResponse,
500
+ FetchListKnowledgeResponse,
790
501
  parse_obj_as(
791
- type_=SourceListResponse, # type: ignore
502
+ type_=FetchListKnowledgeResponse, # type: ignore
792
503
  object_=_response.json(),
793
504
  ),
794
505
  )
@@ -884,13 +595,6 @@ class AsyncRawFetchClient:
884
595
  request_options: typing.Optional[RequestOptions] = None,
885
596
  ) -> AsyncHttpResponse[SourceGraphRelationsResponse]:
886
597
  """
887
- Retrieve relations for a specific source.
888
-
889
- Use this endpoint to fetch all relations associated with a specific source.
890
- This is useful when you need to understand the relationships between entities within a source.
891
-
892
- Provide the source ID in the request body along with your tenant information to get the relations for that source.
893
-
894
598
  Parameters
895
599
  ----------
896
600
  source_id : str
@@ -911,7 +615,7 @@ class AsyncRawFetchClient:
911
615
  Successful Response
912
616
  """
913
617
  _response = await self._client_wrapper.httpx_client.request(
914
- "list/graph-relations-by-id",
618
+ "list/graph_relations_by_id",
915
619
  method="GET",
916
620
  params={
917
621
  "source_id": source_id,
@@ -1023,13 +727,6 @@ class AsyncRawFetchClient:
1023
727
  request_options: typing.Optional[RequestOptions] = None,
1024
728
  ) -> AsyncHttpResponse[SourceFetchResponse]:
1025
729
  """
1026
- Fetch the content of a source ingested.
1027
-
1028
- This endpoint can return:
1029
- - File content directly (as string or base64)
1030
- - A presigned URL to access the file
1031
- - Both content and presigned URL
1032
-
1033
730
  Parameters
1034
731
  ----------
1035
732
  tenant_id : str
@@ -1056,7 +753,7 @@ class AsyncRawFetchClient:
1056
753
  Successful Response
1057
754
  """
1058
755
  _response = await self._client_wrapper.httpx_client.request(
1059
- "fetch/fetch-source-content",
756
+ "fetch/content",
1060
757
  method="POST",
1061
758
  json={
1062
759
  "tenant_id": tenant_id,
@@ -0,0 +1,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from .fetch_list_knowledge_response import FetchListKnowledgeResponse
6
+
7
+ __all__ = ["FetchListKnowledgeResponse"]
@@ -0,0 +1,8 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ...types.list_user_memories_response import ListUserMemoriesResponse
6
+ from ...types.source_list_response import SourceListResponse
7
+
8
+ FetchListKnowledgeResponse = typing.Union[SourceListResponse, ListUserMemoriesResponse]
@@ -18,8 +18,6 @@ class RawCortexAI:
18
18
  self, *, request_options: typing.Optional[RequestOptions] = None
19
19
  ) -> HttpResponse[typing.Optional[typing.Any]]:
20
20
  """
21
- Endpoint that serves Prometheus metrics.
22
-
23
21
  Parameters
24
22
  ----------
25
23
  request_options : typing.Optional[RequestOptions]
@@ -61,8 +59,6 @@ class AsyncRawCortexAI:
61
59
  self, *, request_options: typing.Optional[RequestOptions] = None
62
60
  ) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
63
61
  """
64
- Endpoint that serves Prometheus metrics.
65
-
66
62
  Parameters
67
63
  ----------
68
64
  request_options : typing.Optional[RequestOptions]