hindsight-client 0.3.0__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.
- hindsight_client/__init__.py +9 -8
- hindsight_client/hindsight_client.py +394 -59
- {hindsight_client-0.3.0.dist-info → hindsight_client-0.4.0.dist-info}/METADATA +1 -1
- hindsight_client-0.4.0.dist-info/RECORD +89 -0
- hindsight_client_api/__init__.py +24 -0
- hindsight_client_api/api/__init__.py +2 -0
- hindsight_client_api/api/banks_api.py +997 -131
- hindsight_client_api/api/directives_api.py +1619 -0
- hindsight_client_api/api/entities_api.py +9 -6
- hindsight_client_api/api/mental_models_api.py +1897 -0
- hindsight_client_api/api/monitoring_api.py +246 -0
- hindsight_client_api/api/operations_api.py +350 -4
- hindsight_client_api/models/__init__.py +22 -0
- hindsight_client_api/models/add_background_request.py +2 -2
- hindsight_client_api/models/async_operation_submit_response.py +89 -0
- hindsight_client_api/models/background_response.py +10 -3
- hindsight_client_api/models/bank_list_item.py +6 -6
- hindsight_client_api/models/bank_profile_response.py +11 -4
- hindsight_client_api/models/bank_stats_response.py +15 -4
- hindsight_client_api/models/consolidation_response.py +89 -0
- hindsight_client_api/models/create_bank_request.py +8 -1
- hindsight_client_api/models/create_directive_request.py +95 -0
- hindsight_client_api/models/create_mental_model_request.py +100 -0
- hindsight_client_api/models/create_mental_model_response.py +87 -0
- hindsight_client_api/models/directive_list_response.py +95 -0
- hindsight_client_api/models/directive_response.py +113 -0
- hindsight_client_api/models/features_info.py +91 -0
- hindsight_client_api/models/mental_model_list_response.py +95 -0
- hindsight_client_api/models/mental_model_response.py +126 -0
- hindsight_client_api/models/mental_model_trigger.py +87 -0
- hindsight_client_api/models/operation_response.py +1 -1
- hindsight_client_api/models/operation_status_response.py +131 -0
- hindsight_client_api/models/operations_list_response.py +8 -2
- hindsight_client_api/models/reflect_based_on.py +115 -0
- hindsight_client_api/models/reflect_directive.py +91 -0
- hindsight_client_api/models/reflect_include_options.py +13 -2
- hindsight_client_api/models/reflect_llm_call.py +89 -0
- hindsight_client_api/models/reflect_mental_model.py +96 -0
- hindsight_client_api/models/reflect_response.py +23 -11
- hindsight_client_api/models/reflect_tool_call.py +100 -0
- hindsight_client_api/models/reflect_trace.py +105 -0
- hindsight_client_api/models/tool_calls_include_options.py +87 -0
- hindsight_client_api/models/update_directive_request.py +120 -0
- hindsight_client_api/models/update_mental_model_request.py +125 -0
- hindsight_client_api/models/version_response.py +93 -0
- hindsight_client-0.3.0.dist-info/RECORD +0 -65
- {hindsight_client-0.3.0.dist-info → hindsight_client-0.4.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
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
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from hindsight_client_api.models.reflect_directive import ReflectDirective
|
|
23
|
+
from hindsight_client_api.models.reflect_fact import ReflectFact
|
|
24
|
+
from hindsight_client_api.models.reflect_mental_model import ReflectMentalModel
|
|
25
|
+
from typing import Optional, Set
|
|
26
|
+
from typing_extensions import Self
|
|
27
|
+
|
|
28
|
+
class ReflectBasedOn(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
Evidence the response is based on: memories, mental models, and directives.
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
memories: Optional[List[ReflectFact]] = Field(default=None, description="Memory facts used to generate the response")
|
|
33
|
+
mental_models: Optional[List[ReflectMentalModel]] = Field(default=None, description="Mental models used during reflection")
|
|
34
|
+
directives: Optional[List[ReflectDirective]] = Field(default=None, description="Directives applied during reflection")
|
|
35
|
+
__properties: ClassVar[List[str]] = ["memories", "mental_models", "directives"]
|
|
36
|
+
|
|
37
|
+
model_config = ConfigDict(
|
|
38
|
+
populate_by_name=True,
|
|
39
|
+
validate_assignment=True,
|
|
40
|
+
protected_namespaces=(),
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def to_str(self) -> str:
|
|
45
|
+
"""Returns the string representation of the model using alias"""
|
|
46
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
47
|
+
|
|
48
|
+
def to_json(self) -> str:
|
|
49
|
+
"""Returns the JSON representation of the model using alias"""
|
|
50
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
51
|
+
return json.dumps(self.to_dict())
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
55
|
+
"""Create an instance of ReflectBasedOn from a JSON string"""
|
|
56
|
+
return cls.from_dict(json.loads(json_str))
|
|
57
|
+
|
|
58
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
59
|
+
"""Return the dictionary representation of the model using alias.
|
|
60
|
+
|
|
61
|
+
This has the following differences from calling pydantic's
|
|
62
|
+
`self.model_dump(by_alias=True)`:
|
|
63
|
+
|
|
64
|
+
* `None` is only added to the output dict for nullable fields that
|
|
65
|
+
were set at model initialization. Other fields with value `None`
|
|
66
|
+
are ignored.
|
|
67
|
+
"""
|
|
68
|
+
excluded_fields: Set[str] = set([
|
|
69
|
+
])
|
|
70
|
+
|
|
71
|
+
_dict = self.model_dump(
|
|
72
|
+
by_alias=True,
|
|
73
|
+
exclude=excluded_fields,
|
|
74
|
+
exclude_none=True,
|
|
75
|
+
)
|
|
76
|
+
# override the default output from pydantic by calling `to_dict()` of each item in memories (list)
|
|
77
|
+
_items = []
|
|
78
|
+
if self.memories:
|
|
79
|
+
for _item_memories in self.memories:
|
|
80
|
+
if _item_memories:
|
|
81
|
+
_items.append(_item_memories.to_dict())
|
|
82
|
+
_dict['memories'] = _items
|
|
83
|
+
# override the default output from pydantic by calling `to_dict()` of each item in mental_models (list)
|
|
84
|
+
_items = []
|
|
85
|
+
if self.mental_models:
|
|
86
|
+
for _item_mental_models in self.mental_models:
|
|
87
|
+
if _item_mental_models:
|
|
88
|
+
_items.append(_item_mental_models.to_dict())
|
|
89
|
+
_dict['mental_models'] = _items
|
|
90
|
+
# override the default output from pydantic by calling `to_dict()` of each item in directives (list)
|
|
91
|
+
_items = []
|
|
92
|
+
if self.directives:
|
|
93
|
+
for _item_directives in self.directives:
|
|
94
|
+
if _item_directives:
|
|
95
|
+
_items.append(_item_directives.to_dict())
|
|
96
|
+
_dict['directives'] = _items
|
|
97
|
+
return _dict
|
|
98
|
+
|
|
99
|
+
@classmethod
|
|
100
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
101
|
+
"""Create an instance of ReflectBasedOn from a dict"""
|
|
102
|
+
if obj is None:
|
|
103
|
+
return None
|
|
104
|
+
|
|
105
|
+
if not isinstance(obj, dict):
|
|
106
|
+
return cls.model_validate(obj)
|
|
107
|
+
|
|
108
|
+
_obj = cls.model_validate({
|
|
109
|
+
"memories": [ReflectFact.from_dict(_item) for _item in obj["memories"]] if obj.get("memories") is not None else None,
|
|
110
|
+
"mental_models": [ReflectMentalModel.from_dict(_item) for _item in obj["mental_models"]] if obj.get("mental_models") is not None else None,
|
|
111
|
+
"directives": [ReflectDirective.from_dict(_item) for _item in obj["directives"]] if obj.get("directives") is not None else None
|
|
112
|
+
})
|
|
113
|
+
return _obj
|
|
114
|
+
|
|
115
|
+
|
|
@@ -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, StrictStr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class ReflectDirective(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
A directive applied during reflect.
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
id: StrictStr = Field(description="Directive ID")
|
|
30
|
+
name: StrictStr = Field(description="Directive name")
|
|
31
|
+
content: StrictStr = Field(description="Directive content")
|
|
32
|
+
__properties: ClassVar[List[str]] = ["id", "name", "content"]
|
|
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 ReflectDirective 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 ReflectDirective 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
|
+
"id": obj.get("id"),
|
|
86
|
+
"name": obj.get("name"),
|
|
87
|
+
"content": obj.get("content")
|
|
88
|
+
})
|
|
89
|
+
return _obj
|
|
90
|
+
|
|
91
|
+
|
|
@@ -19,6 +19,7 @@ import json
|
|
|
19
19
|
|
|
20
20
|
from pydantic import BaseModel, ConfigDict, Field
|
|
21
21
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from hindsight_client_api.models.tool_calls_include_options import ToolCallsIncludeOptions
|
|
22
23
|
from typing import Optional, Set
|
|
23
24
|
from typing_extensions import Self
|
|
24
25
|
|
|
@@ -27,7 +28,8 @@ class ReflectIncludeOptions(BaseModel):
|
|
|
27
28
|
Options for including additional data in reflect results.
|
|
28
29
|
""" # noqa: E501
|
|
29
30
|
facts: Optional[Dict[str, Any]] = Field(default=None, description="Options for including facts (based_on) in reflect results.")
|
|
30
|
-
|
|
31
|
+
tool_calls: Optional[ToolCallsIncludeOptions] = None
|
|
32
|
+
__properties: ClassVar[List[str]] = ["facts", "tool_calls"]
|
|
31
33
|
|
|
32
34
|
model_config = ConfigDict(
|
|
33
35
|
populate_by_name=True,
|
|
@@ -68,6 +70,14 @@ class ReflectIncludeOptions(BaseModel):
|
|
|
68
70
|
exclude=excluded_fields,
|
|
69
71
|
exclude_none=True,
|
|
70
72
|
)
|
|
73
|
+
# override the default output from pydantic by calling `to_dict()` of tool_calls
|
|
74
|
+
if self.tool_calls:
|
|
75
|
+
_dict['tool_calls'] = self.tool_calls.to_dict()
|
|
76
|
+
# set to None if tool_calls (nullable) is None
|
|
77
|
+
# and model_fields_set contains the field
|
|
78
|
+
if self.tool_calls is None and "tool_calls" in self.model_fields_set:
|
|
79
|
+
_dict['tool_calls'] = None
|
|
80
|
+
|
|
71
81
|
return _dict
|
|
72
82
|
|
|
73
83
|
@classmethod
|
|
@@ -80,7 +90,8 @@ class ReflectIncludeOptions(BaseModel):
|
|
|
80
90
|
return cls.model_validate(obj)
|
|
81
91
|
|
|
82
92
|
_obj = cls.model_validate({
|
|
83
|
-
"facts": obj.get("facts")
|
|
93
|
+
"facts": obj.get("facts"),
|
|
94
|
+
"tool_calls": ToolCallsIncludeOptions.from_dict(obj["tool_calls"]) if obj.get("tool_calls") is not None else None
|
|
84
95
|
})
|
|
85
96
|
return _obj
|
|
86
97
|
|
|
@@ -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 ReflectLLMCall(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
An LLM call made during reflect agent execution.
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
scope: StrictStr = Field(description="Call scope: agent_1, agent_2, final, etc.")
|
|
30
|
+
duration_ms: StrictInt = Field(description="Execution time in milliseconds")
|
|
31
|
+
__properties: ClassVar[List[str]] = ["scope", "duration_ms"]
|
|
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 ReflectLLMCall 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 ReflectLLMCall 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
|
+
"scope": obj.get("scope"),
|
|
85
|
+
"duration_ms": obj.get("duration_ms")
|
|
86
|
+
})
|
|
87
|
+
return _obj
|
|
88
|
+
|
|
89
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
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, 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 ReflectMentalModel(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
A mental model used during reflect.
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
id: StrictStr = Field(description="Mental model ID")
|
|
30
|
+
text: StrictStr = Field(description="Mental model content")
|
|
31
|
+
context: Optional[StrictStr] = None
|
|
32
|
+
__properties: ClassVar[List[str]] = ["id", "text", "context"]
|
|
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 ReflectMentalModel 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
|
+
# set to None if context (nullable) is None
|
|
74
|
+
# and model_fields_set contains the field
|
|
75
|
+
if self.context is None and "context" in self.model_fields_set:
|
|
76
|
+
_dict['context'] = None
|
|
77
|
+
|
|
78
|
+
return _dict
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
82
|
+
"""Create an instance of ReflectMentalModel from a dict"""
|
|
83
|
+
if obj is None:
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
if not isinstance(obj, dict):
|
|
87
|
+
return cls.model_validate(obj)
|
|
88
|
+
|
|
89
|
+
_obj = cls.model_validate({
|
|
90
|
+
"id": obj.get("id"),
|
|
91
|
+
"text": obj.get("text"),
|
|
92
|
+
"context": obj.get("context")
|
|
93
|
+
})
|
|
94
|
+
return _obj
|
|
95
|
+
|
|
96
|
+
|
|
@@ -19,7 +19,8 @@ import json
|
|
|
19
19
|
|
|
20
20
|
from pydantic import BaseModel, ConfigDict, StrictStr
|
|
21
21
|
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
-
from hindsight_client_api.models.
|
|
22
|
+
from hindsight_client_api.models.reflect_based_on import ReflectBasedOn
|
|
23
|
+
from hindsight_client_api.models.reflect_trace import ReflectTrace
|
|
23
24
|
from hindsight_client_api.models.token_usage import TokenUsage
|
|
24
25
|
from typing import Optional, Set
|
|
25
26
|
from typing_extensions import Self
|
|
@@ -29,10 +30,11 @@ class ReflectResponse(BaseModel):
|
|
|
29
30
|
Response model for think endpoint.
|
|
30
31
|
""" # noqa: E501
|
|
31
32
|
text: StrictStr
|
|
32
|
-
based_on: Optional[
|
|
33
|
+
based_on: Optional[ReflectBasedOn] = None
|
|
33
34
|
structured_output: Optional[Dict[str, Any]] = None
|
|
34
35
|
usage: Optional[TokenUsage] = None
|
|
35
|
-
|
|
36
|
+
trace: Optional[ReflectTrace] = None
|
|
37
|
+
__properties: ClassVar[List[str]] = ["text", "based_on", "structured_output", "usage", "trace"]
|
|
36
38
|
|
|
37
39
|
model_config = ConfigDict(
|
|
38
40
|
populate_by_name=True,
|
|
@@ -73,16 +75,20 @@ class ReflectResponse(BaseModel):
|
|
|
73
75
|
exclude=excluded_fields,
|
|
74
76
|
exclude_none=True,
|
|
75
77
|
)
|
|
76
|
-
# override the default output from pydantic by calling `to_dict()` of
|
|
77
|
-
_items = []
|
|
78
|
+
# override the default output from pydantic by calling `to_dict()` of based_on
|
|
78
79
|
if self.based_on:
|
|
79
|
-
|
|
80
|
-
if _item_based_on:
|
|
81
|
-
_items.append(_item_based_on.to_dict())
|
|
82
|
-
_dict['based_on'] = _items
|
|
80
|
+
_dict['based_on'] = self.based_on.to_dict()
|
|
83
81
|
# override the default output from pydantic by calling `to_dict()` of usage
|
|
84
82
|
if self.usage:
|
|
85
83
|
_dict['usage'] = self.usage.to_dict()
|
|
84
|
+
# override the default output from pydantic by calling `to_dict()` of trace
|
|
85
|
+
if self.trace:
|
|
86
|
+
_dict['trace'] = self.trace.to_dict()
|
|
87
|
+
# set to None if based_on (nullable) is None
|
|
88
|
+
# and model_fields_set contains the field
|
|
89
|
+
if self.based_on is None and "based_on" in self.model_fields_set:
|
|
90
|
+
_dict['based_on'] = None
|
|
91
|
+
|
|
86
92
|
# set to None if structured_output (nullable) is None
|
|
87
93
|
# and model_fields_set contains the field
|
|
88
94
|
if self.structured_output is None and "structured_output" in self.model_fields_set:
|
|
@@ -93,6 +99,11 @@ class ReflectResponse(BaseModel):
|
|
|
93
99
|
if self.usage is None and "usage" in self.model_fields_set:
|
|
94
100
|
_dict['usage'] = None
|
|
95
101
|
|
|
102
|
+
# set to None if trace (nullable) is None
|
|
103
|
+
# and model_fields_set contains the field
|
|
104
|
+
if self.trace is None and "trace" in self.model_fields_set:
|
|
105
|
+
_dict['trace'] = None
|
|
106
|
+
|
|
96
107
|
return _dict
|
|
97
108
|
|
|
98
109
|
@classmethod
|
|
@@ -106,9 +117,10 @@ class ReflectResponse(BaseModel):
|
|
|
106
117
|
|
|
107
118
|
_obj = cls.model_validate({
|
|
108
119
|
"text": obj.get("text"),
|
|
109
|
-
"based_on":
|
|
120
|
+
"based_on": ReflectBasedOn.from_dict(obj["based_on"]) if obj.get("based_on") is not None else None,
|
|
110
121
|
"structured_output": obj.get("structured_output"),
|
|
111
|
-
"usage": TokenUsage.from_dict(obj["usage"]) if obj.get("usage") is not None else None
|
|
122
|
+
"usage": TokenUsage.from_dict(obj["usage"]) if obj.get("usage") is not None else None,
|
|
123
|
+
"trace": ReflectTrace.from_dict(obj["trace"]) if obj.get("trace") is not None else None
|
|
112
124
|
})
|
|
113
125
|
return _obj
|
|
114
126
|
|
|
@@ -0,0 +1,100 @@
|
|
|
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, Optional
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class ReflectToolCall(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
A tool call made during reflect agent execution.
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
tool: StrictStr = Field(description="Tool name: lookup, recall, learn, expand")
|
|
30
|
+
input: Dict[str, Any] = Field(description="Tool input parameters")
|
|
31
|
+
output: Optional[Dict[str, Any]] = None
|
|
32
|
+
duration_ms: StrictInt = Field(description="Execution time in milliseconds")
|
|
33
|
+
iteration: Optional[StrictInt] = Field(default=0, description="Iteration number (1-based) when this tool was called")
|
|
34
|
+
__properties: ClassVar[List[str]] = ["tool", "input", "output", "duration_ms", "iteration"]
|
|
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 ReflectToolCall 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
|
+
# set to None if output (nullable) is None
|
|
76
|
+
# and model_fields_set contains the field
|
|
77
|
+
if self.output is None and "output" in self.model_fields_set:
|
|
78
|
+
_dict['output'] = None
|
|
79
|
+
|
|
80
|
+
return _dict
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
84
|
+
"""Create an instance of ReflectToolCall 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
|
+
"tool": obj.get("tool"),
|
|
93
|
+
"input": obj.get("input"),
|
|
94
|
+
"output": obj.get("output"),
|
|
95
|
+
"duration_ms": obj.get("duration_ms"),
|
|
96
|
+
"iteration": obj.get("iteration") if obj.get("iteration") is not None else 0
|
|
97
|
+
})
|
|
98
|
+
return _obj
|
|
99
|
+
|
|
100
|
+
|