letta-client 0.1.6__py3-none-any.whl → 0.1.9__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 (153) hide show
  1. letta/__init__.py +28 -27
  2. letta/agents/__init__.py +40 -29
  3. letta/agents/archival_memory/client.py +17 -17
  4. letta/agents/client.py +405 -1721
  5. letta/agents/context/client.py +5 -5
  6. letta/agents/core_memory/client.py +1080 -0
  7. letta/agents/memory_variables/__init__.py +5 -0
  8. letta/agents/{memory → memory_variables}/client.py +41 -40
  9. letta/agents/memory_variables/types/__init__.py +5 -0
  10. letta/agents/{types/agents_get_agent_variables_response.py → memory_variables/types/memory_variables_get_response.py} +3 -3
  11. letta/agents/messages/client.py +232 -17
  12. letta/agents/messages/types/letta_streaming_response.py +21 -16
  13. letta/agents/messages/types/messages_list_response_item.py +19 -14
  14. letta/agents/recall_memory/client.py +5 -5
  15. letta/agents/sources/client.py +5 -5
  16. letta/agents/templates/__init__.py +5 -0
  17. letta/agents/templates/client.py +578 -0
  18. letta/agents/templates/types/__init__.py +5 -0
  19. letta/agents/{types/agents_migrate_response.py → templates/types/templates_migrate_response.py} +3 -3
  20. letta/agents/tools/client.py +13 -13
  21. letta/agents/types/__init__.py +23 -37
  22. letta/agents/types/agents_search_request_combinator.py +5 -0
  23. letta/agents/types/{agents_search_deployed_agents_request_search_item.py → agents_search_request_search_item.py} +17 -20
  24. letta/agents/types/{agents_search_deployed_agents_request_search_item_name.py → agents_search_request_search_item_name.py} +4 -6
  25. letta/agents/types/agents_search_request_search_item_name_operator.py +5 -0
  26. letta/agents/types/agents_search_request_search_item_order_by.py +22 -0
  27. letta/agents/types/agents_search_request_search_item_order_by_direction.py +5 -0
  28. letta/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 → agents_search_request_search_item_version.py} +2 -2
  30. letta/blocks/client.py +25 -25
  31. letta/client.py +4 -0
  32. letta/core/__init__.py +4 -0
  33. letta/core/client_wrapper.py +1 -1
  34. letta/core/unchecked_base_model.py +305 -0
  35. letta/health/client.py +3 -3
  36. letta/jobs/client.py +17 -17
  37. letta/models/client.py +5 -5
  38. letta/providers/client.py +597 -0
  39. letta/sources/client.py +33 -33
  40. letta/sources/files/client.py +11 -11
  41. letta/sources/passages/client.py +5 -5
  42. letta/tools/client.py +77 -57
  43. letta/types/__init__.py +4 -0
  44. letta/types/action_model.py +2 -2
  45. letta/types/action_parameters_model.py +2 -2
  46. letta/types/action_response_model.py +2 -2
  47. letta/types/agent_environment_variable.py +2 -7
  48. letta/types/agent_state.py +5 -8
  49. letta/types/agent_type.py +1 -2
  50. letta/types/app_auth_scheme.py +2 -2
  51. letta/types/app_model.py +2 -2
  52. letta/types/archival_memory_summary.py +2 -2
  53. letta/types/assistant_file.py +2 -2
  54. letta/types/assistant_message_input.py +2 -2
  55. letta/types/assistant_message_output.py +2 -2
  56. letta/types/auth_request.py +2 -2
  57. letta/types/auth_response.py +2 -2
  58. letta/types/auth_scheme_field.py +2 -2
  59. letta/types/block.py +2 -7
  60. letta/types/block_update.py +2 -2
  61. letta/types/chat_completion_request.py +2 -2
  62. letta/types/chat_completion_response.py +2 -2
  63. letta/types/child_tool_rule.py +2 -2
  64. letta/types/choice.py +2 -2
  65. letta/types/conditional_tool_rule.py +2 -2
  66. letta/types/conflict_error_body.py +2 -2
  67. letta/types/context_window_overview.py +2 -2
  68. letta/types/create_assistant_file_request.py +2 -2
  69. letta/types/create_assistant_request.py +2 -2
  70. letta/types/create_block.py +2 -2
  71. letta/types/delete_assistant_file_response.py +2 -2
  72. letta/types/delete_assistant_response.py +2 -2
  73. letta/types/e_2_b_sandbox_config.py +2 -2
  74. letta/types/embedding_config.py +2 -2
  75. letta/types/file_metadata.py +2 -7
  76. letta/types/function_call_input.py +2 -2
  77. letta/types/function_call_output.py +2 -2
  78. letta/types/function_schema.py +2 -2
  79. letta/types/health.py +2 -2
  80. letta/types/http_validation_error.py +2 -2
  81. letta/types/init_tool_rule.py +2 -2
  82. letta/types/internal_server_error_body.py +2 -2
  83. letta/types/job.py +2 -7
  84. letta/types/letta_request.py +7 -2
  85. letta/types/letta_response.py +2 -2
  86. letta/types/letta_response_messages_item.py +19 -14
  87. letta/types/letta_schemas_letta_message_tool_call.py +2 -2
  88. letta/types/letta_schemas_message_message.py +2 -7
  89. letta/types/letta_schemas_openai_chat_completion_request_tool.py +2 -2
  90. letta/types/letta_schemas_openai_chat_completion_request_tool_call.py +2 -2
  91. letta/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +2 -2
  92. letta/types/letta_schemas_openai_chat_completion_response_message.py +2 -2
  93. letta/types/letta_schemas_openai_chat_completion_response_tool_call.py +2 -2
  94. letta/types/letta_schemas_openai_chat_completions_tool_call_function.py +2 -2
  95. letta/types/letta_schemas_openai_chat_completions_tool_call_input.py +2 -2
  96. letta/types/letta_schemas_openai_chat_completions_tool_call_output.py +2 -2
  97. letta/types/letta_schemas_tool_tool.py +9 -8
  98. letta/types/letta_usage_statistics.py +2 -2
  99. letta/types/llm_config.py +2 -2
  100. letta/types/local_sandbox_config.py +2 -2
  101. letta/types/log_prob_token.py +2 -2
  102. letta/types/memory.py +2 -2
  103. letta/types/message_content_log_prob.py +2 -2
  104. letta/types/message_create.py +2 -2
  105. letta/types/not_found_error_body.py +2 -2
  106. letta/types/open_ai_assistant.py +2 -2
  107. letta/types/organization.py +2 -2
  108. letta/types/organization_create.py +2 -2
  109. letta/types/passage.py +2 -7
  110. letta/types/provider.py +38 -0
  111. letta/types/reasoning_message.py +2 -2
  112. letta/types/recall_memory_summary.py +2 -2
  113. letta/types/response_format.py +2 -2
  114. letta/types/sandbox_config.py +2 -7
  115. letta/types/sandbox_config_create.py +2 -2
  116. letta/types/sandbox_config_update.py +2 -2
  117. letta/types/sandbox_environment_variable.py +2 -7
  118. letta/types/sandbox_environment_variable_create.py +2 -2
  119. letta/types/sandbox_environment_variable_update.py +2 -2
  120. letta/types/source.py +2 -7
  121. letta/types/system_message_input.py +2 -2
  122. letta/types/system_message_output.py +2 -2
  123. letta/types/terminal_tool_rule.py +2 -2
  124. letta/types/tool_call_delta.py +2 -2
  125. letta/types/tool_call_function_output.py +2 -2
  126. letta/types/tool_call_message.py +2 -2
  127. letta/types/tool_create.py +2 -2
  128. letta/types/tool_function_choice.py +2 -2
  129. letta/types/tool_input.py +2 -2
  130. letta/types/tool_message.py +2 -2
  131. letta/types/tool_return_message.py +2 -2
  132. letta/types/tool_type.py +5 -0
  133. letta/types/usage_statistics.py +2 -2
  134. letta/types/user.py +2 -7
  135. letta/types/user_create.py +2 -7
  136. letta/types/user_message_input.py +2 -2
  137. letta/types/user_message_output.py +2 -2
  138. letta/types/user_update.py +2 -7
  139. letta/types/validation_error.py +2 -2
  140. {letta_client-0.1.6.dist-info → letta_client-0.1.9.dist-info}/METADATA +1 -1
  141. letta_client-0.1.9.dist-info/RECORD +200 -0
  142. letta/agents/memory/__init__.py +0 -5
  143. letta/agents/memory/messages/client.py +0 -147
  144. letta/agents/memory_blocks/client.py +0 -364
  145. letta/agents/types/agents_search_deployed_agents_request_combinator.py +0 -5
  146. letta/agents/types/agents_search_deployed_agents_request_search_item_name_operator.py +0 -7
  147. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by.py +0 -26
  148. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_direction.py +0 -5
  149. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_value.py +0 -7
  150. letta_client-0.1.6.dist-info/RECORD +0 -193
  151. /letta/agents/{memory/messages → core_memory}/__init__.py +0 -0
  152. /letta/{agents/memory_blocks → providers}/__init__.py +0 -0
  153. {letta_client-0.1.6.dist-info → letta_client-0.1.9.dist-info}/WHEEL +0 -0
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .types import MemoryVariablesGetResponse
4
+
5
+ __all__ = ["MemoryVariablesGetResponse"]
@@ -1,29 +1,28 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
3
  from ...core.client_wrapper import SyncClientWrapper
4
- from .messages.client import MessagesClient
5
4
  import typing
6
5
  from ...core.request_options import RequestOptions
7
- from ...types.memory import Memory
6
+ from .types.memory_variables_get_response import MemoryVariablesGetResponse
8
7
  from ...core.jsonable_encoder import jsonable_encoder
9
- from ...core.pydantic_utilities import parse_obj_as
10
- from ...errors.unprocessable_entity_error import UnprocessableEntityError
11
- from ...types.http_validation_error import HttpValidationError
8
+ from ...core.unchecked_base_model import construct_type
9
+ from ...errors.not_found_error import NotFoundError
12
10
  from json.decoder import JSONDecodeError
13
11
  from ...core.api_error import ApiError
14
12
  from ...core.client_wrapper import AsyncClientWrapper
15
- from .messages.client import AsyncMessagesClient
16
13
 
17
14
 
18
- class MemoryClient:
15
+ class MemoryVariablesClient:
19
16
  def __init__(self, *, client_wrapper: SyncClientWrapper):
20
17
  self._client_wrapper = client_wrapper
21
- self.messages = MessagesClient(client_wrapper=self._client_wrapper)
22
18
 
23
- def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
19
+ def get(
20
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
21
+ ) -> MemoryVariablesGetResponse:
24
22
  """
25
- Retrieve the memory state of a specific agent.
26
- This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
23
+ <Note>This endpoint is only available on Letta Cloud.</Note>
24
+
25
+ Returns the memory variables associated with an agent.
27
26
 
28
27
  Parameters
29
28
  ----------
@@ -34,8 +33,8 @@ class MemoryClient:
34
33
 
35
34
  Returns
36
35
  -------
37
- Memory
38
- Successful Response
36
+ MemoryVariablesGetResponse
37
+ 200
39
38
 
40
39
  Examples
41
40
  --------
@@ -44,30 +43,30 @@ class MemoryClient:
44
43
  client = Letta(
45
44
  token="YOUR_TOKEN",
46
45
  )
47
- client.agents.memory.get(
46
+ client.agents.memory_variables.get(
48
47
  agent_id="agent_id",
49
48
  )
50
49
  """
51
50
  _response = self._client_wrapper.httpx_client.request(
52
- f"v1/agents/{jsonable_encoder(agent_id)}/memory",
51
+ f"v1/agents/{jsonable_encoder(agent_id)}/variables",
53
52
  method="GET",
54
53
  request_options=request_options,
55
54
  )
56
55
  try:
57
56
  if 200 <= _response.status_code < 300:
58
57
  return typing.cast(
59
- Memory,
60
- parse_obj_as(
61
- type_=Memory, # type: ignore
58
+ MemoryVariablesGetResponse,
59
+ construct_type(
60
+ type_=MemoryVariablesGetResponse, # type: ignore
62
61
  object_=_response.json(),
63
62
  ),
64
63
  )
65
- if _response.status_code == 422:
66
- raise UnprocessableEntityError(
64
+ if _response.status_code == 404:
65
+ raise NotFoundError(
67
66
  typing.cast(
68
- HttpValidationError,
69
- parse_obj_as(
70
- type_=HttpValidationError, # type: ignore
67
+ typing.Optional[typing.Any],
68
+ construct_type(
69
+ type_=typing.Optional[typing.Any], # type: ignore
71
70
  object_=_response.json(),
72
71
  ),
73
72
  )
@@ -78,15 +77,17 @@ class MemoryClient:
78
77
  raise ApiError(status_code=_response.status_code, body=_response_json)
79
78
 
80
79
 
81
- class AsyncMemoryClient:
80
+ class AsyncMemoryVariablesClient:
82
81
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
83
82
  self._client_wrapper = client_wrapper
84
- self.messages = AsyncMessagesClient(client_wrapper=self._client_wrapper)
85
83
 
86
- async def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
84
+ async def get(
85
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
86
+ ) -> MemoryVariablesGetResponse:
87
87
  """
88
- Retrieve the memory state of a specific agent.
89
- This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
88
+ <Note>This endpoint is only available on Letta Cloud.</Note>
89
+
90
+ Returns the memory variables associated with an agent.
90
91
 
91
92
  Parameters
92
93
  ----------
@@ -97,8 +98,8 @@ class AsyncMemoryClient:
97
98
 
98
99
  Returns
99
100
  -------
100
- Memory
101
- Successful Response
101
+ MemoryVariablesGetResponse
102
+ 200
102
103
 
103
104
  Examples
104
105
  --------
@@ -112,7 +113,7 @@ class AsyncMemoryClient:
112
113
 
113
114
 
114
115
  async def main() -> None:
115
- await client.agents.memory.get(
116
+ await client.agents.memory_variables.get(
116
117
  agent_id="agent_id",
117
118
  )
118
119
 
@@ -120,25 +121,25 @@ class AsyncMemoryClient:
120
121
  asyncio.run(main())
121
122
  """
122
123
  _response = await self._client_wrapper.httpx_client.request(
123
- f"v1/agents/{jsonable_encoder(agent_id)}/memory",
124
+ f"v1/agents/{jsonable_encoder(agent_id)}/variables",
124
125
  method="GET",
125
126
  request_options=request_options,
126
127
  )
127
128
  try:
128
129
  if 200 <= _response.status_code < 300:
129
130
  return typing.cast(
130
- Memory,
131
- parse_obj_as(
132
- type_=Memory, # type: ignore
131
+ MemoryVariablesGetResponse,
132
+ construct_type(
133
+ type_=MemoryVariablesGetResponse, # type: ignore
133
134
  object_=_response.json(),
134
135
  ),
135
136
  )
136
- if _response.status_code == 422:
137
- raise UnprocessableEntityError(
137
+ if _response.status_code == 404:
138
+ raise NotFoundError(
138
139
  typing.cast(
139
- HttpValidationError,
140
- parse_obj_as(
141
- type_=HttpValidationError, # type: ignore
140
+ typing.Optional[typing.Any],
141
+ construct_type(
142
+ type_=typing.Optional[typing.Any], # type: ignore
142
143
  object_=_response.json(),
143
144
  ),
144
145
  )
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .memory_variables_get_response import MemoryVariablesGetResponse
4
+
5
+ __all__ = ["MemoryVariablesGetResponse"]
@@ -1,12 +1,12 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- from ...core.pydantic_utilities import UniversalBaseModel
3
+ from ....core.unchecked_base_model import UncheckedBaseModel
4
4
  import typing
5
- from ...core.pydantic_utilities import IS_PYDANTIC_V2
5
+ from ....core.pydantic_utilities import IS_PYDANTIC_V2
6
6
  import pydantic
7
7
 
8
8
 
9
- class AgentsGetAgentVariablesResponse(UniversalBaseModel):
9
+ class MemoryVariablesGetResponse(UncheckedBaseModel):
10
10
  variables: typing.Dict[str, str]
11
11
 
12
12
  if IS_PYDANTIC_V2:
@@ -5,7 +5,7 @@ from ...core.client_wrapper import SyncClientWrapper
5
5
  from ...core.request_options import RequestOptions
6
6
  from .types.messages_list_response import MessagesListResponse
7
7
  from ...core.jsonable_encoder import jsonable_encoder
8
- from ...core.pydantic_utilities import parse_obj_as
8
+ from ...core.unchecked_base_model import construct_type
9
9
  from ...errors.unprocessable_entity_error import UnprocessableEntityError
10
10
  from ...types.http_validation_error import HttpValidationError
11
11
  from json.decoder import JSONDecodeError
@@ -21,6 +21,7 @@ from ...types.letta_schemas_message_message import LettaSchemasMessageMessage
21
21
  from .types.letta_streaming_response import LettaStreamingResponse
22
22
  import httpx_sse
23
23
  import json
24
+ from ...types.job import Job
24
25
  from ...core.client_wrapper import AsyncClientWrapper
25
26
 
26
27
  # this is used as the default value for optional parameters
@@ -99,7 +100,7 @@ class MessagesClient:
99
100
  if 200 <= _response.status_code < 300:
100
101
  return typing.cast(
101
102
  MessagesListResponse,
102
- parse_obj_as(
103
+ construct_type(
103
104
  type_=MessagesListResponse, # type: ignore
104
105
  object_=_response.json(),
105
106
  ),
@@ -108,7 +109,7 @@ class MessagesClient:
108
109
  raise UnprocessableEntityError(
109
110
  typing.cast(
110
111
  HttpValidationError,
111
- parse_obj_as(
112
+ construct_type(
112
113
  type_=HttpValidationError, # type: ignore
113
114
  object_=_response.json(),
114
115
  ),
@@ -124,6 +125,7 @@ class MessagesClient:
124
125
  agent_id: str,
125
126
  *,
126
127
  messages: typing.Sequence[MessageCreate],
128
+ use_assistant_message: typing.Optional[bool] = OMIT,
127
129
  assistant_message_tool_name: typing.Optional[str] = OMIT,
128
130
  assistant_message_tool_kwarg: typing.Optional[str] = OMIT,
129
131
  request_options: typing.Optional[RequestOptions] = None,
@@ -139,6 +141,9 @@ class MessagesClient:
139
141
  messages : typing.Sequence[MessageCreate]
140
142
  The messages to be sent to the agent.
141
143
 
144
+ use_assistant_message : typing.Optional[bool]
145
+ Whether the server should parse specific tool call arguments (default `send_message`) as `AssistantMessage` objects.
146
+
142
147
  assistant_message_tool_name : typing.Optional[str]
143
148
  The name of the designated message tool.
144
149
 
@@ -177,6 +182,7 @@ class MessagesClient:
177
182
  "messages": convert_and_respect_annotation_metadata(
178
183
  object_=messages, annotation=typing.Sequence[MessageCreate], direction="write"
179
184
  ),
185
+ "use_assistant_message": use_assistant_message,
180
186
  "assistant_message_tool_name": assistant_message_tool_name,
181
187
  "assistant_message_tool_kwarg": assistant_message_tool_kwarg,
182
188
  },
@@ -187,7 +193,7 @@ class MessagesClient:
187
193
  if 200 <= _response.status_code < 300:
188
194
  return typing.cast(
189
195
  LettaResponse,
190
- parse_obj_as(
196
+ construct_type(
191
197
  type_=LettaResponse, # type: ignore
192
198
  object_=_response.json(),
193
199
  ),
@@ -196,7 +202,7 @@ class MessagesClient:
196
202
  raise UnprocessableEntityError(
197
203
  typing.cast(
198
204
  HttpValidationError,
199
- parse_obj_as(
205
+ construct_type(
200
206
  type_=HttpValidationError, # type: ignore
201
207
  object_=_response.json(),
202
208
  ),
@@ -287,7 +293,7 @@ class MessagesClient:
287
293
  if 200 <= _response.status_code < 300:
288
294
  return typing.cast(
289
295
  LettaSchemasMessageMessage,
290
- parse_obj_as(
296
+ construct_type(
291
297
  type_=LettaSchemasMessageMessage, # type: ignore
292
298
  object_=_response.json(),
293
299
  ),
@@ -296,7 +302,7 @@ class MessagesClient:
296
302
  raise UnprocessableEntityError(
297
303
  typing.cast(
298
304
  HttpValidationError,
299
- parse_obj_as(
305
+ construct_type(
300
306
  type_=HttpValidationError, # type: ignore
301
307
  object_=_response.json(),
302
308
  ),
@@ -312,6 +318,7 @@ class MessagesClient:
312
318
  agent_id: str,
313
319
  *,
314
320
  messages: typing.Sequence[MessageCreate],
321
+ use_assistant_message: typing.Optional[bool] = OMIT,
315
322
  assistant_message_tool_name: typing.Optional[str] = OMIT,
316
323
  assistant_message_tool_kwarg: typing.Optional[str] = OMIT,
317
324
  stream_tokens: typing.Optional[bool] = OMIT,
@@ -329,6 +336,9 @@ class MessagesClient:
329
336
  messages : typing.Sequence[MessageCreate]
330
337
  The messages to be sent to the agent.
331
338
 
339
+ use_assistant_message : typing.Optional[bool]
340
+ Whether the server should parse specific tool call arguments (default `send_message`) as `AssistantMessage` objects.
341
+
332
342
  assistant_message_tool_name : typing.Optional[str]
333
343
  The name of the designated message tool.
334
344
 
@@ -372,6 +382,7 @@ class MessagesClient:
372
382
  "messages": convert_and_respect_annotation_metadata(
373
383
  object_=messages, annotation=typing.Sequence[MessageCreate], direction="write"
374
384
  ),
385
+ "use_assistant_message": use_assistant_message,
375
386
  "assistant_message_tool_name": assistant_message_tool_name,
376
387
  "assistant_message_tool_kwarg": assistant_message_tool_kwarg,
377
388
  "stream_tokens": stream_tokens,
@@ -389,7 +400,7 @@ class MessagesClient:
389
400
  try:
390
401
  yield typing.cast(
391
402
  LettaStreamingResponse,
392
- parse_obj_as(
403
+ construct_type(
393
404
  type_=LettaStreamingResponse, # type: ignore
394
405
  object_=json.loads(_sse.data),
395
406
  ),
@@ -402,7 +413,7 @@ class MessagesClient:
402
413
  raise UnprocessableEntityError(
403
414
  typing.cast(
404
415
  HttpValidationError,
405
- parse_obj_as(
416
+ construct_type(
406
417
  type_=HttpValidationError, # type: ignore
407
418
  object_=_response.json(),
408
419
  ),
@@ -413,6 +424,99 @@ class MessagesClient:
413
424
  raise ApiError(status_code=_response.status_code, body=_response.text)
414
425
  raise ApiError(status_code=_response.status_code, body=_response_json)
415
426
 
427
+ def create_async(
428
+ self,
429
+ agent_id: str,
430
+ *,
431
+ messages: typing.Sequence[MessageCreate],
432
+ use_assistant_message: typing.Optional[bool] = OMIT,
433
+ assistant_message_tool_name: typing.Optional[str] = OMIT,
434
+ assistant_message_tool_kwarg: typing.Optional[str] = OMIT,
435
+ request_options: typing.Optional[RequestOptions] = None,
436
+ ) -> Job:
437
+ """
438
+ Asynchronously process a user message and return a job ID.
439
+ The actual processing happens in the background, and the status can be checked using the job ID.
440
+
441
+ Parameters
442
+ ----------
443
+ agent_id : str
444
+
445
+ messages : typing.Sequence[MessageCreate]
446
+ The messages to be sent to the agent.
447
+
448
+ use_assistant_message : typing.Optional[bool]
449
+ Whether the server should parse specific tool call arguments (default `send_message`) as `AssistantMessage` objects.
450
+
451
+ assistant_message_tool_name : typing.Optional[str]
452
+ The name of the designated message tool.
453
+
454
+ assistant_message_tool_kwarg : typing.Optional[str]
455
+ The name of the message argument in the designated message tool.
456
+
457
+ request_options : typing.Optional[RequestOptions]
458
+ Request-specific configuration.
459
+
460
+ Returns
461
+ -------
462
+ Job
463
+ Successful Response
464
+
465
+ Examples
466
+ --------
467
+ from letta import Letta, MessageCreate
468
+
469
+ client = Letta(
470
+ token="YOUR_TOKEN",
471
+ )
472
+ client.agents.messages.create_async(
473
+ agent_id="agent_id",
474
+ messages=[
475
+ MessageCreate(
476
+ role="user",
477
+ text="text",
478
+ )
479
+ ],
480
+ )
481
+ """
482
+ _response = self._client_wrapper.httpx_client.request(
483
+ f"v1/agents/{jsonable_encoder(agent_id)}/messages/async",
484
+ method="POST",
485
+ json={
486
+ "messages": convert_and_respect_annotation_metadata(
487
+ object_=messages, annotation=typing.Sequence[MessageCreate], direction="write"
488
+ ),
489
+ "use_assistant_message": use_assistant_message,
490
+ "assistant_message_tool_name": assistant_message_tool_name,
491
+ "assistant_message_tool_kwarg": assistant_message_tool_kwarg,
492
+ },
493
+ request_options=request_options,
494
+ omit=OMIT,
495
+ )
496
+ try:
497
+ if 200 <= _response.status_code < 300:
498
+ return typing.cast(
499
+ Job,
500
+ construct_type(
501
+ type_=Job, # type: ignore
502
+ object_=_response.json(),
503
+ ),
504
+ )
505
+ if _response.status_code == 422:
506
+ raise UnprocessableEntityError(
507
+ typing.cast(
508
+ HttpValidationError,
509
+ construct_type(
510
+ type_=HttpValidationError, # type: ignore
511
+ object_=_response.json(),
512
+ ),
513
+ )
514
+ )
515
+ _response_json = _response.json()
516
+ except JSONDecodeError:
517
+ raise ApiError(status_code=_response.status_code, body=_response.text)
518
+ raise ApiError(status_code=_response.status_code, body=_response_json)
519
+
416
520
 
417
521
  class AsyncMessagesClient:
418
522
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
@@ -494,7 +598,7 @@ class AsyncMessagesClient:
494
598
  if 200 <= _response.status_code < 300:
495
599
  return typing.cast(
496
600
  MessagesListResponse,
497
- parse_obj_as(
601
+ construct_type(
498
602
  type_=MessagesListResponse, # type: ignore
499
603
  object_=_response.json(),
500
604
  ),
@@ -503,7 +607,7 @@ class AsyncMessagesClient:
503
607
  raise UnprocessableEntityError(
504
608
  typing.cast(
505
609
  HttpValidationError,
506
- parse_obj_as(
610
+ construct_type(
507
611
  type_=HttpValidationError, # type: ignore
508
612
  object_=_response.json(),
509
613
  ),
@@ -519,6 +623,7 @@ class AsyncMessagesClient:
519
623
  agent_id: str,
520
624
  *,
521
625
  messages: typing.Sequence[MessageCreate],
626
+ use_assistant_message: typing.Optional[bool] = OMIT,
522
627
  assistant_message_tool_name: typing.Optional[str] = OMIT,
523
628
  assistant_message_tool_kwarg: typing.Optional[str] = OMIT,
524
629
  request_options: typing.Optional[RequestOptions] = None,
@@ -534,6 +639,9 @@ class AsyncMessagesClient:
534
639
  messages : typing.Sequence[MessageCreate]
535
640
  The messages to be sent to the agent.
536
641
 
642
+ use_assistant_message : typing.Optional[bool]
643
+ Whether the server should parse specific tool call arguments (default `send_message`) as `AssistantMessage` objects.
644
+
537
645
  assistant_message_tool_name : typing.Optional[str]
538
646
  The name of the designated message tool.
539
647
 
@@ -580,6 +688,7 @@ class AsyncMessagesClient:
580
688
  "messages": convert_and_respect_annotation_metadata(
581
689
  object_=messages, annotation=typing.Sequence[MessageCreate], direction="write"
582
690
  ),
691
+ "use_assistant_message": use_assistant_message,
583
692
  "assistant_message_tool_name": assistant_message_tool_name,
584
693
  "assistant_message_tool_kwarg": assistant_message_tool_kwarg,
585
694
  },
@@ -590,7 +699,7 @@ class AsyncMessagesClient:
590
699
  if 200 <= _response.status_code < 300:
591
700
  return typing.cast(
592
701
  LettaResponse,
593
- parse_obj_as(
702
+ construct_type(
594
703
  type_=LettaResponse, # type: ignore
595
704
  object_=_response.json(),
596
705
  ),
@@ -599,7 +708,7 @@ class AsyncMessagesClient:
599
708
  raise UnprocessableEntityError(
600
709
  typing.cast(
601
710
  HttpValidationError,
602
- parse_obj_as(
711
+ construct_type(
603
712
  type_=HttpValidationError, # type: ignore
604
713
  object_=_response.json(),
605
714
  ),
@@ -698,7 +807,7 @@ class AsyncMessagesClient:
698
807
  if 200 <= _response.status_code < 300:
699
808
  return typing.cast(
700
809
  LettaSchemasMessageMessage,
701
- parse_obj_as(
810
+ construct_type(
702
811
  type_=LettaSchemasMessageMessage, # type: ignore
703
812
  object_=_response.json(),
704
813
  ),
@@ -707,7 +816,7 @@ class AsyncMessagesClient:
707
816
  raise UnprocessableEntityError(
708
817
  typing.cast(
709
818
  HttpValidationError,
710
- parse_obj_as(
819
+ construct_type(
711
820
  type_=HttpValidationError, # type: ignore
712
821
  object_=_response.json(),
713
822
  ),
@@ -723,6 +832,7 @@ class AsyncMessagesClient:
723
832
  agent_id: str,
724
833
  *,
725
834
  messages: typing.Sequence[MessageCreate],
835
+ use_assistant_message: typing.Optional[bool] = OMIT,
726
836
  assistant_message_tool_name: typing.Optional[str] = OMIT,
727
837
  assistant_message_tool_kwarg: typing.Optional[str] = OMIT,
728
838
  stream_tokens: typing.Optional[bool] = OMIT,
@@ -740,6 +850,9 @@ class AsyncMessagesClient:
740
850
  messages : typing.Sequence[MessageCreate]
741
851
  The messages to be sent to the agent.
742
852
 
853
+ use_assistant_message : typing.Optional[bool]
854
+ Whether the server should parse specific tool call arguments (default `send_message`) as `AssistantMessage` objects.
855
+
743
856
  assistant_message_tool_name : typing.Optional[str]
744
857
  The name of the designated message tool.
745
858
 
@@ -791,6 +904,7 @@ class AsyncMessagesClient:
791
904
  "messages": convert_and_respect_annotation_metadata(
792
905
  object_=messages, annotation=typing.Sequence[MessageCreate], direction="write"
793
906
  ),
907
+ "use_assistant_message": use_assistant_message,
794
908
  "assistant_message_tool_name": assistant_message_tool_name,
795
909
  "assistant_message_tool_kwarg": assistant_message_tool_kwarg,
796
910
  "stream_tokens": stream_tokens,
@@ -808,7 +922,7 @@ class AsyncMessagesClient:
808
922
  try:
809
923
  yield typing.cast(
810
924
  LettaStreamingResponse,
811
- parse_obj_as(
925
+ construct_type(
812
926
  type_=LettaStreamingResponse, # type: ignore
813
927
  object_=json.loads(_sse.data),
814
928
  ),
@@ -821,7 +935,7 @@ class AsyncMessagesClient:
821
935
  raise UnprocessableEntityError(
822
936
  typing.cast(
823
937
  HttpValidationError,
824
- parse_obj_as(
938
+ construct_type(
825
939
  type_=HttpValidationError, # type: ignore
826
940
  object_=_response.json(),
827
941
  ),
@@ -831,3 +945,104 @@ class AsyncMessagesClient:
831
945
  except JSONDecodeError:
832
946
  raise ApiError(status_code=_response.status_code, body=_response.text)
833
947
  raise ApiError(status_code=_response.status_code, body=_response_json)
948
+
949
+ async def create_async(
950
+ self,
951
+ agent_id: str,
952
+ *,
953
+ messages: typing.Sequence[MessageCreate],
954
+ use_assistant_message: typing.Optional[bool] = OMIT,
955
+ assistant_message_tool_name: typing.Optional[str] = OMIT,
956
+ assistant_message_tool_kwarg: typing.Optional[str] = OMIT,
957
+ request_options: typing.Optional[RequestOptions] = None,
958
+ ) -> Job:
959
+ """
960
+ Asynchronously process a user message and return a job ID.
961
+ The actual processing happens in the background, and the status can be checked using the job ID.
962
+
963
+ Parameters
964
+ ----------
965
+ agent_id : str
966
+
967
+ messages : typing.Sequence[MessageCreate]
968
+ The messages to be sent to the agent.
969
+
970
+ use_assistant_message : typing.Optional[bool]
971
+ Whether the server should parse specific tool call arguments (default `send_message`) as `AssistantMessage` objects.
972
+
973
+ assistant_message_tool_name : typing.Optional[str]
974
+ The name of the designated message tool.
975
+
976
+ assistant_message_tool_kwarg : typing.Optional[str]
977
+ The name of the message argument in the designated message tool.
978
+
979
+ request_options : typing.Optional[RequestOptions]
980
+ Request-specific configuration.
981
+
982
+ Returns
983
+ -------
984
+ Job
985
+ Successful Response
986
+
987
+ Examples
988
+ --------
989
+ import asyncio
990
+
991
+ from letta import AsyncLetta, MessageCreate
992
+
993
+ client = AsyncLetta(
994
+ token="YOUR_TOKEN",
995
+ )
996
+
997
+
998
+ async def main() -> None:
999
+ await client.agents.messages.create_async(
1000
+ agent_id="agent_id",
1001
+ messages=[
1002
+ MessageCreate(
1003
+ role="user",
1004
+ text="text",
1005
+ )
1006
+ ],
1007
+ )
1008
+
1009
+
1010
+ asyncio.run(main())
1011
+ """
1012
+ _response = await self._client_wrapper.httpx_client.request(
1013
+ f"v1/agents/{jsonable_encoder(agent_id)}/messages/async",
1014
+ method="POST",
1015
+ json={
1016
+ "messages": convert_and_respect_annotation_metadata(
1017
+ object_=messages, annotation=typing.Sequence[MessageCreate], direction="write"
1018
+ ),
1019
+ "use_assistant_message": use_assistant_message,
1020
+ "assistant_message_tool_name": assistant_message_tool_name,
1021
+ "assistant_message_tool_kwarg": assistant_message_tool_kwarg,
1022
+ },
1023
+ request_options=request_options,
1024
+ omit=OMIT,
1025
+ )
1026
+ try:
1027
+ if 200 <= _response.status_code < 300:
1028
+ return typing.cast(
1029
+ Job,
1030
+ construct_type(
1031
+ type_=Job, # type: ignore
1032
+ object_=_response.json(),
1033
+ ),
1034
+ )
1035
+ if _response.status_code == 422:
1036
+ raise UnprocessableEntityError(
1037
+ typing.cast(
1038
+ HttpValidationError,
1039
+ construct_type(
1040
+ type_=HttpValidationError, # type: ignore
1041
+ object_=_response.json(),
1042
+ ),
1043
+ )
1044
+ )
1045
+ _response_json = _response.json()
1046
+ except JSONDecodeError:
1047
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1048
+ raise ApiError(status_code=_response.status_code, body=_response_json)