hindsight-client 0.2.1__py3-none-any.whl → 0.4.0__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 (60) hide show
  1. hindsight_client/__init__.py +9 -8
  2. hindsight_client/hindsight_client.py +396 -59
  3. {hindsight_client-0.2.1.dist-info → hindsight_client-0.4.0.dist-info}/METADATA +1 -1
  4. hindsight_client-0.4.0.dist-info/RECORD +89 -0
  5. hindsight_client_api/__init__.py +27 -0
  6. hindsight_client_api/api/__init__.py +2 -0
  7. hindsight_client_api/api/banks_api.py +1012 -131
  8. hindsight_client_api/api/directives_api.py +1619 -0
  9. hindsight_client_api/api/entities_api.py +29 -9
  10. hindsight_client_api/api/memory_api.py +713 -73
  11. hindsight_client_api/api/mental_models_api.py +1897 -0
  12. hindsight_client_api/api/monitoring_api.py +246 -0
  13. hindsight_client_api/api/operations_api.py +350 -4
  14. hindsight_client_api/models/__init__.py +25 -0
  15. hindsight_client_api/models/add_background_request.py +2 -2
  16. hindsight_client_api/models/async_operation_submit_response.py +89 -0
  17. hindsight_client_api/models/background_response.py +10 -3
  18. hindsight_client_api/models/bank_list_item.py +6 -6
  19. hindsight_client_api/models/bank_profile_response.py +11 -4
  20. hindsight_client_api/models/bank_stats_response.py +15 -4
  21. hindsight_client_api/models/consolidation_response.py +89 -0
  22. hindsight_client_api/models/create_bank_request.py +8 -1
  23. hindsight_client_api/models/create_directive_request.py +95 -0
  24. hindsight_client_api/models/create_mental_model_request.py +100 -0
  25. hindsight_client_api/models/create_mental_model_response.py +87 -0
  26. hindsight_client_api/models/directive_list_response.py +95 -0
  27. hindsight_client_api/models/directive_response.py +113 -0
  28. hindsight_client_api/models/document_response.py +5 -3
  29. hindsight_client_api/models/entity_list_response.py +9 -3
  30. hindsight_client_api/models/features_info.py +91 -0
  31. hindsight_client_api/models/graph_data_response.py +4 -2
  32. hindsight_client_api/models/list_tags_response.py +101 -0
  33. hindsight_client_api/models/memory_item.py +9 -2
  34. hindsight_client_api/models/mental_model_list_response.py +95 -0
  35. hindsight_client_api/models/mental_model_response.py +126 -0
  36. hindsight_client_api/models/mental_model_trigger.py +87 -0
  37. hindsight_client_api/models/operation_response.py +1 -1
  38. hindsight_client_api/models/operation_status_response.py +131 -0
  39. hindsight_client_api/models/operations_list_response.py +8 -2
  40. hindsight_client_api/models/recall_request.py +22 -3
  41. hindsight_client_api/models/recall_result.py +9 -2
  42. hindsight_client_api/models/reflect_based_on.py +115 -0
  43. hindsight_client_api/models/reflect_directive.py +91 -0
  44. hindsight_client_api/models/reflect_include_options.py +13 -2
  45. hindsight_client_api/models/reflect_llm_call.py +89 -0
  46. hindsight_client_api/models/reflect_mental_model.py +96 -0
  47. hindsight_client_api/models/reflect_request.py +22 -3
  48. hindsight_client_api/models/reflect_response.py +34 -11
  49. hindsight_client_api/models/reflect_tool_call.py +100 -0
  50. hindsight_client_api/models/reflect_trace.py +105 -0
  51. hindsight_client_api/models/retain_request.py +10 -3
  52. hindsight_client_api/models/retain_response.py +21 -3
  53. hindsight_client_api/models/tag_item.py +89 -0
  54. hindsight_client_api/models/token_usage.py +91 -0
  55. hindsight_client_api/models/tool_calls_include_options.py +87 -0
  56. hindsight_client_api/models/update_directive_request.py +120 -0
  57. hindsight_client_api/models/update_mental_model_request.py +125 -0
  58. hindsight_client_api/models/version_response.py +93 -0
  59. hindsight_client-0.2.1.dist-info/RECORD +0 -62
  60. {hindsight_client-0.2.1.dist-info → hindsight_client-0.4.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,113 @@
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, StrictBool, StrictInt, 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 DirectiveResponse(BaseModel):
26
+ """
27
+ Response model for a directive.
28
+ """ # noqa: E501
29
+ id: StrictStr
30
+ bank_id: StrictStr
31
+ name: StrictStr
32
+ content: StrictStr
33
+ priority: Optional[StrictInt] = 0
34
+ is_active: Optional[StrictBool] = True
35
+ tags: Optional[List[StrictStr]] = None
36
+ created_at: Optional[StrictStr] = None
37
+ updated_at: Optional[StrictStr] = None
38
+ __properties: ClassVar[List[str]] = ["id", "bank_id", "name", "content", "priority", "is_active", "tags", "created_at", "updated_at"]
39
+
40
+ model_config = ConfigDict(
41
+ populate_by_name=True,
42
+ validate_assignment=True,
43
+ protected_namespaces=(),
44
+ )
45
+
46
+
47
+ def to_str(self) -> str:
48
+ """Returns the string representation of the model using alias"""
49
+ return pprint.pformat(self.model_dump(by_alias=True))
50
+
51
+ def to_json(self) -> str:
52
+ """Returns the JSON representation of the model using alias"""
53
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54
+ return json.dumps(self.to_dict())
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of DirectiveResponse from a JSON string"""
59
+ return cls.from_dict(json.loads(json_str))
60
+
61
+ def to_dict(self) -> Dict[str, Any]:
62
+ """Return the dictionary representation of the model using alias.
63
+
64
+ This has the following differences from calling pydantic's
65
+ `self.model_dump(by_alias=True)`:
66
+
67
+ * `None` is only added to the output dict for nullable fields that
68
+ were set at model initialization. Other fields with value `None`
69
+ are ignored.
70
+ """
71
+ excluded_fields: Set[str] = set([
72
+ ])
73
+
74
+ _dict = self.model_dump(
75
+ by_alias=True,
76
+ exclude=excluded_fields,
77
+ exclude_none=True,
78
+ )
79
+ # set to None if created_at (nullable) is None
80
+ # and model_fields_set contains the field
81
+ if self.created_at is None and "created_at" in self.model_fields_set:
82
+ _dict['created_at'] = None
83
+
84
+ # set to None if updated_at (nullable) is None
85
+ # and model_fields_set contains the field
86
+ if self.updated_at is None and "updated_at" in self.model_fields_set:
87
+ _dict['updated_at'] = None
88
+
89
+ return _dict
90
+
91
+ @classmethod
92
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93
+ """Create an instance of DirectiveResponse from a dict"""
94
+ if obj is None:
95
+ return None
96
+
97
+ if not isinstance(obj, dict):
98
+ return cls.model_validate(obj)
99
+
100
+ _obj = cls.model_validate({
101
+ "id": obj.get("id"),
102
+ "bank_id": obj.get("bank_id"),
103
+ "name": obj.get("name"),
104
+ "content": obj.get("content"),
105
+ "priority": obj.get("priority") if obj.get("priority") is not None else 0,
106
+ "is_active": obj.get("is_active") if obj.get("is_active") is not None else True,
107
+ "tags": obj.get("tags"),
108
+ "created_at": obj.get("created_at"),
109
+ "updated_at": obj.get("updated_at")
110
+ })
111
+ return _obj
112
+
113
+
@@ -17,7 +17,7 @@ import pprint
17
17
  import re # noqa: F401
18
18
  import json
19
19
 
20
- from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
21
21
  from typing import Any, ClassVar, Dict, List, Optional
22
22
  from typing import Optional, Set
23
23
  from typing_extensions import Self
@@ -33,7 +33,8 @@ class DocumentResponse(BaseModel):
33
33
  created_at: StrictStr
34
34
  updated_at: StrictStr
35
35
  memory_unit_count: StrictInt
36
- __properties: ClassVar[List[str]] = ["id", "bank_id", "original_text", "content_hash", "created_at", "updated_at", "memory_unit_count"]
36
+ tags: Optional[List[StrictStr]] = Field(default=None, description="Tags associated with this document")
37
+ __properties: ClassVar[List[str]] = ["id", "bank_id", "original_text", "content_hash", "created_at", "updated_at", "memory_unit_count", "tags"]
37
38
 
38
39
  model_config = ConfigDict(
39
40
  populate_by_name=True,
@@ -97,7 +98,8 @@ class DocumentResponse(BaseModel):
97
98
  "content_hash": obj.get("content_hash"),
98
99
  "created_at": obj.get("created_at"),
99
100
  "updated_at": obj.get("updated_at"),
100
- "memory_unit_count": obj.get("memory_unit_count")
101
+ "memory_unit_count": obj.get("memory_unit_count"),
102
+ "tags": obj.get("tags")
101
103
  })
102
104
  return _obj
103
105
 
@@ -17,7 +17,7 @@ import pprint
17
17
  import re # noqa: F401
18
18
  import json
19
19
 
20
- from pydantic import BaseModel, ConfigDict
20
+ from pydantic import BaseModel, ConfigDict, StrictInt
21
21
  from typing import Any, ClassVar, Dict, List
22
22
  from hindsight_client_api.models.entity_list_item import EntityListItem
23
23
  from typing import Optional, Set
@@ -28,7 +28,10 @@ class EntityListResponse(BaseModel):
28
28
  Response model for entity list endpoint.
29
29
  """ # noqa: E501
30
30
  items: List[EntityListItem]
31
- __properties: ClassVar[List[str]] = ["items"]
31
+ total: StrictInt
32
+ limit: StrictInt
33
+ offset: StrictInt
34
+ __properties: ClassVar[List[str]] = ["items", "total", "limit", "offset"]
32
35
 
33
36
  model_config = ConfigDict(
34
37
  populate_by_name=True,
@@ -88,7 +91,10 @@ class EntityListResponse(BaseModel):
88
91
  return cls.model_validate(obj)
89
92
 
90
93
  _obj = cls.model_validate({
91
- "items": [EntityListItem.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None
94
+ "items": [EntityListItem.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None,
95
+ "total": obj.get("total"),
96
+ "limit": obj.get("limit"),
97
+ "offset": obj.get("offset")
92
98
  })
93
99
  return _obj
94
100
 
@@ -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: 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, StrictBool
21
+ from typing import Any, ClassVar, Dict, List
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class FeaturesInfo(BaseModel):
26
+ """
27
+ Feature flags indicating which capabilities are enabled.
28
+ """ # noqa: E501
29
+ observations: StrictBool = Field(description="Whether observations (auto-consolidation) are enabled")
30
+ mcp: StrictBool = Field(description="Whether MCP (Model Context Protocol) server is enabled")
31
+ worker: StrictBool = Field(description="Whether the background worker is enabled")
32
+ __properties: ClassVar[List[str]] = ["observations", "mcp", "worker"]
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 FeaturesInfo 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
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of FeaturesInfo from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate({
85
+ "observations": obj.get("observations"),
86
+ "mcp": obj.get("mcp"),
87
+ "worker": obj.get("worker")
88
+ })
89
+ return _obj
90
+
91
+
@@ -30,7 +30,8 @@ class GraphDataResponse(BaseModel):
30
30
  edges: List[Dict[str, Any]]
31
31
  table_rows: List[Dict[str, Any]]
32
32
  total_units: StrictInt
33
- __properties: ClassVar[List[str]] = ["nodes", "edges", "table_rows", "total_units"]
33
+ limit: StrictInt
34
+ __properties: ClassVar[List[str]] = ["nodes", "edges", "table_rows", "total_units", "limit"]
34
35
 
35
36
  model_config = ConfigDict(
36
37
  populate_by_name=True,
@@ -86,7 +87,8 @@ class GraphDataResponse(BaseModel):
86
87
  "nodes": obj.get("nodes"),
87
88
  "edges": obj.get("edges"),
88
89
  "table_rows": obj.get("table_rows"),
89
- "total_units": obj.get("total_units")
90
+ "total_units": obj.get("total_units"),
91
+ "limit": obj.get("limit")
90
92
  })
91
93
  return _obj
92
94
 
@@ -0,0 +1,101 @@
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, StrictInt
21
+ from typing import Any, ClassVar, Dict, List
22
+ from hindsight_client_api.models.tag_item import TagItem
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class ListTagsResponse(BaseModel):
27
+ """
28
+ Response model for list tags endpoint.
29
+ """ # noqa: E501
30
+ items: List[TagItem]
31
+ total: StrictInt
32
+ limit: StrictInt
33
+ offset: StrictInt
34
+ __properties: ClassVar[List[str]] = ["items", "total", "limit", "offset"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50
+ return json.dumps(self.to_dict())
51
+
52
+ @classmethod
53
+ def from_json(cls, json_str: str) -> Optional[Self]:
54
+ """Create an instance of ListTagsResponse from a JSON string"""
55
+ return cls.from_dict(json.loads(json_str))
56
+
57
+ def to_dict(self) -> Dict[str, Any]:
58
+ """Return the dictionary representation of the model using alias.
59
+
60
+ This has the following differences from calling pydantic's
61
+ `self.model_dump(by_alias=True)`:
62
+
63
+ * `None` is only added to the output dict for nullable fields that
64
+ were set at model initialization. Other fields with value `None`
65
+ are ignored.
66
+ """
67
+ excluded_fields: Set[str] = set([
68
+ ])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ # override the default output from pydantic by calling `to_dict()` of each item in items (list)
76
+ _items = []
77
+ if self.items:
78
+ for _item_items in self.items:
79
+ if _item_items:
80
+ _items.append(_item_items.to_dict())
81
+ _dict['items'] = _items
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of ListTagsResponse from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "items": [TagItem.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None,
95
+ "total": obj.get("total"),
96
+ "limit": obj.get("limit"),
97
+ "offset": obj.get("offset")
98
+ })
99
+ return _obj
100
+
101
+
@@ -34,7 +34,8 @@ class MemoryItem(BaseModel):
34
34
  metadata: Optional[Dict[str, StrictStr]] = None
35
35
  document_id: Optional[StrictStr] = None
36
36
  entities: Optional[List[EntityInput]] = None
37
- __properties: ClassVar[List[str]] = ["content", "timestamp", "context", "metadata", "document_id", "entities"]
37
+ tags: Optional[List[StrictStr]] = None
38
+ __properties: ClassVar[List[str]] = ["content", "timestamp", "context", "metadata", "document_id", "entities", "tags"]
38
39
 
39
40
  model_config = ConfigDict(
40
41
  populate_by_name=True,
@@ -107,6 +108,11 @@ class MemoryItem(BaseModel):
107
108
  if self.entities is None and "entities" in self.model_fields_set:
108
109
  _dict['entities'] = None
109
110
 
111
+ # set to None if tags (nullable) is None
112
+ # and model_fields_set contains the field
113
+ if self.tags is None and "tags" in self.model_fields_set:
114
+ _dict['tags'] = None
115
+
110
116
  return _dict
111
117
 
112
118
  @classmethod
@@ -124,7 +130,8 @@ class MemoryItem(BaseModel):
124
130
  "context": obj.get("context"),
125
131
  "metadata": obj.get("metadata"),
126
132
  "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
133
+ "entities": [EntityInput.from_dict(_item) for _item in obj["entities"]] if obj.get("entities") is not None else None,
134
+ "tags": obj.get("tags")
128
135
  })
129
136
  return _obj
130
137
 
@@ -0,0 +1,95 @@
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
21
+ from typing import Any, ClassVar, Dict, List
22
+ from hindsight_client_api.models.mental_model_response import MentalModelResponse
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class MentalModelListResponse(BaseModel):
27
+ """
28
+ Response model for listing mental models.
29
+ """ # noqa: E501
30
+ items: List[MentalModelResponse]
31
+ __properties: ClassVar[List[str]] = ["items"]
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 MentalModelListResponse 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 each item in items (list)
73
+ _items = []
74
+ if self.items:
75
+ for _item_items in self.items:
76
+ if _item_items:
77
+ _items.append(_item_items.to_dict())
78
+ _dict['items'] = _items
79
+ return _dict
80
+
81
+ @classmethod
82
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
83
+ """Create an instance of MentalModelListResponse from a dict"""
84
+ if obj is None:
85
+ return None
86
+
87
+ if not isinstance(obj, dict):
88
+ return cls.model_validate(obj)
89
+
90
+ _obj = cls.model_validate({
91
+ "items": [MentalModelResponse.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None
92
+ })
93
+ return _obj
94
+
95
+
@@ -0,0 +1,126 @@
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, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from hindsight_client_api.models.mental_model_trigger import MentalModelTrigger
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class MentalModelResponse(BaseModel):
27
+ """
28
+ Response model for a mental model (stored reflect response).
29
+ """ # noqa: E501
30
+ id: StrictStr
31
+ bank_id: StrictStr
32
+ name: StrictStr
33
+ source_query: StrictStr
34
+ content: StrictStr
35
+ tags: Optional[List[StrictStr]] = None
36
+ max_tokens: Optional[StrictInt] = 2048
37
+ trigger: Optional[MentalModelTrigger] = None
38
+ last_refreshed_at: Optional[StrictStr] = None
39
+ created_at: Optional[StrictStr] = None
40
+ reflect_response: Optional[Dict[str, Any]] = None
41
+ __properties: ClassVar[List[str]] = ["id", "bank_id", "name", "source_query", "content", "tags", "max_tokens", "trigger", "last_refreshed_at", "created_at", "reflect_response"]
42
+
43
+ model_config = ConfigDict(
44
+ populate_by_name=True,
45
+ validate_assignment=True,
46
+ protected_namespaces=(),
47
+ )
48
+
49
+
50
+ def to_str(self) -> str:
51
+ """Returns the string representation of the model using alias"""
52
+ return pprint.pformat(self.model_dump(by_alias=True))
53
+
54
+ def to_json(self) -> str:
55
+ """Returns the JSON representation of the model using alias"""
56
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
57
+ return json.dumps(self.to_dict())
58
+
59
+ @classmethod
60
+ def from_json(cls, json_str: str) -> Optional[Self]:
61
+ """Create an instance of MentalModelResponse from a JSON string"""
62
+ return cls.from_dict(json.loads(json_str))
63
+
64
+ def to_dict(self) -> Dict[str, Any]:
65
+ """Return the dictionary representation of the model using alias.
66
+
67
+ This has the following differences from calling pydantic's
68
+ `self.model_dump(by_alias=True)`:
69
+
70
+ * `None` is only added to the output dict for nullable fields that
71
+ were set at model initialization. Other fields with value `None`
72
+ are ignored.
73
+ """
74
+ excluded_fields: Set[str] = set([
75
+ ])
76
+
77
+ _dict = self.model_dump(
78
+ by_alias=True,
79
+ exclude=excluded_fields,
80
+ exclude_none=True,
81
+ )
82
+ # override the default output from pydantic by calling `to_dict()` of trigger
83
+ if self.trigger:
84
+ _dict['trigger'] = self.trigger.to_dict()
85
+ # set to None if last_refreshed_at (nullable) is None
86
+ # and model_fields_set contains the field
87
+ if self.last_refreshed_at is None and "last_refreshed_at" in self.model_fields_set:
88
+ _dict['last_refreshed_at'] = None
89
+
90
+ # set to None if created_at (nullable) is None
91
+ # and model_fields_set contains the field
92
+ if self.created_at is None and "created_at" in self.model_fields_set:
93
+ _dict['created_at'] = None
94
+
95
+ # set to None if reflect_response (nullable) is None
96
+ # and model_fields_set contains the field
97
+ if self.reflect_response is None and "reflect_response" in self.model_fields_set:
98
+ _dict['reflect_response'] = None
99
+
100
+ return _dict
101
+
102
+ @classmethod
103
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
104
+ """Create an instance of MentalModelResponse from a dict"""
105
+ if obj is None:
106
+ return None
107
+
108
+ if not isinstance(obj, dict):
109
+ return cls.model_validate(obj)
110
+
111
+ _obj = cls.model_validate({
112
+ "id": obj.get("id"),
113
+ "bank_id": obj.get("bank_id"),
114
+ "name": obj.get("name"),
115
+ "source_query": obj.get("source_query"),
116
+ "content": obj.get("content"),
117
+ "tags": obj.get("tags"),
118
+ "max_tokens": obj.get("max_tokens") if obj.get("max_tokens") is not None else 2048,
119
+ "trigger": MentalModelTrigger.from_dict(obj["trigger"]) if obj.get("trigger") is not None else None,
120
+ "last_refreshed_at": obj.get("last_refreshed_at"),
121
+ "created_at": obj.get("created_at"),
122
+ "reflect_response": obj.get("reflect_response")
123
+ })
124
+ return _obj
125
+
126
+