usecortex-ai 0.3.4__py3-none-any.whl → 0.3.6__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 (31) hide show
  1. usecortex_ai/__init__.py +24 -2
  2. usecortex_ai/search/client.py +36 -4
  3. usecortex_ai/search/raw_client.py +40 -8
  4. usecortex_ai/sources/client.py +97 -0
  5. usecortex_ai/sources/raw_client.py +273 -0
  6. usecortex_ai/types/__init__.py +24 -2
  7. usecortex_ai/types/add_user_memory_response.py +6 -1
  8. usecortex_ai/types/chunk_graph_relations_response.py +33 -0
  9. usecortex_ai/types/entity.py +42 -0
  10. usecortex_ai/types/extended_context.py +0 -3
  11. usecortex_ai/types/graph_relations_response.py +33 -0
  12. usecortex_ai/types/{generate_user_memory_response.py → path_triplet.py} +13 -7
  13. usecortex_ai/types/relation_evidence.py +53 -0
  14. usecortex_ai/types/retrieve_mode.py +5 -0
  15. usecortex_ai/types/retrieve_response.py +34 -0
  16. usecortex_ai/types/retrieve_user_memory_response.py +6 -0
  17. usecortex_ai/types/scored_path_response.py +40 -0
  18. usecortex_ai/types/scored_triplet_response.py +43 -0
  19. usecortex_ai/types/search_chunk.py +11 -0
  20. usecortex_ai/types/triple_with_evidence.py +31 -0
  21. usecortex_ai/types/user_assistant_pair.py +27 -0
  22. usecortex_ai/types/webpage_scrape_request.py +27 -0
  23. usecortex_ai/upload/client.py +276 -0
  24. usecortex_ai/upload/raw_client.py +1179 -339
  25. usecortex_ai/user_memory/client.py +77 -149
  26. usecortex_ai/user_memory/raw_client.py +74 -329
  27. {usecortex_ai-0.3.4.dist-info → usecortex_ai-0.3.6.dist-info}/METADATA +1 -1
  28. {usecortex_ai-0.3.4.dist-info → usecortex_ai-0.3.6.dist-info}/RECORD +31 -20
  29. {usecortex_ai-0.3.4.dist-info → usecortex_ai-0.3.6.dist-info}/WHEEL +0 -0
  30. {usecortex_ai-0.3.4.dist-info → usecortex_ai-0.3.6.dist-info}/licenses/LICENSE +0 -0
  31. {usecortex_ai-0.3.4.dist-info → usecortex_ai-0.3.6.dist-info}/top_level.txt +0 -0
@@ -16,6 +16,7 @@ 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.actual_error_response import ActualErrorResponse
19
+ from ..types.graph_relations_response import GraphRelationsResponse
19
20
  from ..types.list_sources_response import ListSourcesResponse
20
21
 
21
22
  # this is used as the default value for optional parameters
@@ -297,6 +298,142 @@ class RawSourcesClient:
297
298
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
298
299
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
299
300
 
301
+ def get_graph_relations_by_id(
302
+ self,
303
+ *,
304
+ source_id: str,
305
+ tenant_id: typing.Optional[str] = None,
306
+ sub_tenant_id: typing.Optional[str] = None,
307
+ request_options: typing.Optional[RequestOptions] = None,
308
+ ) -> HttpResponse[GraphRelationsResponse]:
309
+ """
310
+ Retrieve relations for a specific source.
311
+
312
+ Use this endpoint to fetch all relations associated with a specific source. This is useful when you need to understand the relationships between entities within a source.
313
+
314
+ Provide the source ID in the request body along with your tenant information to get the relations for that source.
315
+
316
+ Parameters
317
+ ----------
318
+ source_id : str
319
+ The source ID to fetch relations for
320
+
321
+ tenant_id : typing.Optional[str]
322
+ Unique identifier for the tenant/organization
323
+
324
+ sub_tenant_id : typing.Optional[str]
325
+ Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
326
+
327
+ request_options : typing.Optional[RequestOptions]
328
+ Request-specific configuration.
329
+
330
+ Returns
331
+ -------
332
+ HttpResponse[GraphRelationsResponse]
333
+ Successful Response
334
+ """
335
+ _response = self._client_wrapper.httpx_client.request(
336
+ "list/graph_relations_by_id",
337
+ method="GET",
338
+ params={
339
+ "source_id": source_id,
340
+ "tenant_id": tenant_id,
341
+ "sub_tenant_id": sub_tenant_id,
342
+ },
343
+ request_options=request_options,
344
+ )
345
+ try:
346
+ if 200 <= _response.status_code < 300:
347
+ _data = typing.cast(
348
+ GraphRelationsResponse,
349
+ parse_obj_as(
350
+ type_=GraphRelationsResponse, # type: ignore
351
+ object_=_response.json(),
352
+ ),
353
+ )
354
+ return HttpResponse(response=_response, data=_data)
355
+ if _response.status_code == 400:
356
+ raise BadRequestError(
357
+ headers=dict(_response.headers),
358
+ body=typing.cast(
359
+ ActualErrorResponse,
360
+ parse_obj_as(
361
+ type_=ActualErrorResponse, # type: ignore
362
+ object_=_response.json(),
363
+ ),
364
+ ),
365
+ )
366
+ if _response.status_code == 401:
367
+ raise UnauthorizedError(
368
+ headers=dict(_response.headers),
369
+ body=typing.cast(
370
+ ActualErrorResponse,
371
+ parse_obj_as(
372
+ type_=ActualErrorResponse, # type: ignore
373
+ object_=_response.json(),
374
+ ),
375
+ ),
376
+ )
377
+ if _response.status_code == 403:
378
+ raise ForbiddenError(
379
+ headers=dict(_response.headers),
380
+ body=typing.cast(
381
+ ActualErrorResponse,
382
+ parse_obj_as(
383
+ type_=ActualErrorResponse, # type: ignore
384
+ object_=_response.json(),
385
+ ),
386
+ ),
387
+ )
388
+ if _response.status_code == 404:
389
+ raise NotFoundError(
390
+ headers=dict(_response.headers),
391
+ body=typing.cast(
392
+ ActualErrorResponse,
393
+ parse_obj_as(
394
+ type_=ActualErrorResponse, # type: ignore
395
+ object_=_response.json(),
396
+ ),
397
+ ),
398
+ )
399
+ if _response.status_code == 422:
400
+ raise UnprocessableEntityError(
401
+ headers=dict(_response.headers),
402
+ body=typing.cast(
403
+ typing.Optional[typing.Any],
404
+ parse_obj_as(
405
+ type_=typing.Optional[typing.Any], # type: ignore
406
+ object_=_response.json(),
407
+ ),
408
+ ),
409
+ )
410
+ if _response.status_code == 500:
411
+ raise InternalServerError(
412
+ headers=dict(_response.headers),
413
+ body=typing.cast(
414
+ ActualErrorResponse,
415
+ parse_obj_as(
416
+ type_=ActualErrorResponse, # type: ignore
417
+ object_=_response.json(),
418
+ ),
419
+ ),
420
+ )
421
+ if _response.status_code == 503:
422
+ raise ServiceUnavailableError(
423
+ headers=dict(_response.headers),
424
+ body=typing.cast(
425
+ ActualErrorResponse,
426
+ parse_obj_as(
427
+ type_=ActualErrorResponse, # type: ignore
428
+ object_=_response.json(),
429
+ ),
430
+ ),
431
+ )
432
+ _response_json = _response.json()
433
+ except JSONDecodeError:
434
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
435
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
436
+
300
437
 
301
438
  class AsyncRawSourcesClient:
302
439
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -572,3 +709,139 @@ class AsyncRawSourcesClient:
572
709
  except JSONDecodeError:
573
710
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
574
711
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
712
+
713
+ async def get_graph_relations_by_id(
714
+ self,
715
+ *,
716
+ source_id: str,
717
+ tenant_id: typing.Optional[str] = None,
718
+ sub_tenant_id: typing.Optional[str] = None,
719
+ request_options: typing.Optional[RequestOptions] = None,
720
+ ) -> AsyncHttpResponse[GraphRelationsResponse]:
721
+ """
722
+ Retrieve relations for a specific source.
723
+
724
+ Use this endpoint to fetch all relations associated with a specific source. This is useful when you need to understand the relationships between entities within a source.
725
+
726
+ Provide the source ID in the request body along with your tenant information to get the relations for that source.
727
+
728
+ Parameters
729
+ ----------
730
+ source_id : str
731
+ The source ID to fetch relations for
732
+
733
+ tenant_id : typing.Optional[str]
734
+ Unique identifier for the tenant/organization
735
+
736
+ sub_tenant_id : typing.Optional[str]
737
+ Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
738
+
739
+ request_options : typing.Optional[RequestOptions]
740
+ Request-specific configuration.
741
+
742
+ Returns
743
+ -------
744
+ AsyncHttpResponse[GraphRelationsResponse]
745
+ Successful Response
746
+ """
747
+ _response = await self._client_wrapper.httpx_client.request(
748
+ "list/graph_relations_by_id",
749
+ method="GET",
750
+ params={
751
+ "source_id": source_id,
752
+ "tenant_id": tenant_id,
753
+ "sub_tenant_id": sub_tenant_id,
754
+ },
755
+ request_options=request_options,
756
+ )
757
+ try:
758
+ if 200 <= _response.status_code < 300:
759
+ _data = typing.cast(
760
+ GraphRelationsResponse,
761
+ parse_obj_as(
762
+ type_=GraphRelationsResponse, # type: ignore
763
+ object_=_response.json(),
764
+ ),
765
+ )
766
+ return AsyncHttpResponse(response=_response, data=_data)
767
+ if _response.status_code == 400:
768
+ raise BadRequestError(
769
+ headers=dict(_response.headers),
770
+ body=typing.cast(
771
+ ActualErrorResponse,
772
+ parse_obj_as(
773
+ type_=ActualErrorResponse, # type: ignore
774
+ object_=_response.json(),
775
+ ),
776
+ ),
777
+ )
778
+ if _response.status_code == 401:
779
+ raise UnauthorizedError(
780
+ headers=dict(_response.headers),
781
+ body=typing.cast(
782
+ ActualErrorResponse,
783
+ parse_obj_as(
784
+ type_=ActualErrorResponse, # type: ignore
785
+ object_=_response.json(),
786
+ ),
787
+ ),
788
+ )
789
+ if _response.status_code == 403:
790
+ raise ForbiddenError(
791
+ headers=dict(_response.headers),
792
+ body=typing.cast(
793
+ ActualErrorResponse,
794
+ parse_obj_as(
795
+ type_=ActualErrorResponse, # type: ignore
796
+ object_=_response.json(),
797
+ ),
798
+ ),
799
+ )
800
+ if _response.status_code == 404:
801
+ raise NotFoundError(
802
+ headers=dict(_response.headers),
803
+ body=typing.cast(
804
+ ActualErrorResponse,
805
+ parse_obj_as(
806
+ type_=ActualErrorResponse, # type: ignore
807
+ object_=_response.json(),
808
+ ),
809
+ ),
810
+ )
811
+ if _response.status_code == 422:
812
+ raise UnprocessableEntityError(
813
+ headers=dict(_response.headers),
814
+ body=typing.cast(
815
+ typing.Optional[typing.Any],
816
+ parse_obj_as(
817
+ type_=typing.Optional[typing.Any], # type: ignore
818
+ object_=_response.json(),
819
+ ),
820
+ ),
821
+ )
822
+ if _response.status_code == 500:
823
+ raise InternalServerError(
824
+ headers=dict(_response.headers),
825
+ body=typing.cast(
826
+ ActualErrorResponse,
827
+ parse_obj_as(
828
+ type_=ActualErrorResponse, # type: ignore
829
+ object_=_response.json(),
830
+ ),
831
+ ),
832
+ )
833
+ if _response.status_code == 503:
834
+ raise ServiceUnavailableError(
835
+ headers=dict(_response.headers),
836
+ body=typing.cast(
837
+ ActualErrorResponse,
838
+ parse_obj_as(
839
+ type_=ActualErrorResponse, # type: ignore
840
+ object_=_response.json(),
841
+ ),
842
+ ),
843
+ )
844
+ _response_json = _response.json()
845
+ except JSONDecodeError:
846
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
847
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -10,6 +10,7 @@ from .batch_upload_data import BatchUploadData
10
10
  from .bm_25_operator_type import Bm25OperatorType
11
11
  from .body_scrape_webpage_upload_scrape_webpage_post import BodyScrapeWebpageUploadScrapeWebpagePost
12
12
  from .body_update_scrape_job_upload_update_webpage_patch import BodyUpdateScrapeJobUploadUpdateWebpagePatch
13
+ from .chunk_graph_relations_response import ChunkGraphRelationsResponse
13
14
  from .content_model import ContentModel
14
15
  from .delete_memory_request import DeleteMemoryRequest
15
16
  from .delete_sources import DeleteSources
@@ -19,19 +20,26 @@ from .embeddings_create_collection_data import EmbeddingsCreateCollectionData
19
20
  from .embeddings_delete_data import EmbeddingsDeleteData
20
21
  from .embeddings_get_data import EmbeddingsGetData
21
22
  from .embeddings_search_data import EmbeddingsSearchData
23
+ from .entity import Entity
22
24
  from .error_response import ErrorResponse
23
25
  from .extended_context import ExtendedContext
24
26
  from .fetch_content_data import FetchContentData
25
27
  from .file_upload_result import FileUploadResult
26
- from .generate_user_memory_response import GenerateUserMemoryResponse
28
+ from .graph_relations_response import GraphRelationsResponse
27
29
  from .http_validation_error import HttpValidationError
28
30
  from .list_sources_response import ListSourcesResponse
29
31
  from .list_user_memories_response import ListUserMemoriesResponse
30
32
  from .markdown_upload_request import MarkdownUploadRequest
33
+ from .path_triplet import PathTriplet
31
34
  from .processing_status import ProcessingStatus
32
35
  from .related_chunk import RelatedChunk
36
+ from .relation_evidence import RelationEvidence
33
37
  from .relations import Relations
38
+ from .retrieve_mode import RetrieveMode
39
+ from .retrieve_response import RetrieveResponse
34
40
  from .retrieve_user_memory_response import RetrieveUserMemoryResponse
41
+ from .scored_path_response import ScoredPathResponse
42
+ from .scored_triplet_response import ScoredTripletResponse
35
43
  from .search_chunk import SearchChunk
36
44
  from .single_upload_data import SingleUploadData
37
45
  from .source import Source
@@ -39,9 +47,12 @@ from .source_model import SourceModel
39
47
  from .sub_tenant_ids_data import SubTenantIdsData
40
48
  from .tenant_create_data import TenantCreateData
41
49
  from .tenant_stats import TenantStats
50
+ from .triple_with_evidence import TripleWithEvidence
51
+ from .user_assistant_pair import UserAssistantPair
42
52
  from .user_memory import UserMemory
43
53
  from .validation_error import ValidationError
44
54
  from .validation_error_loc_item import ValidationErrorLocItem
55
+ from .webpage_scrape_request import WebpageScrapeRequest
45
56
 
46
57
  __all__ = [
47
58
  "ActualErrorResponse",
@@ -52,6 +63,7 @@ __all__ = [
52
63
  "Bm25OperatorType",
53
64
  "BodyScrapeWebpageUploadScrapeWebpagePost",
54
65
  "BodyUpdateScrapeJobUploadUpdateWebpagePatch",
66
+ "ChunkGraphRelationsResponse",
55
67
  "ContentModel",
56
68
  "DeleteMemoryRequest",
57
69
  "DeleteSources",
@@ -61,19 +73,26 @@ __all__ = [
61
73
  "EmbeddingsDeleteData",
62
74
  "EmbeddingsGetData",
63
75
  "EmbeddingsSearchData",
76
+ "Entity",
64
77
  "ErrorResponse",
65
78
  "ExtendedContext",
66
79
  "FetchContentData",
67
80
  "FileUploadResult",
68
- "GenerateUserMemoryResponse",
81
+ "GraphRelationsResponse",
69
82
  "HttpValidationError",
70
83
  "ListSourcesResponse",
71
84
  "ListUserMemoriesResponse",
72
85
  "MarkdownUploadRequest",
86
+ "PathTriplet",
73
87
  "ProcessingStatus",
74
88
  "RelatedChunk",
89
+ "RelationEvidence",
75
90
  "Relations",
91
+ "RetrieveMode",
92
+ "RetrieveResponse",
76
93
  "RetrieveUserMemoryResponse",
94
+ "ScoredPathResponse",
95
+ "ScoredTripletResponse",
77
96
  "SearchChunk",
78
97
  "SingleUploadData",
79
98
  "Source",
@@ -81,7 +100,10 @@ __all__ = [
81
100
  "SubTenantIdsData",
82
101
  "TenantCreateData",
83
102
  "TenantStats",
103
+ "TripleWithEvidence",
104
+ "UserAssistantPair",
84
105
  "UserMemory",
85
106
  "ValidationError",
86
107
  "ValidationErrorLocItem",
108
+ "WebpageScrapeRequest",
87
109
  ]
@@ -21,11 +21,16 @@ class AddUserMemoryResponse(UniversalBaseModel):
21
21
  Confirms whether the memory was successfully stored in the system
22
22
  """
23
23
 
24
- memory_id: typing.Optional[str] = pydantic.Field(default=None)
24
+ memory_id: str = pydantic.Field()
25
25
  """
26
26
  Unique identifier assigned to the newly created memory
27
27
  """
28
28
 
29
+ chunks_created: typing.Optional[int] = pydantic.Field(default=None)
30
+ """
31
+ Total number of chunks created from the memory
32
+ """
33
+
29
34
  if IS_PYDANTIC_V2:
30
35
  model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
31
36
  else:
@@ -0,0 +1,33 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+ from .scored_path_response import ScoredPathResponse
8
+ from .scored_triplet_response import ScoredTripletResponse
9
+
10
+
11
+ class ChunkGraphRelationsResponse(UniversalBaseModel):
12
+ """
13
+ Graph relations with group_id -> triplet mapping
14
+ """
15
+
16
+ entity_paths: typing.Optional[typing.List[ScoredPathResponse]] = pydantic.Field(default=None)
17
+ """
18
+ Multi-hop paths connecting entities from the query, reranked by relevance. Each path is a chain of connected triplets.
19
+ """
20
+
21
+ chunk_triplets: typing.Optional[typing.Dict[str, ScoredTripletResponse]] = pydantic.Field(default=None)
22
+ """
23
+ Mapping of group_id to scored triplet. Use chunk.graph_triplet_ids to find which groups belong to a chunk.
24
+ """
25
+
26
+ if IS_PYDANTIC_V2:
27
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
28
+ else:
29
+
30
+ class Config:
31
+ frozen = True
32
+ smart_union = True
33
+ extra = pydantic.Extra.allow
@@ -0,0 +1,42 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class Entity(UniversalBaseModel):
10
+ name: str = pydantic.Field()
11
+ """
12
+ Normalized entity name
13
+ """
14
+
15
+ type: str = pydantic.Field()
16
+ """
17
+ PERSON, ORGANIZATION, PROJECT, PRODUCT, ERROR_CODE, etc.
18
+ """
19
+
20
+ namespace: typing.Optional[str] = pydantic.Field(default=None)
21
+ """
22
+ Context category like 'employees', 'projects'
23
+ """
24
+
25
+ identifier: typing.Optional[str] = pydantic.Field(default=None)
26
+ """
27
+ Unique ID like email, employee_id, URL
28
+ """
29
+
30
+ entity_id: typing.Optional[str] = pydantic.Field(default=None)
31
+ """
32
+ Internal unique entity ID from graph database
33
+ """
34
+
35
+ if IS_PYDANTIC_V2:
36
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
37
+ else:
38
+
39
+ class Config:
40
+ frozen = True
41
+ smart_union = True
42
+ extra = pydantic.Extra.allow
@@ -4,12 +4,9 @@ import typing
4
4
 
5
5
  import pydantic
6
6
  from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
- from .related_chunk import RelatedChunk
8
7
 
9
8
 
10
9
  class ExtendedContext(UniversalBaseModel):
11
- relations: typing.Optional[typing.List[RelatedChunk]] = None
12
-
13
10
  if IS_PYDANTIC_V2:
14
11
  model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
15
12
  else:
@@ -0,0 +1,33 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+ from .triple_with_evidence import TripleWithEvidence
8
+
9
+
10
+ class GraphRelationsResponse(UniversalBaseModel):
11
+ relations: typing.List[typing.Optional[TripleWithEvidence]] = pydantic.Field()
12
+ """
13
+ List of relations retrieved
14
+ """
15
+
16
+ success: typing.Optional[bool] = pydantic.Field(default=None)
17
+ """
18
+ Indicates whether the request was successful
19
+ """
20
+
21
+ message: typing.Optional[str] = pydantic.Field(default=None)
22
+ """
23
+ Response message describing the operation result
24
+ """
25
+
26
+ if IS_PYDANTIC_V2:
27
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
28
+ else:
29
+
30
+ class Config:
31
+ frozen = True
32
+ smart_union = True
33
+ extra = pydantic.Extra.allow
@@ -4,22 +4,28 @@ import typing
4
4
 
5
5
  import pydantic
6
6
  from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
- from .user_memory import UserMemory
7
+ from .entity import Entity
8
+ from .relation_evidence import RelationEvidence
8
9
 
9
10
 
10
- class GenerateUserMemoryResponse(UniversalBaseModel):
11
+ class PathTriplet(UniversalBaseModel):
11
12
  """
12
- Response model for AI-generated user memories.
13
+ Single triplet within a path (without score, as the path is scored as a whole)
13
14
  """
14
15
 
15
- success: bool = pydantic.Field()
16
+ source: Entity = pydantic.Field()
16
17
  """
17
- Indicates whether the memory generation operation was successful
18
+ Source entity
18
19
  """
19
20
 
20
- generated_user_memories: typing.Optional[typing.List[UserMemory]] = pydantic.Field(default=None)
21
+ target: Entity = pydantic.Field()
21
22
  """
22
- Array of AI-generated memories based on your query and user context
23
+ Target entity
24
+ """
25
+
26
+ relation: RelationEvidence = pydantic.Field()
27
+ """
28
+ Relation between entities
23
29
  """
24
30
 
25
31
  if IS_PYDANTIC_V2:
@@ -0,0 +1,53 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ import pydantic
7
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
8
+
9
+
10
+ class RelationEvidence(UniversalBaseModel):
11
+ relationship_id: typing.Optional[str] = pydantic.Field(default=None)
12
+ """
13
+ Unique identifier for this specific relationship edge in the graph. The combination of source entity, target entity, and relationship_id allows disambiguation between multiple relations between the same source and target entities.
14
+ """
15
+
16
+ canonical_predicate: str = pydantic.Field()
17
+ """
18
+ Relationship phrase like 'works for', 'reports to'
19
+ """
20
+
21
+ raw_predicate: str = pydantic.Field()
22
+ """
23
+ Original predicate from text
24
+ """
25
+
26
+ context: str = pydantic.Field()
27
+ """
28
+ Rich contextual description of the relationship with surrounding information, details about how/why/when, and any relevant background. Should be comprehensive enough to understand the relationship without referring back to source.
29
+ """
30
+
31
+ temporal_details: typing.Optional[str] = pydantic.Field(default=None)
32
+ """
33
+ Temporal timing information extracted from text (e.g., 'last week', 'in 2023', 'yesterday')
34
+ """
35
+
36
+ chunk_id: typing.Optional[str] = pydantic.Field(default=None)
37
+ """
38
+ The chunk_id this relation came from
39
+ """
40
+
41
+ timestamp: typing.Optional[dt.datetime] = pydantic.Field(default=None)
42
+ """
43
+ Timestamp when this relation was introduced
44
+ """
45
+
46
+ if IS_PYDANTIC_V2:
47
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
48
+ else:
49
+
50
+ class Config:
51
+ frozen = True
52
+ smart_union = True
53
+ extra = pydantic.Extra.allow
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ RetrieveMode = typing.Union[typing.Literal["fast", "accurate"], typing.Any]
@@ -0,0 +1,34 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+ from .chunk_graph_relations_response import ChunkGraphRelationsResponse
8
+ from .search_chunk import SearchChunk
9
+
10
+
11
+ class RetrieveResponse(UniversalBaseModel):
12
+ chunks: typing.Optional[typing.List[SearchChunk]] = pydantic.Field(default=None)
13
+ """
14
+ Retrieved content chunks
15
+ """
16
+
17
+ graph_relations: typing.Optional[ChunkGraphRelationsResponse] = pydantic.Field(default=None)
18
+ """
19
+ Graph relations with chunk_relations (by chunk_id) and entity_relations (top entity matches)
20
+ """
21
+
22
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
23
+ """
24
+ Additional metadata about the retrieval run
25
+ """
26
+
27
+ if IS_PYDANTIC_V2:
28
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
29
+ else:
30
+
31
+ class Config:
32
+ frozen = True
33
+ smart_union = True
34
+ extra = pydantic.Extra.allow
@@ -4,6 +4,7 @@ import typing
4
4
 
5
5
  import pydantic
6
6
  from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+ from .scored_path_response import ScoredPathResponse
7
8
  from .user_memory import UserMemory
8
9
 
9
10
 
@@ -22,6 +23,11 @@ class RetrieveUserMemoryResponse(UniversalBaseModel):
22
23
  Array of user memories ranked by relevance to your search query
23
24
  """
24
25
 
26
+ relations: typing.Optional[typing.List[ScoredPathResponse]] = pydantic.Field(default=None)
27
+ """
28
+ Array of scored relations extracted from the user query via knowledge graph search
29
+ """
30
+
25
31
  if IS_PYDANTIC_V2:
26
32
  model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
27
33
  else: