letta-client 0.1.6__py3-none-any.whl → 0.1.10__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.

Potentially problematic release.


This version of letta-client might be problematic. Click here for more details.

Files changed (216) hide show
  1. {letta → letta_client}/__init__.py +33 -27
  2. {letta → letta_client}/agents/__init__.py +40 -29
  3. {letta → letta_client}/agents/archival_memory/client.py +25 -25
  4. letta_client/agents/client.py +1328 -0
  5. {letta → letta_client}/agents/context/client.py +7 -7
  6. letta_client/agents/core_memory/client.py +1080 -0
  7. letta_client/agents/memory_variables/__init__.py +5 -0
  8. {letta/agents/memory → letta_client/agents/memory_variables}/client.py +43 -42
  9. letta_client/agents/memory_variables/types/__init__.py +5 -0
  10. letta/agents/types/agents_get_agent_variables_response.py → letta_client/agents/memory_variables/types/memory_variables_get_response.py +3 -3
  11. {letta → letta_client}/agents/messages/client.py +240 -25
  12. {letta → letta_client}/agents/messages/types/letta_streaming_response.py +21 -16
  13. {letta → letta_client}/agents/messages/types/messages_list_response_item.py +19 -14
  14. {letta → letta_client}/agents/recall_memory/client.py +7 -7
  15. {letta → letta_client}/agents/sources/client.py +7 -7
  16. letta_client/agents/templates/__init__.py +5 -0
  17. letta_client/agents/templates/client.py +578 -0
  18. letta_client/agents/templates/types/__init__.py +5 -0
  19. letta/agents/types/agents_migrate_response.py → letta_client/agents/templates/types/templates_migrate_response.py +3 -3
  20. {letta → letta_client}/agents/tools/client.py +19 -19
  21. letta_client/agents/types/__init__.py +33 -0
  22. letta_client/agents/types/agents_search_request_combinator.py +5 -0
  23. letta/agents/types/agents_search_deployed_agents_request_search_item.py → letta_client/agents/types/agents_search_request_search_item.py +17 -20
  24. letta/agents/types/agents_search_deployed_agents_request_search_item_name.py → letta_client/agents/types/agents_search_request_search_item_name.py +4 -6
  25. letta_client/agents/types/agents_search_request_search_item_name_operator.py +5 -0
  26. letta_client/agents/types/agents_search_request_search_item_order_by.py +22 -0
  27. letta_client/agents/types/agents_search_request_search_item_order_by_direction.py +5 -0
  28. letta_client/agents/types/agents_search_request_search_item_order_by_value.py +5 -0
  29. letta/agents/types/agents_search_deployed_agents_request_search_item_version.py → letta_client/agents/types/agents_search_request_search_item_version.py +2 -2
  30. {letta → letta_client}/blocks/client.py +39 -39
  31. {letta → letta_client}/client.py +10 -2
  32. {letta → letta_client}/core/__init__.py +4 -0
  33. {letta → letta_client}/core/client_wrapper.py +1 -1
  34. letta_client/core/unchecked_base_model.py +305 -0
  35. {letta → letta_client}/health/client.py +5 -5
  36. {letta → letta_client}/jobs/client.py +25 -25
  37. {letta → letta_client}/models/client.py +9 -9
  38. letta_client/providers/client.py +597 -0
  39. letta_client/runs/client.py +876 -0
  40. {letta → letta_client}/sources/client.py +49 -49
  41. {letta → letta_client}/sources/files/client.py +17 -17
  42. {letta → letta_client}/sources/passages/client.py +7 -7
  43. letta_client/tools/__init__.py +2 -0
  44. {letta → letta_client}/tools/client.py +101 -81
  45. {letta → letta_client}/types/__init__.py +8 -0
  46. {letta → letta_client}/types/action_model.py +2 -2
  47. {letta → letta_client}/types/action_parameters_model.py +2 -2
  48. {letta → letta_client}/types/action_response_model.py +2 -2
  49. {letta → letta_client}/types/agent_environment_variable.py +2 -7
  50. {letta → letta_client}/types/agent_state.py +5 -8
  51. letta_client/types/agent_type.py +7 -0
  52. {letta → letta_client}/types/app_auth_scheme.py +2 -2
  53. {letta → letta_client}/types/app_model.py +2 -2
  54. {letta → letta_client}/types/archival_memory_summary.py +2 -2
  55. {letta → letta_client}/types/assistant_file.py +2 -2
  56. {letta → letta_client}/types/assistant_message_input.py +2 -2
  57. {letta → letta_client}/types/assistant_message_output.py +2 -2
  58. {letta → letta_client}/types/auth_request.py +2 -2
  59. {letta → letta_client}/types/auth_response.py +2 -2
  60. {letta → letta_client}/types/auth_scheme_field.py +2 -2
  61. {letta → letta_client}/types/block.py +2 -7
  62. {letta → letta_client}/types/block_update.py +2 -2
  63. {letta → letta_client}/types/chat_completion_request.py +2 -2
  64. {letta → letta_client}/types/chat_completion_response.py +2 -2
  65. {letta → letta_client}/types/child_tool_rule.py +2 -2
  66. {letta → letta_client}/types/choice.py +2 -2
  67. {letta → letta_client}/types/conditional_tool_rule.py +2 -2
  68. {letta → letta_client}/types/conflict_error_body.py +2 -2
  69. {letta → letta_client}/types/context_window_overview.py +2 -2
  70. {letta → letta_client}/types/create_assistant_file_request.py +2 -2
  71. {letta → letta_client}/types/create_assistant_request.py +2 -2
  72. {letta → letta_client}/types/create_block.py +2 -2
  73. {letta → letta_client}/types/delete_assistant_file_response.py +2 -2
  74. {letta → letta_client}/types/delete_assistant_response.py +2 -2
  75. {letta → letta_client}/types/e_2_b_sandbox_config.py +2 -2
  76. {letta → letta_client}/types/embedding_config.py +2 -2
  77. {letta → letta_client}/types/file_metadata.py +2 -7
  78. {letta → letta_client}/types/function_call_input.py +2 -2
  79. {letta → letta_client}/types/function_call_output.py +2 -2
  80. {letta → letta_client}/types/function_schema.py +2 -2
  81. {letta → letta_client}/types/health.py +2 -2
  82. {letta → letta_client}/types/http_validation_error.py +2 -2
  83. {letta → letta_client}/types/init_tool_rule.py +2 -2
  84. {letta → letta_client}/types/internal_server_error_body.py +2 -2
  85. {letta → letta_client}/types/job.py +7 -6
  86. letta_client/types/job_type.py +5 -0
  87. {letta → letta_client}/types/letta_request.py +7 -2
  88. {letta → letta_client}/types/letta_response.py +2 -2
  89. {letta → letta_client}/types/letta_response_messages_item.py +19 -14
  90. {letta → letta_client}/types/letta_schemas_letta_message_tool_call.py +2 -2
  91. {letta → letta_client}/types/letta_schemas_message_message.py +2 -7
  92. {letta → letta_client}/types/letta_schemas_openai_chat_completion_request_tool.py +2 -2
  93. {letta → letta_client}/types/letta_schemas_openai_chat_completion_request_tool_call.py +2 -2
  94. {letta → letta_client}/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +2 -2
  95. {letta → letta_client}/types/letta_schemas_openai_chat_completion_response_message.py +2 -2
  96. {letta → letta_client}/types/letta_schemas_openai_chat_completion_response_tool_call.py +2 -2
  97. {letta → letta_client}/types/letta_schemas_openai_chat_completions_tool_call_function.py +2 -2
  98. {letta → letta_client}/types/letta_schemas_openai_chat_completions_tool_call_input.py +2 -2
  99. {letta → letta_client}/types/letta_schemas_openai_chat_completions_tool_call_output.py +2 -2
  100. {letta → letta_client}/types/letta_schemas_tool_tool.py +9 -8
  101. {letta → letta_client}/types/letta_usage_statistics.py +2 -2
  102. {letta → letta_client}/types/llm_config.py +2 -2
  103. {letta → letta_client}/types/local_sandbox_config.py +2 -2
  104. {letta → letta_client}/types/log_prob_token.py +2 -2
  105. {letta → letta_client}/types/memory.py +2 -2
  106. {letta → letta_client}/types/message_content_log_prob.py +2 -2
  107. {letta → letta_client}/types/message_create.py +2 -2
  108. {letta → letta_client}/types/not_found_error_body.py +2 -2
  109. {letta → letta_client}/types/open_ai_assistant.py +2 -2
  110. {letta → letta_client}/types/organization.py +2 -2
  111. {letta → letta_client}/types/organization_create.py +2 -2
  112. {letta → letta_client}/types/passage.py +2 -7
  113. letta_client/types/provider.py +38 -0
  114. {letta → letta_client}/types/reasoning_message.py +2 -2
  115. {letta → letta_client}/types/recall_memory_summary.py +2 -2
  116. {letta → letta_client}/types/response_format.py +2 -2
  117. letta_client/types/run.py +77 -0
  118. {letta → letta_client}/types/sandbox_config.py +2 -7
  119. {letta → letta_client}/types/sandbox_config_create.py +2 -2
  120. {letta → letta_client}/types/sandbox_config_update.py +2 -2
  121. {letta → letta_client}/types/sandbox_environment_variable.py +2 -7
  122. {letta → letta_client}/types/sandbox_environment_variable_create.py +2 -2
  123. {letta → letta_client}/types/sandbox_environment_variable_update.py +2 -2
  124. {letta → letta_client}/types/source.py +2 -7
  125. {letta → letta_client}/types/system_message_input.py +2 -2
  126. {letta → letta_client}/types/system_message_output.py +2 -2
  127. {letta → letta_client}/types/terminal_tool_rule.py +2 -2
  128. {letta → letta_client}/types/tool_call_delta.py +2 -2
  129. {letta → letta_client}/types/tool_call_function_output.py +2 -2
  130. {letta → letta_client}/types/tool_call_message.py +2 -2
  131. {letta → letta_client}/types/tool_create.py +2 -2
  132. {letta → letta_client}/types/tool_function_choice.py +2 -2
  133. {letta → letta_client}/types/tool_input.py +2 -2
  134. {letta → letta_client}/types/tool_message.py +2 -2
  135. {letta → letta_client}/types/tool_return_message.py +2 -2
  136. letta_client/types/tool_type.py +5 -0
  137. {letta → letta_client}/types/usage_statistics.py +2 -2
  138. {letta → letta_client}/types/user.py +2 -7
  139. {letta → letta_client}/types/user_create.py +2 -7
  140. {letta → letta_client}/types/user_message_input.py +2 -2
  141. {letta → letta_client}/types/user_message_output.py +2 -2
  142. {letta → letta_client}/types/user_update.py +2 -7
  143. {letta → letta_client}/types/validation_error.py +2 -2
  144. {letta_client-0.1.6.dist-info → letta_client-0.1.10.dist-info}/METADATA +7 -7
  145. letta_client-0.1.10.dist-info/RECORD +204 -0
  146. letta/agents/client.py +0 -2644
  147. letta/agents/memory/__init__.py +0 -5
  148. letta/agents/memory/messages/client.py +0 -147
  149. letta/agents/memory_blocks/client.py +0 -364
  150. letta/agents/types/__init__.py +0 -47
  151. letta/agents/types/agents_search_deployed_agents_request_combinator.py +0 -5
  152. letta/agents/types/agents_search_deployed_agents_request_search_item_name_operator.py +0 -7
  153. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by.py +0 -26
  154. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_direction.py +0 -5
  155. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_value.py +0 -7
  156. letta/types/agent_type.py +0 -8
  157. letta_client-0.1.6.dist-info/RECORD +0 -193
  158. {letta → letta_client}/agents/archival_memory/__init__.py +0 -0
  159. {letta → letta_client}/agents/context/__init__.py +0 -0
  160. {letta/agents/memory/messages → letta_client/agents/core_memory}/__init__.py +0 -0
  161. {letta → letta_client}/agents/messages/__init__.py +0 -0
  162. {letta → letta_client}/agents/messages/types/__init__.py +0 -0
  163. {letta → letta_client}/agents/messages/types/messages_list_response.py +0 -0
  164. {letta/agents/memory_blocks → letta_client/agents/recall_memory}/__init__.py +0 -0
  165. {letta/agents/recall_memory → letta_client/agents/sources}/__init__.py +0 -0
  166. {letta/agents/sources → letta_client/agents/tools}/__init__.py +0 -0
  167. {letta → letta_client}/agents/types/create_agent_request_tool_rules_item.py +0 -0
  168. {letta → letta_client}/agents/types/update_agent_tool_rules_item.py +0 -0
  169. {letta/agents/tools → letta_client/blocks}/__init__.py +0 -0
  170. {letta → letta_client}/core/api_error.py +0 -0
  171. {letta → letta_client}/core/datetime_utils.py +0 -0
  172. {letta → letta_client}/core/file.py +0 -0
  173. {letta → letta_client}/core/http_client.py +0 -0
  174. {letta → letta_client}/core/jsonable_encoder.py +0 -0
  175. {letta → letta_client}/core/pydantic_utilities.py +0 -0
  176. {letta → letta_client}/core/query_encoder.py +0 -0
  177. {letta → letta_client}/core/remove_none_from_dict.py +0 -0
  178. {letta → letta_client}/core/request_options.py +0 -0
  179. {letta → letta_client}/core/serialization.py +0 -0
  180. {letta → letta_client}/environment.py +0 -0
  181. {letta → letta_client}/errors/__init__.py +0 -0
  182. {letta → letta_client}/errors/conflict_error.py +0 -0
  183. {letta → letta_client}/errors/internal_server_error.py +0 -0
  184. {letta → letta_client}/errors/not_found_error.py +0 -0
  185. {letta → letta_client}/errors/unprocessable_entity_error.py +0 -0
  186. {letta/blocks → letta_client/health}/__init__.py +0 -0
  187. {letta/health → letta_client/jobs}/__init__.py +0 -0
  188. {letta/jobs → letta_client/models}/__init__.py +0 -0
  189. {letta/models → letta_client/providers}/__init__.py +0 -0
  190. {letta → letta_client}/py.typed +0 -0
  191. {letta/sources/files → letta_client/runs}/__init__.py +0 -0
  192. {letta → letta_client}/sources/__init__.py +0 -0
  193. {letta/sources/passages → letta_client/sources/files}/__init__.py +0 -0
  194. {letta/tools → letta_client/sources/passages}/__init__.py +0 -0
  195. {letta → letta_client}/types/agent_state_tool_rules_item.py +0 -0
  196. {letta → letta_client}/types/app_auth_scheme_auth_mode.py +0 -0
  197. {letta → letta_client}/types/chat_completion_request_function_call.py +0 -0
  198. {letta → letta_client}/types/chat_completion_request_messages_item.py +0 -0
  199. {letta → letta_client}/types/chat_completion_request_stop.py +0 -0
  200. {letta → letta_client}/types/chat_completion_request_tool_choice.py +0 -0
  201. {letta → letta_client}/types/embedding_config_embedding_endpoint_type.py +0 -0
  202. {letta → letta_client}/types/job_status.py +0 -0
  203. {letta → letta_client}/types/llm_config_model_endpoint_type.py +0 -0
  204. {letta → letta_client}/types/message_create_role.py +0 -0
  205. {letta → letta_client}/types/message_role.py +0 -0
  206. {letta → letta_client}/types/not_found_error_body_message.py +0 -0
  207. {letta → letta_client}/types/sandbox_config_create_config.py +0 -0
  208. {letta → letta_client}/types/sandbox_config_update_config.py +0 -0
  209. {letta → letta_client}/types/sandbox_type.py +0 -0
  210. {letta → letta_client}/types/tool_call_message_tool_call.py +0 -0
  211. {letta → letta_client}/types/tool_return_message_status.py +0 -0
  212. {letta → letta_client}/types/tool_rule_type.py +0 -0
  213. {letta → letta_client}/types/user_message_input_content.py +0 -0
  214. {letta → letta_client}/types/validation_error_loc_item.py +0 -0
  215. {letta → letta_client}/version.py +0 -0
  216. {letta_client-0.1.6.dist-info → letta_client-0.1.10.dist-info}/WHEEL +0 -0
@@ -0,0 +1,305 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import inspect
5
+ import typing
6
+ import uuid
7
+
8
+ import typing_extensions
9
+ from pydantic_core import PydanticUndefined
10
+
11
+ import pydantic
12
+
13
+ from .pydantic_utilities import (
14
+ IS_PYDANTIC_V2,
15
+ ModelField,
16
+ UniversalBaseModel,
17
+ get_args,
18
+ get_origin,
19
+ is_literal_type,
20
+ is_union,
21
+ parse_date,
22
+ parse_datetime,
23
+ parse_obj_as,
24
+ )
25
+ from .serialization import get_field_to_alias_mapping
26
+
27
+
28
+ class UnionMetadata:
29
+ discriminant: str
30
+
31
+ def __init__(self, *, discriminant: str) -> None:
32
+ self.discriminant = discriminant
33
+
34
+
35
+ Model = typing.TypeVar("Model", bound=pydantic.BaseModel)
36
+
37
+
38
+ class UncheckedBaseModel(UniversalBaseModel):
39
+ if IS_PYDANTIC_V2:
40
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2
41
+ else:
42
+
43
+ class Config:
44
+ extra = pydantic.Extra.allow
45
+
46
+ @classmethod
47
+ def model_construct(
48
+ cls: typing.Type["Model"],
49
+ _fields_set: typing.Optional[typing.Set[str]] = None,
50
+ **values: typing.Any,
51
+ ) -> "Model":
52
+ # Fallback construct function to the specified override below.
53
+ return cls.construct(_fields_set=_fields_set, **values)
54
+
55
+ # Allow construct to not validate model
56
+ # Implementation taken from: https://github.com/pydantic/pydantic/issues/1168#issuecomment-817742836
57
+ @classmethod
58
+ def construct(
59
+ cls: typing.Type["Model"],
60
+ _fields_set: typing.Optional[typing.Set[str]] = None,
61
+ **values: typing.Any,
62
+ ) -> "Model":
63
+ m = cls.__new__(cls)
64
+ fields_values = {}
65
+
66
+ if _fields_set is None:
67
+ _fields_set = set(values.keys())
68
+
69
+ fields = _get_model_fields(cls)
70
+ populate_by_name = _get_is_populate_by_name(cls)
71
+ field_aliases = get_field_to_alias_mapping(cls)
72
+
73
+ for name, field in fields.items():
74
+ # Key here is only used to pull data from the values dict
75
+ # you should always use the NAME of the field to for field_values, etc.
76
+ # because that's how the object is constructed from a pydantic perspective
77
+ key = field.alias
78
+ if (key is None or field.alias == name) and name in field_aliases:
79
+ key = field_aliases[name]
80
+
81
+ if key is None or (key not in values and populate_by_name): # Added this to allow population by field name
82
+ key = name
83
+
84
+ if key in values:
85
+ if IS_PYDANTIC_V2:
86
+ type_ = field.annotation # type: ignore # Pydantic v2
87
+ else:
88
+ type_ = typing.cast(typing.Type, field.outer_type_) # type: ignore # Pydantic < v1.10.15
89
+
90
+ fields_values[name] = (
91
+ construct_type(object_=values[key], type_=type_) if type_ is not None else values[key]
92
+ )
93
+ _fields_set.add(name)
94
+ else:
95
+ default = _get_field_default(field)
96
+ fields_values[name] = default
97
+
98
+ # If the default values are non-null act like they've been set
99
+ # This effectively allows exclude_unset to work like exclude_none where
100
+ # the latter passes through intentionally set none values.
101
+ if default != None and default != PydanticUndefined:
102
+ _fields_set.add(name)
103
+
104
+ # Add extras back in
105
+ extras = {}
106
+ pydantic_alias_fields = [field.alias for field in fields.values()]
107
+ internal_alias_fields = list(field_aliases.values())
108
+ for key, value in values.items():
109
+ # If the key is not a field by name, nor an alias to a field, then it's extra
110
+ if (key not in pydantic_alias_fields and key not in internal_alias_fields) and key not in fields:
111
+ if IS_PYDANTIC_V2:
112
+ extras[key] = value
113
+ else:
114
+ _fields_set.add(key)
115
+ fields_values[key] = value
116
+
117
+ object.__setattr__(m, "__dict__", fields_values)
118
+
119
+ if IS_PYDANTIC_V2:
120
+ object.__setattr__(m, "__pydantic_private__", None)
121
+ object.__setattr__(m, "__pydantic_extra__", extras)
122
+ object.__setattr__(m, "__pydantic_fields_set__", _fields_set)
123
+ else:
124
+ object.__setattr__(m, "__fields_set__", _fields_set)
125
+ m._init_private_attributes() # type: ignore # Pydantic v1
126
+ return m
127
+
128
+
129
+ def _convert_undiscriminated_union_type(union_type: typing.Type[typing.Any], object_: typing.Any) -> typing.Any:
130
+ inner_types = get_args(union_type)
131
+ if typing.Any in inner_types:
132
+ return object_
133
+
134
+ for inner_type in inner_types:
135
+ try:
136
+ if inspect.isclass(inner_type) and issubclass(inner_type, pydantic.BaseModel):
137
+ # Attempt a validated parse until one works
138
+ return parse_obj_as(inner_type, object_)
139
+ except Exception:
140
+ continue
141
+
142
+ # If none of the types work, just return the first successful cast
143
+ for inner_type in inner_types:
144
+ try:
145
+ return construct_type(object_=object_, type_=inner_type)
146
+ except Exception:
147
+ continue
148
+
149
+
150
+ def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any:
151
+ base_type = get_origin(type_) or type_
152
+ union_type = type_
153
+ if base_type == typing_extensions.Annotated:
154
+ union_type = get_args(type_)[0]
155
+ annotated_metadata = get_args(type_)[1:]
156
+ for metadata in annotated_metadata:
157
+ if isinstance(metadata, UnionMetadata):
158
+ try:
159
+ # Cast to the correct type, based on the discriminant
160
+ for inner_type in get_args(union_type):
161
+ try:
162
+ objects_discriminant = getattr(object_, metadata.discriminant)
163
+ except:
164
+ objects_discriminant = object_[metadata.discriminant]
165
+ if inner_type.__fields__[metadata.discriminant].default == objects_discriminant:
166
+ return construct_type(object_=object_, type_=inner_type)
167
+ except Exception:
168
+ # Allow to fall through to our regular union handling
169
+ pass
170
+ return _convert_undiscriminated_union_type(union_type, object_)
171
+
172
+
173
+ def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any:
174
+ """
175
+ Here we are essentially creating the same `construct` method in spirit as the above, but for all types, not just
176
+ Pydantic models.
177
+ The idea is to essentially attempt to coerce object_ to type_ (recursively)
178
+ """
179
+ # Short circuit when dealing with optionals, don't try to coerces None to a type
180
+ if object_ is None:
181
+ return None
182
+
183
+ base_type = get_origin(type_) or type_
184
+ is_annotated = base_type == typing_extensions.Annotated
185
+ maybe_annotation_members = get_args(type_)
186
+ is_annotated_union = is_annotated and is_union(get_origin(maybe_annotation_members[0]))
187
+
188
+ if base_type == typing.Any:
189
+ return object_
190
+
191
+ if base_type == dict:
192
+ if not isinstance(object_, typing.Mapping):
193
+ return object_
194
+
195
+ key_type, items_type = get_args(type_)
196
+ d = {
197
+ construct_type(object_=key, type_=key_type): construct_type(object_=item, type_=items_type)
198
+ for key, item in object_.items()
199
+ }
200
+ return d
201
+
202
+ if base_type == list:
203
+ if not isinstance(object_, list):
204
+ return object_
205
+
206
+ inner_type = get_args(type_)[0]
207
+ return [construct_type(object_=entry, type_=inner_type) for entry in object_]
208
+
209
+ if base_type == set:
210
+ if not isinstance(object_, set) and not isinstance(object_, list):
211
+ return object_
212
+
213
+ inner_type = get_args(type_)[0]
214
+ return {construct_type(object_=entry, type_=inner_type) for entry in object_}
215
+
216
+ if is_union(base_type) or is_annotated_union:
217
+ return _convert_union_type(type_, object_)
218
+
219
+ # Cannot do an `issubclass` with a literal type, let's also just confirm we have a class before this call
220
+ if (
221
+ object_ is not None
222
+ and not is_literal_type(type_)
223
+ and (
224
+ (inspect.isclass(base_type) and issubclass(base_type, pydantic.BaseModel))
225
+ or (
226
+ is_annotated
227
+ and inspect.isclass(maybe_annotation_members[0])
228
+ and issubclass(maybe_annotation_members[0], pydantic.BaseModel)
229
+ )
230
+ )
231
+ ):
232
+ if IS_PYDANTIC_V2:
233
+ return type_.model_construct(**object_)
234
+ else:
235
+ return type_.construct(**object_)
236
+
237
+ if base_type == dt.datetime:
238
+ try:
239
+ return parse_datetime(object_)
240
+ except Exception:
241
+ return object_
242
+
243
+ if base_type == dt.date:
244
+ try:
245
+ return parse_date(object_)
246
+ except Exception:
247
+ return object_
248
+
249
+ if base_type == uuid.UUID:
250
+ try:
251
+ return uuid.UUID(object_)
252
+ except Exception:
253
+ return object_
254
+
255
+ if base_type == int:
256
+ try:
257
+ return int(object_)
258
+ except Exception:
259
+ return object_
260
+
261
+ if base_type == bool:
262
+ try:
263
+ if isinstance(object_, str):
264
+ stringified_object = object_.lower()
265
+ return stringified_object == "true" or stringified_object == "1"
266
+
267
+ return bool(object_)
268
+ except Exception:
269
+ return object_
270
+
271
+ return object_
272
+
273
+
274
+ def _get_is_populate_by_name(model: typing.Type["Model"]) -> bool:
275
+ if IS_PYDANTIC_V2:
276
+ return model.model_config.get("populate_by_name", False) # type: ignore # Pydantic v2
277
+ return model.__config__.allow_population_by_field_name # type: ignore # Pydantic v1
278
+
279
+
280
+ PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo]
281
+
282
+
283
+ # Pydantic V1 swapped the typing of __fields__'s values from ModelField to FieldInfo
284
+ # And so we try to handle both V1 cases, as well as V2 (FieldInfo from model.model_fields)
285
+ def _get_model_fields(
286
+ model: typing.Type["Model"],
287
+ ) -> typing.Mapping[str, PydanticField]:
288
+ if IS_PYDANTIC_V2:
289
+ return model.model_fields # type: ignore # Pydantic v2
290
+ else:
291
+ return model.__fields__ # type: ignore # Pydantic v1
292
+
293
+
294
+ def _get_field_default(field: PydanticField) -> typing.Any:
295
+ try:
296
+ value = field.get_default() # type: ignore # Pydantic < v1.10.15
297
+ except:
298
+ value = field.default
299
+ if IS_PYDANTIC_V2:
300
+ from pydantic_core import PydanticUndefined
301
+
302
+ if value == PydanticUndefined:
303
+ return None
304
+ return value
305
+ return value
@@ -4,7 +4,7 @@ from ..core.client_wrapper import SyncClientWrapper
4
4
  import typing
5
5
  from ..core.request_options import RequestOptions
6
6
  from ..types.health import Health
7
- from ..core.pydantic_utilities import parse_obj_as
7
+ from ..core.unchecked_base_model import construct_type
8
8
  from json.decoder import JSONDecodeError
9
9
  from ..core.api_error import ApiError
10
10
  from ..core.client_wrapper import AsyncClientWrapper
@@ -28,7 +28,7 @@ class HealthClient:
28
28
 
29
29
  Examples
30
30
  --------
31
- from letta import Letta
31
+ from letta_client import Letta
32
32
 
33
33
  client = Letta(
34
34
  token="YOUR_TOKEN",
@@ -44,7 +44,7 @@ class HealthClient:
44
44
  if 200 <= _response.status_code < 300:
45
45
  return typing.cast(
46
46
  Health,
47
- parse_obj_as(
47
+ construct_type(
48
48
  type_=Health, # type: ignore
49
49
  object_=_response.json(),
50
50
  ),
@@ -75,7 +75,7 @@ class AsyncHealthClient:
75
75
  --------
76
76
  import asyncio
77
77
 
78
- from letta import AsyncLetta
78
+ from letta_client import AsyncLetta
79
79
 
80
80
  client = AsyncLetta(
81
81
  token="YOUR_TOKEN",
@@ -97,7 +97,7 @@ class AsyncHealthClient:
97
97
  if 200 <= _response.status_code < 300:
98
98
  return typing.cast(
99
99
  Health,
100
- parse_obj_as(
100
+ construct_type(
101
101
  type_=Health, # type: ignore
102
102
  object_=_response.json(),
103
103
  ),
@@ -4,7 +4,7 @@ from ..core.client_wrapper import SyncClientWrapper
4
4
  import typing
5
5
  from ..core.request_options import RequestOptions
6
6
  from ..types.job import Job
7
- from ..core.pydantic_utilities import parse_obj_as
7
+ from ..core.unchecked_base_model import construct_type
8
8
  from ..errors.unprocessable_entity_error import UnprocessableEntityError
9
9
  from ..types.http_validation_error import HttpValidationError
10
10
  from json.decoder import JSONDecodeError
@@ -38,7 +38,7 @@ class JobsClient:
38
38
 
39
39
  Examples
40
40
  --------
41
- from letta import Letta
41
+ from letta_client import Letta
42
42
 
43
43
  client = Letta(
44
44
  token="YOUR_TOKEN",
@@ -57,7 +57,7 @@ class JobsClient:
57
57
  if 200 <= _response.status_code < 300:
58
58
  return typing.cast(
59
59
  typing.List[Job],
60
- parse_obj_as(
60
+ construct_type(
61
61
  type_=typing.List[Job], # type: ignore
62
62
  object_=_response.json(),
63
63
  ),
@@ -66,7 +66,7 @@ class JobsClient:
66
66
  raise UnprocessableEntityError(
67
67
  typing.cast(
68
68
  HttpValidationError,
69
- parse_obj_as(
69
+ construct_type(
70
70
  type_=HttpValidationError, # type: ignore
71
71
  object_=_response.json(),
72
72
  ),
@@ -93,7 +93,7 @@ class JobsClient:
93
93
 
94
94
  Examples
95
95
  --------
96
- from letta import Letta
96
+ from letta_client import Letta
97
97
 
98
98
  client = Letta(
99
99
  token="YOUR_TOKEN",
@@ -109,7 +109,7 @@ class JobsClient:
109
109
  if 200 <= _response.status_code < 300:
110
110
  return typing.cast(
111
111
  typing.List[Job],
112
- parse_obj_as(
112
+ construct_type(
113
113
  type_=typing.List[Job], # type: ignore
114
114
  object_=_response.json(),
115
115
  ),
@@ -118,7 +118,7 @@ class JobsClient:
118
118
  raise UnprocessableEntityError(
119
119
  typing.cast(
120
120
  HttpValidationError,
121
- parse_obj_as(
121
+ construct_type(
122
122
  type_=HttpValidationError, # type: ignore
123
123
  object_=_response.json(),
124
124
  ),
@@ -147,7 +147,7 @@ class JobsClient:
147
147
 
148
148
  Examples
149
149
  --------
150
- from letta import Letta
150
+ from letta_client import Letta
151
151
 
152
152
  client = Letta(
153
153
  token="YOUR_TOKEN",
@@ -165,7 +165,7 @@ class JobsClient:
165
165
  if 200 <= _response.status_code < 300:
166
166
  return typing.cast(
167
167
  Job,
168
- parse_obj_as(
168
+ construct_type(
169
169
  type_=Job, # type: ignore
170
170
  object_=_response.json(),
171
171
  ),
@@ -174,7 +174,7 @@ class JobsClient:
174
174
  raise UnprocessableEntityError(
175
175
  typing.cast(
176
176
  HttpValidationError,
177
- parse_obj_as(
177
+ construct_type(
178
178
  type_=HttpValidationError, # type: ignore
179
179
  object_=_response.json(),
180
180
  ),
@@ -203,7 +203,7 @@ class JobsClient:
203
203
 
204
204
  Examples
205
205
  --------
206
- from letta import Letta
206
+ from letta_client import Letta
207
207
 
208
208
  client = Letta(
209
209
  token="YOUR_TOKEN",
@@ -221,7 +221,7 @@ class JobsClient:
221
221
  if 200 <= _response.status_code < 300:
222
222
  return typing.cast(
223
223
  Job,
224
- parse_obj_as(
224
+ construct_type(
225
225
  type_=Job, # type: ignore
226
226
  object_=_response.json(),
227
227
  ),
@@ -230,7 +230,7 @@ class JobsClient:
230
230
  raise UnprocessableEntityError(
231
231
  typing.cast(
232
232
  HttpValidationError,
233
- parse_obj_as(
233
+ construct_type(
234
234
  type_=HttpValidationError, # type: ignore
235
235
  object_=_response.json(),
236
236
  ),
@@ -269,7 +269,7 @@ class AsyncJobsClient:
269
269
  --------
270
270
  import asyncio
271
271
 
272
- from letta import AsyncLetta
272
+ from letta_client import AsyncLetta
273
273
 
274
274
  client = AsyncLetta(
275
275
  token="YOUR_TOKEN",
@@ -294,7 +294,7 @@ class AsyncJobsClient:
294
294
  if 200 <= _response.status_code < 300:
295
295
  return typing.cast(
296
296
  typing.List[Job],
297
- parse_obj_as(
297
+ construct_type(
298
298
  type_=typing.List[Job], # type: ignore
299
299
  object_=_response.json(),
300
300
  ),
@@ -303,7 +303,7 @@ class AsyncJobsClient:
303
303
  raise UnprocessableEntityError(
304
304
  typing.cast(
305
305
  HttpValidationError,
306
- parse_obj_as(
306
+ construct_type(
307
307
  type_=HttpValidationError, # type: ignore
308
308
  object_=_response.json(),
309
309
  ),
@@ -332,7 +332,7 @@ class AsyncJobsClient:
332
332
  --------
333
333
  import asyncio
334
334
 
335
- from letta import AsyncLetta
335
+ from letta_client import AsyncLetta
336
336
 
337
337
  client = AsyncLetta(
338
338
  token="YOUR_TOKEN",
@@ -354,7 +354,7 @@ class AsyncJobsClient:
354
354
  if 200 <= _response.status_code < 300:
355
355
  return typing.cast(
356
356
  typing.List[Job],
357
- parse_obj_as(
357
+ construct_type(
358
358
  type_=typing.List[Job], # type: ignore
359
359
  object_=_response.json(),
360
360
  ),
@@ -363,7 +363,7 @@ class AsyncJobsClient:
363
363
  raise UnprocessableEntityError(
364
364
  typing.cast(
365
365
  HttpValidationError,
366
- parse_obj_as(
366
+ construct_type(
367
367
  type_=HttpValidationError, # type: ignore
368
368
  object_=_response.json(),
369
369
  ),
@@ -394,7 +394,7 @@ class AsyncJobsClient:
394
394
  --------
395
395
  import asyncio
396
396
 
397
- from letta import AsyncLetta
397
+ from letta_client import AsyncLetta
398
398
 
399
399
  client = AsyncLetta(
400
400
  token="YOUR_TOKEN",
@@ -418,7 +418,7 @@ class AsyncJobsClient:
418
418
  if 200 <= _response.status_code < 300:
419
419
  return typing.cast(
420
420
  Job,
421
- parse_obj_as(
421
+ construct_type(
422
422
  type_=Job, # type: ignore
423
423
  object_=_response.json(),
424
424
  ),
@@ -427,7 +427,7 @@ class AsyncJobsClient:
427
427
  raise UnprocessableEntityError(
428
428
  typing.cast(
429
429
  HttpValidationError,
430
- parse_obj_as(
430
+ construct_type(
431
431
  type_=HttpValidationError, # type: ignore
432
432
  object_=_response.json(),
433
433
  ),
@@ -458,7 +458,7 @@ class AsyncJobsClient:
458
458
  --------
459
459
  import asyncio
460
460
 
461
- from letta import AsyncLetta
461
+ from letta_client import AsyncLetta
462
462
 
463
463
  client = AsyncLetta(
464
464
  token="YOUR_TOKEN",
@@ -482,7 +482,7 @@ class AsyncJobsClient:
482
482
  if 200 <= _response.status_code < 300:
483
483
  return typing.cast(
484
484
  Job,
485
- parse_obj_as(
485
+ construct_type(
486
486
  type_=Job, # type: ignore
487
487
  object_=_response.json(),
488
488
  ),
@@ -491,7 +491,7 @@ class AsyncJobsClient:
491
491
  raise UnprocessableEntityError(
492
492
  typing.cast(
493
493
  HttpValidationError,
494
- parse_obj_as(
494
+ construct_type(
495
495
  type_=HttpValidationError, # type: ignore
496
496
  object_=_response.json(),
497
497
  ),
@@ -4,7 +4,7 @@ from ..core.client_wrapper import SyncClientWrapper
4
4
  import typing
5
5
  from ..core.request_options import RequestOptions
6
6
  from ..types.llm_config import LlmConfig
7
- from ..core.pydantic_utilities import parse_obj_as
7
+ from ..core.unchecked_base_model import construct_type
8
8
  from json.decoder import JSONDecodeError
9
9
  from ..core.api_error import ApiError
10
10
  from ..types.embedding_config import EmbeddingConfig
@@ -29,7 +29,7 @@ class ModelsClient:
29
29
 
30
30
  Examples
31
31
  --------
32
- from letta import Letta
32
+ from letta_client import Letta
33
33
 
34
34
  client = Letta(
35
35
  token="YOUR_TOKEN",
@@ -45,7 +45,7 @@ class ModelsClient:
45
45
  if 200 <= _response.status_code < 300:
46
46
  return typing.cast(
47
47
  typing.List[LlmConfig],
48
- parse_obj_as(
48
+ construct_type(
49
49
  type_=typing.List[LlmConfig], # type: ignore
50
50
  object_=_response.json(),
51
51
  ),
@@ -71,7 +71,7 @@ class ModelsClient:
71
71
 
72
72
  Examples
73
73
  --------
74
- from letta import Letta
74
+ from letta_client import Letta
75
75
 
76
76
  client = Letta(
77
77
  token="YOUR_TOKEN",
@@ -87,7 +87,7 @@ class ModelsClient:
87
87
  if 200 <= _response.status_code < 300:
88
88
  return typing.cast(
89
89
  typing.List[EmbeddingConfig],
90
- parse_obj_as(
90
+ construct_type(
91
91
  type_=typing.List[EmbeddingConfig], # type: ignore
92
92
  object_=_response.json(),
93
93
  ),
@@ -118,7 +118,7 @@ class AsyncModelsClient:
118
118
  --------
119
119
  import asyncio
120
120
 
121
- from letta import AsyncLetta
121
+ from letta_client import AsyncLetta
122
122
 
123
123
  client = AsyncLetta(
124
124
  token="YOUR_TOKEN",
@@ -140,7 +140,7 @@ class AsyncModelsClient:
140
140
  if 200 <= _response.status_code < 300:
141
141
  return typing.cast(
142
142
  typing.List[LlmConfig],
143
- parse_obj_as(
143
+ construct_type(
144
144
  type_=typing.List[LlmConfig], # type: ignore
145
145
  object_=_response.json(),
146
146
  ),
@@ -168,7 +168,7 @@ class AsyncModelsClient:
168
168
  --------
169
169
  import asyncio
170
170
 
171
- from letta import AsyncLetta
171
+ from letta_client import AsyncLetta
172
172
 
173
173
  client = AsyncLetta(
174
174
  token="YOUR_TOKEN",
@@ -190,7 +190,7 @@ class AsyncModelsClient:
190
190
  if 200 <= _response.status_code < 300:
191
191
  return typing.cast(
192
192
  typing.List[EmbeddingConfig],
193
- parse_obj_as(
193
+ construct_type(
194
194
  type_=typing.List[EmbeddingConfig], # type: ignore
195
195
  object_=_response.json(),
196
196
  ),