hindsight-client 0.2.1__py3-none-any.whl → 0.3.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.
- hindsight_client/hindsight_client.py +2 -0
- {hindsight_client-0.2.1.dist-info → hindsight_client-0.3.0.dist-info}/METADATA +1 -1
- {hindsight_client-0.2.1.dist-info → hindsight_client-0.3.0.dist-info}/RECORD +22 -19
- hindsight_client_api/__init__.py +3 -0
- hindsight_client_api/api/banks_api.py +15 -0
- hindsight_client_api/api/entities_api.py +20 -3
- hindsight_client_api/api/memory_api.py +713 -73
- hindsight_client_api/models/__init__.py +3 -0
- hindsight_client_api/models/document_response.py +5 -3
- hindsight_client_api/models/entity_list_response.py +9 -3
- hindsight_client_api/models/graph_data_response.py +4 -2
- hindsight_client_api/models/list_tags_response.py +101 -0
- hindsight_client_api/models/memory_item.py +9 -2
- hindsight_client_api/models/recall_request.py +22 -3
- hindsight_client_api/models/recall_result.py +9 -2
- hindsight_client_api/models/reflect_request.py +22 -3
- hindsight_client_api/models/reflect_response.py +13 -2
- hindsight_client_api/models/retain_request.py +10 -3
- hindsight_client_api/models/retain_response.py +21 -3
- hindsight_client_api/models/tag_item.py +89 -0
- hindsight_client_api/models/token_usage.py +91 -0
- {hindsight_client-0.2.1.dist-info → hindsight_client-0.3.0.dist-info}/WHEEL +0 -0
|
@@ -42,6 +42,7 @@ from hindsight_client_api.models.http_validation_error import HTTPValidationErro
|
|
|
42
42
|
from hindsight_client_api.models.include_options import IncludeOptions
|
|
43
43
|
from hindsight_client_api.models.list_documents_response import ListDocumentsResponse
|
|
44
44
|
from hindsight_client_api.models.list_memory_units_response import ListMemoryUnitsResponse
|
|
45
|
+
from hindsight_client_api.models.list_tags_response import ListTagsResponse
|
|
45
46
|
from hindsight_client_api.models.memory_item import MemoryItem
|
|
46
47
|
from hindsight_client_api.models.operation_response import OperationResponse
|
|
47
48
|
from hindsight_client_api.models.operations_list_response import OperationsListResponse
|
|
@@ -54,6 +55,8 @@ from hindsight_client_api.models.reflect_request import ReflectRequest
|
|
|
54
55
|
from hindsight_client_api.models.reflect_response import ReflectResponse
|
|
55
56
|
from hindsight_client_api.models.retain_request import RetainRequest
|
|
56
57
|
from hindsight_client_api.models.retain_response import RetainResponse
|
|
58
|
+
from hindsight_client_api.models.tag_item import TagItem
|
|
59
|
+
from hindsight_client_api.models.token_usage import TokenUsage
|
|
57
60
|
from hindsight_client_api.models.update_disposition_request import UpdateDispositionRequest
|
|
58
61
|
from hindsight_client_api.models.validation_error import ValidationError
|
|
59
62
|
from hindsight_client_api.models.validation_error_loc_inner import ValidationErrorLocInner
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -17,7 +17,7 @@ import pprint
|
|
|
17
17
|
import re # noqa: F401
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
|
-
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
|
|
21
21
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
22
|
from hindsight_client_api.models.budget import Budget
|
|
23
23
|
from hindsight_client_api.models.include_options import IncludeOptions
|
|
@@ -35,7 +35,19 @@ class RecallRequest(BaseModel):
|
|
|
35
35
|
trace: Optional[StrictBool] = False
|
|
36
36
|
query_timestamp: Optional[StrictStr] = None
|
|
37
37
|
include: Optional[IncludeOptions] = Field(default=None, description="Options for including additional data (entities are included by default)")
|
|
38
|
-
|
|
38
|
+
tags: Optional[List[StrictStr]] = None
|
|
39
|
+
tags_match: Optional[StrictStr] = Field(default='any', description="How to match tags: 'any' (OR, includes untagged), 'all' (AND, includes untagged), 'any_strict' (OR, excludes untagged), 'all_strict' (AND, excludes untagged).")
|
|
40
|
+
__properties: ClassVar[List[str]] = ["query", "types", "budget", "max_tokens", "trace", "query_timestamp", "include", "tags", "tags_match"]
|
|
41
|
+
|
|
42
|
+
@field_validator('tags_match')
|
|
43
|
+
def tags_match_validate_enum(cls, value):
|
|
44
|
+
"""Validates the enum"""
|
|
45
|
+
if value is None:
|
|
46
|
+
return value
|
|
47
|
+
|
|
48
|
+
if value not in set(['any', 'all', 'any_strict', 'all_strict']):
|
|
49
|
+
raise ValueError("must be one of enum values ('any', 'all', 'any_strict', 'all_strict')")
|
|
50
|
+
return value
|
|
39
51
|
|
|
40
52
|
model_config = ConfigDict(
|
|
41
53
|
populate_by_name=True,
|
|
@@ -89,6 +101,11 @@ class RecallRequest(BaseModel):
|
|
|
89
101
|
if self.query_timestamp is None and "query_timestamp" in self.model_fields_set:
|
|
90
102
|
_dict['query_timestamp'] = None
|
|
91
103
|
|
|
104
|
+
# set to None if tags (nullable) is None
|
|
105
|
+
# and model_fields_set contains the field
|
|
106
|
+
if self.tags is None and "tags" in self.model_fields_set:
|
|
107
|
+
_dict['tags'] = None
|
|
108
|
+
|
|
92
109
|
return _dict
|
|
93
110
|
|
|
94
111
|
@classmethod
|
|
@@ -107,7 +124,9 @@ class RecallRequest(BaseModel):
|
|
|
107
124
|
"max_tokens": obj.get("max_tokens") if obj.get("max_tokens") is not None else 4096,
|
|
108
125
|
"trace": obj.get("trace") if obj.get("trace") is not None else False,
|
|
109
126
|
"query_timestamp": obj.get("query_timestamp"),
|
|
110
|
-
"include": IncludeOptions.from_dict(obj["include"]) if obj.get("include") is not None else None
|
|
127
|
+
"include": IncludeOptions.from_dict(obj["include"]) if obj.get("include") is not None else None,
|
|
128
|
+
"tags": obj.get("tags"),
|
|
129
|
+
"tags_match": obj.get("tags_match") if obj.get("tags_match") is not None else 'any'
|
|
111
130
|
})
|
|
112
131
|
return _obj
|
|
113
132
|
|
|
@@ -37,7 +37,8 @@ class RecallResult(BaseModel):
|
|
|
37
37
|
document_id: Optional[StrictStr] = None
|
|
38
38
|
metadata: Optional[Dict[str, StrictStr]] = None
|
|
39
39
|
chunk_id: Optional[StrictStr] = None
|
|
40
|
-
|
|
40
|
+
tags: Optional[List[StrictStr]] = None
|
|
41
|
+
__properties: ClassVar[List[str]] = ["id", "text", "type", "entities", "context", "occurred_start", "occurred_end", "mentioned_at", "document_id", "metadata", "chunk_id", "tags"]
|
|
41
42
|
|
|
42
43
|
model_config = ConfigDict(
|
|
43
44
|
populate_by_name=True,
|
|
@@ -123,6 +124,11 @@ class RecallResult(BaseModel):
|
|
|
123
124
|
if self.chunk_id is None and "chunk_id" in self.model_fields_set:
|
|
124
125
|
_dict['chunk_id'] = None
|
|
125
126
|
|
|
127
|
+
# set to None if tags (nullable) is None
|
|
128
|
+
# and model_fields_set contains the field
|
|
129
|
+
if self.tags is None and "tags" in self.model_fields_set:
|
|
130
|
+
_dict['tags'] = None
|
|
131
|
+
|
|
126
132
|
return _dict
|
|
127
133
|
|
|
128
134
|
@classmethod
|
|
@@ -145,7 +151,8 @@ class RecallResult(BaseModel):
|
|
|
145
151
|
"mentioned_at": obj.get("mentioned_at"),
|
|
146
152
|
"document_id": obj.get("document_id"),
|
|
147
153
|
"metadata": obj.get("metadata"),
|
|
148
|
-
"chunk_id": obj.get("chunk_id")
|
|
154
|
+
"chunk_id": obj.get("chunk_id"),
|
|
155
|
+
"tags": obj.get("tags")
|
|
149
156
|
})
|
|
150
157
|
return _obj
|
|
151
158
|
|
|
@@ -17,7 +17,7 @@ import pprint
|
|
|
17
17
|
import re # noqa: F401
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
|
-
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
|
|
21
21
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
22
|
from hindsight_client_api.models.budget import Budget
|
|
23
23
|
from hindsight_client_api.models.reflect_include_options import ReflectIncludeOptions
|
|
@@ -34,7 +34,19 @@ class ReflectRequest(BaseModel):
|
|
|
34
34
|
max_tokens: Optional[StrictInt] = Field(default=4096, description="Maximum tokens for the response")
|
|
35
35
|
include: Optional[ReflectIncludeOptions] = Field(default=None, description="Options for including additional data (disabled by default)")
|
|
36
36
|
response_schema: Optional[Dict[str, Any]] = None
|
|
37
|
-
|
|
37
|
+
tags: Optional[List[StrictStr]] = None
|
|
38
|
+
tags_match: Optional[StrictStr] = Field(default='any', description="How to match tags: 'any' (OR, includes untagged), 'all' (AND, includes untagged), 'any_strict' (OR, excludes untagged), 'all_strict' (AND, excludes untagged).")
|
|
39
|
+
__properties: ClassVar[List[str]] = ["query", "budget", "context", "max_tokens", "include", "response_schema", "tags", "tags_match"]
|
|
40
|
+
|
|
41
|
+
@field_validator('tags_match')
|
|
42
|
+
def tags_match_validate_enum(cls, value):
|
|
43
|
+
"""Validates the enum"""
|
|
44
|
+
if value is None:
|
|
45
|
+
return value
|
|
46
|
+
|
|
47
|
+
if value not in set(['any', 'all', 'any_strict', 'all_strict']):
|
|
48
|
+
raise ValueError("must be one of enum values ('any', 'all', 'any_strict', 'all_strict')")
|
|
49
|
+
return value
|
|
38
50
|
|
|
39
51
|
model_config = ConfigDict(
|
|
40
52
|
populate_by_name=True,
|
|
@@ -88,6 +100,11 @@ class ReflectRequest(BaseModel):
|
|
|
88
100
|
if self.response_schema is None and "response_schema" in self.model_fields_set:
|
|
89
101
|
_dict['response_schema'] = None
|
|
90
102
|
|
|
103
|
+
# set to None if tags (nullable) is None
|
|
104
|
+
# and model_fields_set contains the field
|
|
105
|
+
if self.tags is None and "tags" in self.model_fields_set:
|
|
106
|
+
_dict['tags'] = None
|
|
107
|
+
|
|
91
108
|
return _dict
|
|
92
109
|
|
|
93
110
|
@classmethod
|
|
@@ -105,7 +122,9 @@ class ReflectRequest(BaseModel):
|
|
|
105
122
|
"context": obj.get("context"),
|
|
106
123
|
"max_tokens": obj.get("max_tokens") if obj.get("max_tokens") is not None else 4096,
|
|
107
124
|
"include": ReflectIncludeOptions.from_dict(obj["include"]) if obj.get("include") is not None else None,
|
|
108
|
-
"response_schema": obj.get("response_schema")
|
|
125
|
+
"response_schema": obj.get("response_schema"),
|
|
126
|
+
"tags": obj.get("tags"),
|
|
127
|
+
"tags_match": obj.get("tags_match") if obj.get("tags_match") is not None else 'any'
|
|
109
128
|
})
|
|
110
129
|
return _obj
|
|
111
130
|
|
|
@@ -20,6 +20,7 @@ import json
|
|
|
20
20
|
from pydantic import BaseModel, ConfigDict, StrictStr
|
|
21
21
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
22
|
from hindsight_client_api.models.reflect_fact import ReflectFact
|
|
23
|
+
from hindsight_client_api.models.token_usage import TokenUsage
|
|
23
24
|
from typing import Optional, Set
|
|
24
25
|
from typing_extensions import Self
|
|
25
26
|
|
|
@@ -30,7 +31,8 @@ class ReflectResponse(BaseModel):
|
|
|
30
31
|
text: StrictStr
|
|
31
32
|
based_on: Optional[List[ReflectFact]] = None
|
|
32
33
|
structured_output: Optional[Dict[str, Any]] = None
|
|
33
|
-
|
|
34
|
+
usage: Optional[TokenUsage] = None
|
|
35
|
+
__properties: ClassVar[List[str]] = ["text", "based_on", "structured_output", "usage"]
|
|
34
36
|
|
|
35
37
|
model_config = ConfigDict(
|
|
36
38
|
populate_by_name=True,
|
|
@@ -78,11 +80,19 @@ class ReflectResponse(BaseModel):
|
|
|
78
80
|
if _item_based_on:
|
|
79
81
|
_items.append(_item_based_on.to_dict())
|
|
80
82
|
_dict['based_on'] = _items
|
|
83
|
+
# override the default output from pydantic by calling `to_dict()` of usage
|
|
84
|
+
if self.usage:
|
|
85
|
+
_dict['usage'] = self.usage.to_dict()
|
|
81
86
|
# set to None if structured_output (nullable) is None
|
|
82
87
|
# and model_fields_set contains the field
|
|
83
88
|
if self.structured_output is None and "structured_output" in self.model_fields_set:
|
|
84
89
|
_dict['structured_output'] = None
|
|
85
90
|
|
|
91
|
+
# set to None if usage (nullable) is None
|
|
92
|
+
# and model_fields_set contains the field
|
|
93
|
+
if self.usage is None and "usage" in self.model_fields_set:
|
|
94
|
+
_dict['usage'] = None
|
|
95
|
+
|
|
86
96
|
return _dict
|
|
87
97
|
|
|
88
98
|
@classmethod
|
|
@@ -97,7 +107,8 @@ class ReflectResponse(BaseModel):
|
|
|
97
107
|
_obj = cls.model_validate({
|
|
98
108
|
"text": obj.get("text"),
|
|
99
109
|
"based_on": [ReflectFact.from_dict(_item) for _item in obj["based_on"]] if obj.get("based_on") is not None else None,
|
|
100
|
-
"structured_output": obj.get("structured_output")
|
|
110
|
+
"structured_output": obj.get("structured_output"),
|
|
111
|
+
"usage": TokenUsage.from_dict(obj["usage"]) if obj.get("usage") is not None else None
|
|
101
112
|
})
|
|
102
113
|
return _obj
|
|
103
114
|
|
|
@@ -17,7 +17,7 @@ import pprint
|
|
|
17
17
|
import re # noqa: F401
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
|
-
from pydantic import BaseModel, ConfigDict, Field, StrictBool
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
|
|
21
21
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
22
|
from hindsight_client_api.models.memory_item import MemoryItem
|
|
23
23
|
from typing import Optional, Set
|
|
@@ -29,7 +29,8 @@ class RetainRequest(BaseModel):
|
|
|
29
29
|
""" # noqa: E501
|
|
30
30
|
items: List[MemoryItem]
|
|
31
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
|
-
|
|
32
|
+
document_tags: Optional[List[StrictStr]] = None
|
|
33
|
+
__properties: ClassVar[List[str]] = ["items", "async", "document_tags"]
|
|
33
34
|
|
|
34
35
|
model_config = ConfigDict(
|
|
35
36
|
populate_by_name=True,
|
|
@@ -77,6 +78,11 @@ class RetainRequest(BaseModel):
|
|
|
77
78
|
if _item_items:
|
|
78
79
|
_items.append(_item_items.to_dict())
|
|
79
80
|
_dict['items'] = _items
|
|
81
|
+
# set to None if document_tags (nullable) is None
|
|
82
|
+
# and model_fields_set contains the field
|
|
83
|
+
if self.document_tags is None and "document_tags" in self.model_fields_set:
|
|
84
|
+
_dict['document_tags'] = None
|
|
85
|
+
|
|
80
86
|
return _dict
|
|
81
87
|
|
|
82
88
|
@classmethod
|
|
@@ -90,7 +96,8 @@ class RetainRequest(BaseModel):
|
|
|
90
96
|
|
|
91
97
|
_obj = cls.model_validate({
|
|
92
98
|
"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
|
|
99
|
+
"async": obj.get("async") if obj.get("async") is not None else False,
|
|
100
|
+
"document_tags": obj.get("document_tags")
|
|
94
101
|
})
|
|
95
102
|
return _obj
|
|
96
103
|
|
|
@@ -18,7 +18,8 @@ import re # noqa: F401
|
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
20
|
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
|
|
21
|
-
from typing import Any, ClassVar, Dict, List
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from hindsight_client_api.models.token_usage import TokenUsage
|
|
22
23
|
from typing import Optional, Set
|
|
23
24
|
from typing_extensions import Self
|
|
24
25
|
|
|
@@ -30,7 +31,9 @@ class RetainResponse(BaseModel):
|
|
|
30
31
|
bank_id: StrictStr
|
|
31
32
|
items_count: StrictInt
|
|
32
33
|
var_async: StrictBool = Field(description="Whether the operation was processed asynchronously", alias="async")
|
|
33
|
-
|
|
34
|
+
operation_id: Optional[StrictStr] = None
|
|
35
|
+
usage: Optional[TokenUsage] = None
|
|
36
|
+
__properties: ClassVar[List[str]] = ["success", "bank_id", "items_count", "async", "operation_id", "usage"]
|
|
34
37
|
|
|
35
38
|
model_config = ConfigDict(
|
|
36
39
|
populate_by_name=True,
|
|
@@ -71,6 +74,19 @@ class RetainResponse(BaseModel):
|
|
|
71
74
|
exclude=excluded_fields,
|
|
72
75
|
exclude_none=True,
|
|
73
76
|
)
|
|
77
|
+
# override the default output from pydantic by calling `to_dict()` of usage
|
|
78
|
+
if self.usage:
|
|
79
|
+
_dict['usage'] = self.usage.to_dict()
|
|
80
|
+
# set to None if operation_id (nullable) is None
|
|
81
|
+
# and model_fields_set contains the field
|
|
82
|
+
if self.operation_id is None and "operation_id" in self.model_fields_set:
|
|
83
|
+
_dict['operation_id'] = None
|
|
84
|
+
|
|
85
|
+
# set to None if usage (nullable) is None
|
|
86
|
+
# and model_fields_set contains the field
|
|
87
|
+
if self.usage is None and "usage" in self.model_fields_set:
|
|
88
|
+
_dict['usage'] = None
|
|
89
|
+
|
|
74
90
|
return _dict
|
|
75
91
|
|
|
76
92
|
@classmethod
|
|
@@ -86,7 +102,9 @@ class RetainResponse(BaseModel):
|
|
|
86
102
|
"success": obj.get("success"),
|
|
87
103
|
"bank_id": obj.get("bank_id"),
|
|
88
104
|
"items_count": obj.get("items_count"),
|
|
89
|
-
"async": obj.get("async")
|
|
105
|
+
"async": obj.get("async"),
|
|
106
|
+
"operation_id": obj.get("operation_id"),
|
|
107
|
+
"usage": TokenUsage.from_dict(obj["usage"]) if obj.get("usage") is not None else None
|
|
90
108
|
})
|
|
91
109
|
return _obj
|
|
92
110
|
|
|
@@ -0,0 +1,89 @@
|
|
|
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, 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 TagItem(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
Single tag with usage count.
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
tag: StrictStr = Field(description="The tag value")
|
|
30
|
+
count: StrictInt = Field(description="Number of memories with this tag")
|
|
31
|
+
__properties: ClassVar[List[str]] = ["tag", "count"]
|
|
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 TagItem 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
|
+
return _dict
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
76
|
+
"""Create an instance of TagItem from a dict"""
|
|
77
|
+
if obj is None:
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
if not isinstance(obj, dict):
|
|
81
|
+
return cls.model_validate(obj)
|
|
82
|
+
|
|
83
|
+
_obj = cls.model_validate({
|
|
84
|
+
"tag": obj.get("tag"),
|
|
85
|
+
"count": obj.get("count")
|
|
86
|
+
})
|
|
87
|
+
return _obj
|
|
88
|
+
|
|
89
|
+
|