hindsight-client 0.0.13__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 (134) hide show
  1. hindsight_client/__init__.py +26 -0
  2. hindsight_client/hindsight_client.py +432 -0
  3. hindsight_client-0.0.13.dist-info/METADATA +56 -0
  4. hindsight_client-0.0.13.dist-info/RECORD +134 -0
  5. hindsight_client-0.0.13.dist-info/WHEEL +4 -0
  6. hindsight_client_api/__init__.py +126 -0
  7. hindsight_client_api/api/__init__.py +6 -0
  8. hindsight_client_api/api/default_api.py +5976 -0
  9. hindsight_client_api/api/monitoring_api.py +281 -0
  10. hindsight_client_api/api_client.py +807 -0
  11. hindsight_client_api/api_response.py +21 -0
  12. hindsight_client_api/configuration.py +572 -0
  13. hindsight_client_api/docs/AddBackgroundRequest.md +31 -0
  14. hindsight_client_api/docs/BackgroundResponse.md +31 -0
  15. hindsight_client_api/docs/BankListItem.md +35 -0
  16. hindsight_client_api/docs/BankListResponse.md +30 -0
  17. hindsight_client_api/docs/BankProfileResponse.md +33 -0
  18. hindsight_client_api/docs/Budget.md +15 -0
  19. hindsight_client_api/docs/ChunkData.md +33 -0
  20. hindsight_client_api/docs/ChunkIncludeOptions.md +30 -0
  21. hindsight_client_api/docs/ChunkResponse.md +35 -0
  22. hindsight_client_api/docs/CreateBankRequest.md +32 -0
  23. hindsight_client_api/docs/DefaultApi.md +1569 -0
  24. hindsight_client_api/docs/DeleteResponse.md +30 -0
  25. hindsight_client_api/docs/DocumentResponse.md +36 -0
  26. hindsight_client_api/docs/EntityDetailResponse.md +36 -0
  27. hindsight_client_api/docs/EntityIncludeOptions.md +30 -0
  28. hindsight_client_api/docs/EntityListItem.md +35 -0
  29. hindsight_client_api/docs/EntityListResponse.md +30 -0
  30. hindsight_client_api/docs/EntityObservationResponse.md +31 -0
  31. hindsight_client_api/docs/EntityStateResponse.md +32 -0
  32. hindsight_client_api/docs/GraphDataResponse.md +33 -0
  33. hindsight_client_api/docs/HTTPValidationError.md +29 -0
  34. hindsight_client_api/docs/IncludeOptions.md +31 -0
  35. hindsight_client_api/docs/ListDocumentsResponse.md +33 -0
  36. hindsight_client_api/docs/ListMemoryUnitsResponse.md +33 -0
  37. hindsight_client_api/docs/MemoryItem.md +34 -0
  38. hindsight_client_api/docs/MetadataFilter.md +32 -0
  39. hindsight_client_api/docs/MonitoringApi.md +72 -0
  40. hindsight_client_api/docs/PersonalityTraits.md +35 -0
  41. hindsight_client_api/docs/RecallRequest.md +37 -0
  42. hindsight_client_api/docs/RecallResponse.md +33 -0
  43. hindsight_client_api/docs/RecallResult.md +40 -0
  44. hindsight_client_api/docs/ReflectFact.md +35 -0
  45. hindsight_client_api/docs/ReflectIncludeOptions.md +30 -0
  46. hindsight_client_api/docs/ReflectRequest.md +34 -0
  47. hindsight_client_api/docs/ReflectResponse.md +31 -0
  48. hindsight_client_api/docs/RetainRequest.md +31 -0
  49. hindsight_client_api/docs/RetainResponse.md +33 -0
  50. hindsight_client_api/docs/UpdatePersonalityRequest.md +30 -0
  51. hindsight_client_api/docs/ValidationError.md +31 -0
  52. hindsight_client_api/docs/ValidationErrorLocInner.md +28 -0
  53. hindsight_client_api/exceptions.py +219 -0
  54. hindsight_client_api/models/__init__.py +54 -0
  55. hindsight_client_api/models/add_background_request.py +89 -0
  56. hindsight_client_api/models/background_response.py +98 -0
  57. hindsight_client_api/models/bank_list_item.py +111 -0
  58. hindsight_client_api/models/bank_list_response.py +95 -0
  59. hindsight_client_api/models/bank_profile_response.py +97 -0
  60. hindsight_client_api/models/budget.py +38 -0
  61. hindsight_client_api/models/chunk_data.py +93 -0
  62. hindsight_client_api/models/chunk_include_options.py +87 -0
  63. hindsight_client_api/models/chunk_response.py +97 -0
  64. hindsight_client_api/models/create_bank_request.py +110 -0
  65. hindsight_client_api/models/delete_response.py +87 -0
  66. hindsight_client_api/models/document_response.py +104 -0
  67. hindsight_client_api/models/entity_detail_response.py +122 -0
  68. hindsight_client_api/models/entity_include_options.py +87 -0
  69. hindsight_client_api/models/entity_list_item.py +112 -0
  70. hindsight_client_api/models/entity_list_response.py +95 -0
  71. hindsight_client_api/models/entity_observation_response.py +94 -0
  72. hindsight_client_api/models/entity_state_response.py +99 -0
  73. hindsight_client_api/models/graph_data_response.py +93 -0
  74. hindsight_client_api/models/http_validation_error.py +95 -0
  75. hindsight_client_api/models/include_options.py +107 -0
  76. hindsight_client_api/models/list_documents_response.py +93 -0
  77. hindsight_client_api/models/list_memory_units_response.py +93 -0
  78. hindsight_client_api/models/memory_item.py +116 -0
  79. hindsight_client_api/models/metadata_filter.py +96 -0
  80. hindsight_client_api/models/personality_traits.py +98 -0
  81. hindsight_client_api/models/recall_request.py +129 -0
  82. hindsight_client_api/models/recall_response.py +142 -0
  83. hindsight_client_api/models/recall_result.py +152 -0
  84. hindsight_client_api/models/reflect_fact.py +122 -0
  85. hindsight_client_api/models/reflect_include_options.py +87 -0
  86. hindsight_client_api/models/reflect_request.py +118 -0
  87. hindsight_client_api/models/reflect_response.py +97 -0
  88. hindsight_client_api/models/retain_request.py +97 -0
  89. hindsight_client_api/models/retain_response.py +93 -0
  90. hindsight_client_api/models/update_personality_request.py +91 -0
  91. hindsight_client_api/models/validation_error.py +99 -0
  92. hindsight_client_api/models/validation_error_loc_inner.py +138 -0
  93. hindsight_client_api/rest.py +213 -0
  94. hindsight_client_api/test/__init__.py +0 -0
  95. hindsight_client_api/test/test_add_background_request.py +53 -0
  96. hindsight_client_api/test/test_background_response.py +53 -0
  97. hindsight_client_api/test/test_bank_list_item.py +60 -0
  98. hindsight_client_api/test/test_bank_list_response.py +68 -0
  99. hindsight_client_api/test/test_bank_profile_response.py +58 -0
  100. hindsight_client_api/test/test_budget.py +33 -0
  101. hindsight_client_api/test/test_chunk_data.py +57 -0
  102. hindsight_client_api/test/test_chunk_include_options.py +51 -0
  103. hindsight_client_api/test/test_chunk_response.py +62 -0
  104. hindsight_client_api/test/test_create_bank_request.py +53 -0
  105. hindsight_client_api/test/test_default_api.py +178 -0
  106. hindsight_client_api/test/test_delete_response.py +52 -0
  107. hindsight_client_api/test/test_document_response.py +64 -0
  108. hindsight_client_api/test/test_entity_detail_response.py +71 -0
  109. hindsight_client_api/test/test_entity_include_options.py +51 -0
  110. hindsight_client_api/test/test_entity_list_item.py +61 -0
  111. hindsight_client_api/test/test_entity_list_response.py +56 -0
  112. hindsight_client_api/test/test_entity_observation_response.py +53 -0
  113. hindsight_client_api/test/test_entity_state_response.py +64 -0
  114. hindsight_client_api/test/test_graph_data_response.py +82 -0
  115. hindsight_client_api/test/test_http_validation_error.py +58 -0
  116. hindsight_client_api/test/test_include_options.py +54 -0
  117. hindsight_client_api/test/test_list_documents_response.py +66 -0
  118. hindsight_client_api/test/test_list_memory_units_response.py +66 -0
  119. hindsight_client_api/test/test_memory_item.py +58 -0
  120. hindsight_client_api/test/test_metadata_filter.py +54 -0
  121. hindsight_client_api/test/test_monitoring_api.py +38 -0
  122. hindsight_client_api/test/test_personality_traits.py +62 -0
  123. hindsight_client_api/test/test_recall_request.py +67 -0
  124. hindsight_client_api/test/test_recall_response.py +76 -0
  125. hindsight_client_api/test/test_recall_result.py +67 -0
  126. hindsight_client_api/test/test_reflect_fact.py +57 -0
  127. hindsight_client_api/test/test_reflect_include_options.py +51 -0
  128. hindsight_client_api/test/test_reflect_request.py +59 -0
  129. hindsight_client_api/test/test_reflect_response.py +55 -0
  130. hindsight_client_api/test/test_retain_request.py +57 -0
  131. hindsight_client_api/test/test_retain_response.py +58 -0
  132. hindsight_client_api/test/test_update_personality_request.py +52 -0
  133. hindsight_client_api/test/test_validation_error.py +60 -0
  134. hindsight_client_api/test/test_validation_error_loc_inner.py +50 -0
@@ -0,0 +1,97 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hindsight HTTP API
5
+
6
+ HTTP API for Hindsight
7
+
8
+ The version of the OpenAPI document: 1.0.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, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from hindsight_client_api.models.reflect_fact import ReflectFact
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class ReflectResponse(BaseModel):
27
+ """
28
+ Response model for think endpoint.
29
+ """ # noqa: E501
30
+ text: StrictStr
31
+ based_on: Optional[List[ReflectFact]] = None
32
+ __properties: ClassVar[List[str]] = ["text", "based_on"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of ReflectResponse from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ # override the default output from pydantic by calling `to_dict()` of each item in based_on (list)
74
+ _items = []
75
+ if self.based_on:
76
+ for _item_based_on in self.based_on:
77
+ if _item_based_on:
78
+ _items.append(_item_based_on.to_dict())
79
+ _dict['based_on'] = _items
80
+ return _dict
81
+
82
+ @classmethod
83
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
84
+ """Create an instance of ReflectResponse from a dict"""
85
+ if obj is None:
86
+ return None
87
+
88
+ if not isinstance(obj, dict):
89
+ return cls.model_validate(obj)
90
+
91
+ _obj = cls.model_validate({
92
+ "text": obj.get("text"),
93
+ "based_on": [ReflectFact.from_dict(_item) for _item in obj["based_on"]] if obj.get("based_on") is not None else None
94
+ })
95
+ return _obj
96
+
97
+
@@ -0,0 +1,97 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hindsight HTTP API
5
+
6
+ HTTP API for Hindsight
7
+
8
+ The version of the OpenAPI document: 1.0.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, StrictBool
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from hindsight_client_api.models.memory_item import MemoryItem
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class RetainRequest(BaseModel):
27
+ """
28
+ Request model for retain endpoint.
29
+ """ # noqa: E501
30
+ items: List[MemoryItem]
31
+ var_async: Optional[StrictBool] = Field(default=False, description="If true, process asynchronously in background. If false, wait for completion (default: false)", alias="async")
32
+ __properties: ClassVar[List[str]] = ["items", "async"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of RetainRequest from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ # override the default output from pydantic by calling `to_dict()` of each item in items (list)
74
+ _items = []
75
+ if self.items:
76
+ for _item_items in self.items:
77
+ if _item_items:
78
+ _items.append(_item_items.to_dict())
79
+ _dict['items'] = _items
80
+ return _dict
81
+
82
+ @classmethod
83
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
84
+ """Create an instance of RetainRequest from a dict"""
85
+ if obj is None:
86
+ return None
87
+
88
+ if not isinstance(obj, dict):
89
+ return cls.model_validate(obj)
90
+
91
+ _obj = cls.model_validate({
92
+ "items": [MemoryItem.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None,
93
+ "async": obj.get("async") if obj.get("async") is not None else False
94
+ })
95
+ return _obj
96
+
97
+
@@ -0,0 +1,93 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hindsight HTTP API
5
+
6
+ HTTP API for Hindsight
7
+
8
+ The version of the OpenAPI document: 1.0.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, StrictBool, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class RetainResponse(BaseModel):
26
+ """
27
+ Response model for retain endpoint.
28
+ """ # noqa: E501
29
+ success: StrictBool
30
+ bank_id: StrictStr
31
+ items_count: StrictInt
32
+ var_async: StrictBool = Field(description="Whether the operation was processed asynchronously", alias="async")
33
+ __properties: ClassVar[List[str]] = ["success", "bank_id", "items_count", "async"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of RetainResponse from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ return _dict
75
+
76
+ @classmethod
77
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
78
+ """Create an instance of RetainResponse from a dict"""
79
+ if obj is None:
80
+ return None
81
+
82
+ if not isinstance(obj, dict):
83
+ return cls.model_validate(obj)
84
+
85
+ _obj = cls.model_validate({
86
+ "success": obj.get("success"),
87
+ "bank_id": obj.get("bank_id"),
88
+ "items_count": obj.get("items_count"),
89
+ "async": obj.get("async")
90
+ })
91
+ return _obj
92
+
93
+
@@ -0,0 +1,91 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hindsight HTTP API
5
+
6
+ HTTP API for Hindsight
7
+
8
+ The version of the OpenAPI document: 1.0.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
21
+ from typing import Any, ClassVar, Dict, List
22
+ from hindsight_client_api.models.personality_traits import PersonalityTraits
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class UpdatePersonalityRequest(BaseModel):
27
+ """
28
+ Request model for updating personality traits.
29
+ """ # noqa: E501
30
+ personality: PersonalityTraits
31
+ __properties: ClassVar[List[str]] = ["personality"]
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 UpdatePersonalityRequest 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
+ # override the default output from pydantic by calling `to_dict()` of personality
73
+ if self.personality:
74
+ _dict['personality'] = self.personality.to_dict()
75
+ return _dict
76
+
77
+ @classmethod
78
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
79
+ """Create an instance of UpdatePersonalityRequest from a dict"""
80
+ if obj is None:
81
+ return None
82
+
83
+ if not isinstance(obj, dict):
84
+ return cls.model_validate(obj)
85
+
86
+ _obj = cls.model_validate({
87
+ "personality": PersonalityTraits.from_dict(obj["personality"]) if obj.get("personality") is not None else None
88
+ })
89
+ return _obj
90
+
91
+
@@ -0,0 +1,99 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hindsight HTTP API
5
+
6
+ HTTP API for Hindsight
7
+
8
+ The version of the OpenAPI document: 1.0.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, StrictStr
21
+ from typing import Any, ClassVar, Dict, List
22
+ from hindsight_client_api.models.validation_error_loc_inner import ValidationErrorLocInner
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class ValidationError(BaseModel):
27
+ """
28
+ ValidationError
29
+ """ # noqa: E501
30
+ loc: List[ValidationErrorLocInner]
31
+ msg: StrictStr
32
+ type: StrictStr
33
+ __properties: ClassVar[List[str]] = ["loc", "msg", "type"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of ValidationError from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ # override the default output from pydantic by calling `to_dict()` of each item in loc (list)
75
+ _items = []
76
+ if self.loc:
77
+ for _item_loc in self.loc:
78
+ if _item_loc:
79
+ _items.append(_item_loc.to_dict())
80
+ _dict['loc'] = _items
81
+ return _dict
82
+
83
+ @classmethod
84
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
85
+ """Create an instance of ValidationError from a dict"""
86
+ if obj is None:
87
+ return None
88
+
89
+ if not isinstance(obj, dict):
90
+ return cls.model_validate(obj)
91
+
92
+ _obj = cls.model_validate({
93
+ "loc": [ValidationErrorLocInner.from_dict(_item) for _item in obj["loc"]] if obj.get("loc") is not None else None,
94
+ "msg": obj.get("msg"),
95
+ "type": obj.get("type")
96
+ })
97
+ return _obj
98
+
99
+
@@ -0,0 +1,138 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Hindsight HTTP API
5
+
6
+ HTTP API for Hindsight
7
+
8
+ The version of the OpenAPI document: 1.0.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
+ from inspect import getfullargspec
17
+ import json
18
+ import pprint
19
+ import re # noqa: F401
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, ValidationError, field_validator
21
+ from typing import Optional
22
+ from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
23
+ from typing_extensions import Literal, Self
24
+ from pydantic import Field
25
+
26
+ VALIDATIONERRORLOCINNER_ANY_OF_SCHEMAS = ["int", "str"]
27
+
28
+ class ValidationErrorLocInner(BaseModel):
29
+ """
30
+ ValidationErrorLocInner
31
+ """
32
+
33
+ # data type: str
34
+ anyof_schema_1_validator: Optional[StrictStr] = None
35
+ # data type: int
36
+ anyof_schema_2_validator: Optional[StrictInt] = None
37
+ if TYPE_CHECKING:
38
+ actual_instance: Optional[Union[int, str]] = None
39
+ else:
40
+ actual_instance: Any = None
41
+ any_of_schemas: Set[str] = { "int", "str" }
42
+
43
+ model_config = {
44
+ "validate_assignment": True,
45
+ "protected_namespaces": (),
46
+ }
47
+
48
+ def __init__(self, *args, **kwargs) -> None:
49
+ if args:
50
+ if len(args) > 1:
51
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
52
+ if kwargs:
53
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
54
+ super().__init__(actual_instance=args[0])
55
+ else:
56
+ super().__init__(**kwargs)
57
+
58
+ @field_validator('actual_instance')
59
+ def actual_instance_must_validate_anyof(cls, v):
60
+ instance = ValidationErrorLocInner.model_construct()
61
+ error_messages = []
62
+ # validate data type: str
63
+ try:
64
+ instance.anyof_schema_1_validator = v
65
+ return v
66
+ except (ValidationError, ValueError) as e:
67
+ error_messages.append(str(e))
68
+ # validate data type: int
69
+ try:
70
+ instance.anyof_schema_2_validator = v
71
+ return v
72
+ except (ValidationError, ValueError) as e:
73
+ error_messages.append(str(e))
74
+ if error_messages:
75
+ # no match
76
+ raise ValueError("No match found when setting the actual_instance in ValidationErrorLocInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages))
77
+ else:
78
+ return v
79
+
80
+ @classmethod
81
+ def from_dict(cls, obj: Dict[str, Any]) -> Self:
82
+ return cls.from_json(json.dumps(obj))
83
+
84
+ @classmethod
85
+ def from_json(cls, json_str: str) -> Self:
86
+ """Returns the object represented by the json string"""
87
+ instance = cls.model_construct()
88
+ error_messages = []
89
+ # deserialize data into str
90
+ try:
91
+ # validation
92
+ instance.anyof_schema_1_validator = json.loads(json_str)
93
+ # assign value to actual_instance
94
+ instance.actual_instance = instance.anyof_schema_1_validator
95
+ return instance
96
+ except (ValidationError, ValueError) as e:
97
+ error_messages.append(str(e))
98
+ # deserialize data into int
99
+ try:
100
+ # validation
101
+ instance.anyof_schema_2_validator = json.loads(json_str)
102
+ # assign value to actual_instance
103
+ instance.actual_instance = instance.anyof_schema_2_validator
104
+ return instance
105
+ except (ValidationError, ValueError) as e:
106
+ error_messages.append(str(e))
107
+
108
+ if error_messages:
109
+ # no match
110
+ raise ValueError("No match found when deserializing the JSON string into ValidationErrorLocInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages))
111
+ else:
112
+ return instance
113
+
114
+ def to_json(self) -> str:
115
+ """Returns the JSON representation of the actual instance"""
116
+ if self.actual_instance is None:
117
+ return "null"
118
+
119
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
120
+ return self.actual_instance.to_json()
121
+ else:
122
+ return json.dumps(self.actual_instance)
123
+
124
+ def to_dict(self) -> Optional[Union[Dict[str, Any], int, str]]:
125
+ """Returns the dict representation of the actual instance"""
126
+ if self.actual_instance is None:
127
+ return None
128
+
129
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
130
+ return self.actual_instance.to_dict()
131
+ else:
132
+ return self.actual_instance
133
+
134
+ def to_str(self) -> str:
135
+ """Returns the string representation of the actual instance"""
136
+ return pprint.pformat(self.model_dump())
137
+
138
+