letta-client 1.0.0a8__py3-none-any.whl → 1.0.0a10__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.
- letta_client/_version.py +1 -1
- letta_client/pagination.py +174 -1
- letta_client/resources/agents/agents.py +396 -396
- letta_client/resources/agents/blocks.py +200 -190
- letta_client/resources/agents/files.py +13 -10
- letta_client/resources/agents/messages.py +367 -367
- letta_client/resources/agents/tools.py +6 -6
- letta_client/resources/archives.py +121 -111
- letta_client/resources/batches/messages.py +14 -11
- letta_client/resources/blocks/blocks.py +241 -222
- letta_client/resources/folders/folders.py +133 -133
- letta_client/resources/groups/groups.py +141 -141
- letta_client/resources/groups/messages.py +198 -198
- letta_client/resources/identities/blocks.py +7 -7
- letta_client/resources/identities/identities.py +141 -141
- letta_client/resources/tools.py +794 -194
- letta_client/types/__init__.py +11 -8
- letta_client/types/{agent_update_params.py → agent_modify_params.py} +2 -2
- letta_client/types/agent_state.py +6 -3
- letta_client/types/agents/__init__.py +6 -3
- letta_client/types/agents/block.py +6 -3
- letta_client/types/agents/block_list_response.py +63 -0
- letta_client/types/agents/{block_update_params.py → block_modify_params.py} +8 -5
- letta_client/types/agents/block_modify_response.py +63 -0
- letta_client/types/agents/block_retrieve_response.py +63 -0
- letta_client/types/agents/file_list_response.py +3 -14
- letta_client/types/agents/{message_update_params.py → message_modify_params.py} +2 -2
- letta_client/types/agents/{message_update_response.py → message_modify_response.py} +2 -2
- letta_client/types/archive_list_params.py +3 -0
- letta_client/types/{archive_update_params.py → archive_modify_params.py} +2 -2
- letta_client/types/batches/__init__.py +0 -1
- letta_client/types/block_create_params.py +6 -3
- letta_client/types/block_create_response.py +63 -0
- letta_client/types/block_list_response.py +63 -0
- letta_client/types/{block_update_params.py → block_modify_params.py} +8 -5
- letta_client/types/block_modify_response.py +63 -0
- letta_client/types/block_retrieve_response.py +63 -0
- letta_client/types/create_block_param.py +6 -3
- letta_client/types/{folder_update_params.py → folder_modify_params.py} +2 -2
- letta_client/types/{group_update_params.py → group_modify_params.py} +2 -2
- letta_client/types/groups/__init__.py +2 -2
- letta_client/types/groups/{message_update_params.py → message_modify_params.py} +2 -2
- letta_client/types/groups/{message_update_response.py → message_modify_response.py} +2 -2
- letta_client/types/identities/__init__.py +1 -0
- letta_client/types/identities/block_list_response.py +63 -0
- letta_client/types/{identity_update_params.py → identity_modify_params.py} +2 -2
- letta_client/types/tool.py +106 -2
- letta_client/types/{tool_update_params.py → tool_modify_params.py} +2 -2
- {letta_client-1.0.0a8.dist-info → letta_client-1.0.0a10.dist-info}/METADATA +1 -1
- {letta_client-1.0.0a8.dist-info → letta_client-1.0.0a10.dist-info}/RECORD +52 -46
- letta_client/types/archive_list_response.py +0 -10
- letta_client/types/batches/message_list_response.py +0 -12
- {letta_client-1.0.0a8.dist-info → letta_client-1.0.0a10.dist-info}/WHEEL +0 -0
- {letta_client-1.0.0a8.dist-info → letta_client-1.0.0a10.dist-info}/licenses/LICENSE +0 -0
|
@@ -24,8 +24,8 @@ from ...types.agents import (
|
|
|
24
24
|
message_send_params,
|
|
25
25
|
message_reset_params,
|
|
26
26
|
message_cancel_params,
|
|
27
|
+
message_modify_params,
|
|
27
28
|
message_stream_params,
|
|
28
|
-
message_update_params,
|
|
29
29
|
message_send_async_params,
|
|
30
30
|
)
|
|
31
31
|
from ...types.agents.run import Run
|
|
@@ -34,7 +34,7 @@ from ...types.agents.message_type import MessageType
|
|
|
34
34
|
from ...types.agents.letta_response import LettaResponse
|
|
35
35
|
from ...types.agents.letta_message_union import LettaMessageUnion
|
|
36
36
|
from ...types.agents.message_cancel_response import MessageCancelResponse
|
|
37
|
-
from ...types.agents.
|
|
37
|
+
from ...types.agents.message_modify_response import MessageModifyResponse
|
|
38
38
|
from ...types.agents.letta_user_message_content_union_param import LettaUserMessageContentUnionParam
|
|
39
39
|
from ...types.agents.letta_assistant_message_content_union_param import LettaAssistantMessageContentUnionParam
|
|
40
40
|
|
|
@@ -61,8 +61,139 @@ class MessagesResource(SyncAPIResource):
|
|
|
61
61
|
"""
|
|
62
62
|
return MessagesResourceWithStreamingResponse(self)
|
|
63
63
|
|
|
64
|
+
def list(
|
|
65
|
+
self,
|
|
66
|
+
agent_id: str,
|
|
67
|
+
*,
|
|
68
|
+
after: Optional[str] | Omit = omit,
|
|
69
|
+
assistant_message_tool_kwarg: str | Omit = omit,
|
|
70
|
+
assistant_message_tool_name: str | Omit = omit,
|
|
71
|
+
before: Optional[str] | Omit = omit,
|
|
72
|
+
group_id: Optional[str] | Omit = omit,
|
|
73
|
+
include_err: Optional[bool] | Omit = omit,
|
|
74
|
+
limit: Optional[int] | Omit = omit,
|
|
75
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
76
|
+
order_by: Literal["created_at"] | Omit = omit,
|
|
77
|
+
use_assistant_message: bool | Omit = omit,
|
|
78
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
79
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
80
|
+
extra_headers: Headers | None = None,
|
|
81
|
+
extra_query: Query | None = None,
|
|
82
|
+
extra_body: Body | None = None,
|
|
83
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
84
|
+
) -> SyncArrayPage[LettaMessageUnion]:
|
|
85
|
+
"""
|
|
86
|
+
Retrieve message history for an agent.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
90
|
+
|
|
91
|
+
after: Message ID cursor for pagination. Returns messages that come after this message
|
|
92
|
+
ID in the specified sort order
|
|
93
|
+
|
|
94
|
+
assistant_message_tool_kwarg: The name of the message argument.
|
|
95
|
+
|
|
96
|
+
assistant_message_tool_name: The name of the designated message tool.
|
|
97
|
+
|
|
98
|
+
before: Message ID cursor for pagination. Returns messages that come before this message
|
|
99
|
+
ID in the specified sort order
|
|
100
|
+
|
|
101
|
+
group_id: Group ID to filter messages by.
|
|
102
|
+
|
|
103
|
+
include_err: Whether to include error messages and error statuses. For debugging purposes
|
|
104
|
+
only.
|
|
105
|
+
|
|
106
|
+
limit: Maximum number of messages to return
|
|
107
|
+
|
|
108
|
+
order: Sort order for messages by creation time. 'asc' for oldest first, 'desc' for
|
|
109
|
+
newest first
|
|
110
|
+
|
|
111
|
+
order_by: Field to sort by
|
|
112
|
+
|
|
113
|
+
use_assistant_message: Whether to use assistant messages
|
|
114
|
+
|
|
115
|
+
extra_headers: Send extra headers
|
|
116
|
+
|
|
117
|
+
extra_query: Add additional query parameters to the request
|
|
118
|
+
|
|
119
|
+
extra_body: Add additional JSON properties to the request
|
|
120
|
+
|
|
121
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
122
|
+
"""
|
|
123
|
+
if not agent_id:
|
|
124
|
+
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
125
|
+
return self._get_api_list(
|
|
126
|
+
f"/v1/agents/{agent_id}/messages",
|
|
127
|
+
page=SyncArrayPage[LettaMessageUnion],
|
|
128
|
+
options=make_request_options(
|
|
129
|
+
extra_headers=extra_headers,
|
|
130
|
+
extra_query=extra_query,
|
|
131
|
+
extra_body=extra_body,
|
|
132
|
+
timeout=timeout,
|
|
133
|
+
query=maybe_transform(
|
|
134
|
+
{
|
|
135
|
+
"after": after,
|
|
136
|
+
"assistant_message_tool_kwarg": assistant_message_tool_kwarg,
|
|
137
|
+
"assistant_message_tool_name": assistant_message_tool_name,
|
|
138
|
+
"before": before,
|
|
139
|
+
"group_id": group_id,
|
|
140
|
+
"include_err": include_err,
|
|
141
|
+
"limit": limit,
|
|
142
|
+
"order": order,
|
|
143
|
+
"order_by": order_by,
|
|
144
|
+
"use_assistant_message": use_assistant_message,
|
|
145
|
+
},
|
|
146
|
+
message_list_params.MessageListParams,
|
|
147
|
+
),
|
|
148
|
+
),
|
|
149
|
+
model=cast(Any, LettaMessageUnion), # Union types cannot be passed in as arguments in the type system
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
def cancel(
|
|
153
|
+
self,
|
|
154
|
+
agent_id: str,
|
|
155
|
+
*,
|
|
156
|
+
run_ids: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
157
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
158
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
159
|
+
extra_headers: Headers | None = None,
|
|
160
|
+
extra_query: Query | None = None,
|
|
161
|
+
extra_body: Body | None = None,
|
|
162
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
163
|
+
) -> MessageCancelResponse:
|
|
164
|
+
"""Cancel runs associated with an agent.
|
|
165
|
+
|
|
166
|
+
If run_ids are passed in, cancel those in
|
|
167
|
+
particular.
|
|
168
|
+
|
|
169
|
+
Note to cancel active runs associated with an agent, redis is required.
|
|
170
|
+
|
|
171
|
+
Args:
|
|
172
|
+
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
173
|
+
|
|
174
|
+
run_ids: Optional list of run IDs to cancel
|
|
175
|
+
|
|
176
|
+
extra_headers: Send extra headers
|
|
177
|
+
|
|
178
|
+
extra_query: Add additional query parameters to the request
|
|
179
|
+
|
|
180
|
+
extra_body: Add additional JSON properties to the request
|
|
181
|
+
|
|
182
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
183
|
+
"""
|
|
184
|
+
if not agent_id:
|
|
185
|
+
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
186
|
+
return self._post(
|
|
187
|
+
f"/v1/agents/{agent_id}/messages/cancel",
|
|
188
|
+
body=maybe_transform({"run_ids": run_ids}, message_cancel_params.MessageCancelParams),
|
|
189
|
+
options=make_request_options(
|
|
190
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
191
|
+
),
|
|
192
|
+
cast_to=MessageCancelResponse,
|
|
193
|
+
)
|
|
194
|
+
|
|
64
195
|
@overload
|
|
65
|
-
def
|
|
196
|
+
def modify(
|
|
66
197
|
self,
|
|
67
198
|
message_id: str,
|
|
68
199
|
*,
|
|
@@ -75,7 +206,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
75
206
|
extra_query: Query | None = None,
|
|
76
207
|
extra_body: Body | None = None,
|
|
77
208
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
78
|
-
) ->
|
|
209
|
+
) -> MessageModifyResponse:
|
|
79
210
|
"""
|
|
80
211
|
Update the details of a message associated with an agent.
|
|
81
212
|
|
|
@@ -98,7 +229,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
98
229
|
...
|
|
99
230
|
|
|
100
231
|
@overload
|
|
101
|
-
def
|
|
232
|
+
def modify(
|
|
102
233
|
self,
|
|
103
234
|
message_id: str,
|
|
104
235
|
*,
|
|
@@ -111,7 +242,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
111
242
|
extra_query: Query | None = None,
|
|
112
243
|
extra_body: Body | None = None,
|
|
113
244
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
114
|
-
) ->
|
|
245
|
+
) -> MessageModifyResponse:
|
|
115
246
|
"""
|
|
116
247
|
Update the details of a message associated with an agent.
|
|
117
248
|
|
|
@@ -134,7 +265,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
134
265
|
...
|
|
135
266
|
|
|
136
267
|
@overload
|
|
137
|
-
def
|
|
268
|
+
def modify(
|
|
138
269
|
self,
|
|
139
270
|
message_id: str,
|
|
140
271
|
*,
|
|
@@ -147,7 +278,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
147
278
|
extra_query: Query | None = None,
|
|
148
279
|
extra_body: Body | None = None,
|
|
149
280
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
150
|
-
) ->
|
|
281
|
+
) -> MessageModifyResponse:
|
|
151
282
|
"""
|
|
152
283
|
Update the details of a message associated with an agent.
|
|
153
284
|
|
|
@@ -167,7 +298,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
167
298
|
...
|
|
168
299
|
|
|
169
300
|
@overload
|
|
170
|
-
def
|
|
301
|
+
def modify(
|
|
171
302
|
self,
|
|
172
303
|
message_id: str,
|
|
173
304
|
*,
|
|
@@ -180,7 +311,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
180
311
|
extra_query: Query | None = None,
|
|
181
312
|
extra_body: Body | None = None,
|
|
182
313
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
183
|
-
) ->
|
|
314
|
+
) -> MessageModifyResponse:
|
|
184
315
|
"""
|
|
185
316
|
Update the details of a message associated with an agent.
|
|
186
317
|
|
|
@@ -203,7 +334,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
203
334
|
...
|
|
204
335
|
|
|
205
336
|
@required_args(["agent_id", "content"], ["agent_id", "reasoning"])
|
|
206
|
-
def
|
|
337
|
+
def modify(
|
|
207
338
|
self,
|
|
208
339
|
message_id: str,
|
|
209
340
|
*,
|
|
@@ -221,13 +352,13 @@ class MessagesResource(SyncAPIResource):
|
|
|
221
352
|
extra_query: Query | None = None,
|
|
222
353
|
extra_body: Body | None = None,
|
|
223
354
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
224
|
-
) ->
|
|
355
|
+
) -> MessageModifyResponse:
|
|
225
356
|
if not agent_id:
|
|
226
357
|
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
227
358
|
if not message_id:
|
|
228
359
|
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
229
360
|
return cast(
|
|
230
|
-
|
|
361
|
+
MessageModifyResponse,
|
|
231
362
|
self._patch(
|
|
232
363
|
f"/v1/agents/{agent_id}/messages/{message_id}",
|
|
233
364
|
body=maybe_transform(
|
|
@@ -236,148 +367,17 @@ class MessagesResource(SyncAPIResource):
|
|
|
236
367
|
"message_type": message_type,
|
|
237
368
|
"reasoning": reasoning,
|
|
238
369
|
},
|
|
239
|
-
|
|
370
|
+
message_modify_params.MessageModifyParams,
|
|
240
371
|
),
|
|
241
372
|
options=make_request_options(
|
|
242
373
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
243
374
|
),
|
|
244
375
|
cast_to=cast(
|
|
245
|
-
Any,
|
|
376
|
+
Any, MessageModifyResponse
|
|
246
377
|
), # Union types cannot be passed in as arguments in the type system
|
|
247
378
|
),
|
|
248
379
|
)
|
|
249
380
|
|
|
250
|
-
def list(
|
|
251
|
-
self,
|
|
252
|
-
agent_id: str,
|
|
253
|
-
*,
|
|
254
|
-
after: Optional[str] | Omit = omit,
|
|
255
|
-
assistant_message_tool_kwarg: str | Omit = omit,
|
|
256
|
-
assistant_message_tool_name: str | Omit = omit,
|
|
257
|
-
before: Optional[str] | Omit = omit,
|
|
258
|
-
group_id: Optional[str] | Omit = omit,
|
|
259
|
-
include_err: Optional[bool] | Omit = omit,
|
|
260
|
-
limit: Optional[int] | Omit = omit,
|
|
261
|
-
order: Literal["asc", "desc"] | Omit = omit,
|
|
262
|
-
order_by: Literal["created_at"] | Omit = omit,
|
|
263
|
-
use_assistant_message: bool | Omit = omit,
|
|
264
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
265
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
266
|
-
extra_headers: Headers | None = None,
|
|
267
|
-
extra_query: Query | None = None,
|
|
268
|
-
extra_body: Body | None = None,
|
|
269
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
270
|
-
) -> SyncArrayPage[LettaMessageUnion]:
|
|
271
|
-
"""
|
|
272
|
-
Retrieve message history for an agent.
|
|
273
|
-
|
|
274
|
-
Args:
|
|
275
|
-
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
276
|
-
|
|
277
|
-
after: Message ID cursor for pagination. Returns messages that come after this message
|
|
278
|
-
ID in the specified sort order
|
|
279
|
-
|
|
280
|
-
assistant_message_tool_kwarg: The name of the message argument.
|
|
281
|
-
|
|
282
|
-
assistant_message_tool_name: The name of the designated message tool.
|
|
283
|
-
|
|
284
|
-
before: Message ID cursor for pagination. Returns messages that come before this message
|
|
285
|
-
ID in the specified sort order
|
|
286
|
-
|
|
287
|
-
group_id: Group ID to filter messages by.
|
|
288
|
-
|
|
289
|
-
include_err: Whether to include error messages and error statuses. For debugging purposes
|
|
290
|
-
only.
|
|
291
|
-
|
|
292
|
-
limit: Maximum number of messages to return
|
|
293
|
-
|
|
294
|
-
order: Sort order for messages by creation time. 'asc' for oldest first, 'desc' for
|
|
295
|
-
newest first
|
|
296
|
-
|
|
297
|
-
order_by: Field to sort by
|
|
298
|
-
|
|
299
|
-
use_assistant_message: Whether to use assistant messages
|
|
300
|
-
|
|
301
|
-
extra_headers: Send extra headers
|
|
302
|
-
|
|
303
|
-
extra_query: Add additional query parameters to the request
|
|
304
|
-
|
|
305
|
-
extra_body: Add additional JSON properties to the request
|
|
306
|
-
|
|
307
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
308
|
-
"""
|
|
309
|
-
if not agent_id:
|
|
310
|
-
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
311
|
-
return self._get_api_list(
|
|
312
|
-
f"/v1/agents/{agent_id}/messages",
|
|
313
|
-
page=SyncArrayPage[LettaMessageUnion],
|
|
314
|
-
options=make_request_options(
|
|
315
|
-
extra_headers=extra_headers,
|
|
316
|
-
extra_query=extra_query,
|
|
317
|
-
extra_body=extra_body,
|
|
318
|
-
timeout=timeout,
|
|
319
|
-
query=maybe_transform(
|
|
320
|
-
{
|
|
321
|
-
"after": after,
|
|
322
|
-
"assistant_message_tool_kwarg": assistant_message_tool_kwarg,
|
|
323
|
-
"assistant_message_tool_name": assistant_message_tool_name,
|
|
324
|
-
"before": before,
|
|
325
|
-
"group_id": group_id,
|
|
326
|
-
"include_err": include_err,
|
|
327
|
-
"limit": limit,
|
|
328
|
-
"order": order,
|
|
329
|
-
"order_by": order_by,
|
|
330
|
-
"use_assistant_message": use_assistant_message,
|
|
331
|
-
},
|
|
332
|
-
message_list_params.MessageListParams,
|
|
333
|
-
),
|
|
334
|
-
),
|
|
335
|
-
model=cast(Any, LettaMessageUnion), # Union types cannot be passed in as arguments in the type system
|
|
336
|
-
)
|
|
337
|
-
|
|
338
|
-
def cancel(
|
|
339
|
-
self,
|
|
340
|
-
agent_id: str,
|
|
341
|
-
*,
|
|
342
|
-
run_ids: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
343
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
344
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
345
|
-
extra_headers: Headers | None = None,
|
|
346
|
-
extra_query: Query | None = None,
|
|
347
|
-
extra_body: Body | None = None,
|
|
348
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
349
|
-
) -> MessageCancelResponse:
|
|
350
|
-
"""Cancel runs associated with an agent.
|
|
351
|
-
|
|
352
|
-
If run_ids are passed in, cancel those in
|
|
353
|
-
particular.
|
|
354
|
-
|
|
355
|
-
Note to cancel active runs associated with an agent, redis is required.
|
|
356
|
-
|
|
357
|
-
Args:
|
|
358
|
-
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
359
|
-
|
|
360
|
-
run_ids: Optional list of run IDs to cancel
|
|
361
|
-
|
|
362
|
-
extra_headers: Send extra headers
|
|
363
|
-
|
|
364
|
-
extra_query: Add additional query parameters to the request
|
|
365
|
-
|
|
366
|
-
extra_body: Add additional JSON properties to the request
|
|
367
|
-
|
|
368
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
369
|
-
"""
|
|
370
|
-
if not agent_id:
|
|
371
|
-
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
372
|
-
return self._post(
|
|
373
|
-
f"/v1/agents/{agent_id}/messages/cancel",
|
|
374
|
-
body=maybe_transform({"run_ids": run_ids}, message_cancel_params.MessageCancelParams),
|
|
375
|
-
options=make_request_options(
|
|
376
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
377
|
-
),
|
|
378
|
-
cast_to=MessageCancelResponse,
|
|
379
|
-
)
|
|
380
|
-
|
|
381
381
|
def reset(
|
|
382
382
|
self,
|
|
383
383
|
agent_id: str,
|
|
@@ -607,32 +607,173 @@ class MessagesResource(SyncAPIResource):
|
|
|
607
607
|
Args:
|
|
608
608
|
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
609
609
|
|
|
610
|
-
messages: The messages to be sent to the agent.
|
|
610
|
+
messages: The messages to be sent to the agent.
|
|
611
|
+
|
|
612
|
+
assistant_message_tool_kwarg: The name of the message argument in the designated message tool. Still supported
|
|
613
|
+
for legacy agent types, but deprecated for letta_v1_agent onward.
|
|
614
|
+
|
|
615
|
+
assistant_message_tool_name: The name of the designated message tool. Still supported for legacy agent types,
|
|
616
|
+
but deprecated for letta_v1_agent onward.
|
|
617
|
+
|
|
618
|
+
background: Whether to process the request in the background.
|
|
619
|
+
|
|
620
|
+
enable_thinking: If set to True, enables reasoning before responses or tool calls from the agent.
|
|
621
|
+
|
|
622
|
+
include_pings: Whether to include periodic keepalive ping messages in the stream to prevent
|
|
623
|
+
connection timeouts.
|
|
624
|
+
|
|
625
|
+
include_return_message_types: Only return specified message types in the response. If `None` (default) returns
|
|
626
|
+
all messages.
|
|
627
|
+
|
|
628
|
+
max_steps: Maximum number of steps the agent should take to process the request.
|
|
629
|
+
|
|
630
|
+
stream_tokens: Flag to determine if individual tokens should be streamed, rather than streaming
|
|
631
|
+
per step.
|
|
632
|
+
|
|
633
|
+
use_assistant_message: Whether the server should parse specific tool call arguments (default
|
|
634
|
+
`send_message`) as `AssistantMessage` objects. Still supported for legacy agent
|
|
635
|
+
types, but deprecated for letta_v1_agent onward.
|
|
636
|
+
|
|
637
|
+
extra_headers: Send extra headers
|
|
638
|
+
|
|
639
|
+
extra_query: Add additional query parameters to the request
|
|
640
|
+
|
|
641
|
+
extra_body: Add additional JSON properties to the request
|
|
642
|
+
|
|
643
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
644
|
+
"""
|
|
645
|
+
if not agent_id:
|
|
646
|
+
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
647
|
+
return self._post(
|
|
648
|
+
f"/v1/agents/{agent_id}/messages/stream",
|
|
649
|
+
body=maybe_transform(
|
|
650
|
+
{
|
|
651
|
+
"messages": messages,
|
|
652
|
+
"assistant_message_tool_kwarg": assistant_message_tool_kwarg,
|
|
653
|
+
"assistant_message_tool_name": assistant_message_tool_name,
|
|
654
|
+
"background": background,
|
|
655
|
+
"enable_thinking": enable_thinking,
|
|
656
|
+
"include_pings": include_pings,
|
|
657
|
+
"include_return_message_types": include_return_message_types,
|
|
658
|
+
"max_steps": max_steps,
|
|
659
|
+
"stream_tokens": stream_tokens,
|
|
660
|
+
"use_assistant_message": use_assistant_message,
|
|
661
|
+
},
|
|
662
|
+
message_stream_params.MessageStreamParams,
|
|
663
|
+
),
|
|
664
|
+
options=make_request_options(
|
|
665
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
666
|
+
),
|
|
667
|
+
cast_to=object,
|
|
668
|
+
)
|
|
669
|
+
|
|
670
|
+
def summarize(
|
|
671
|
+
self,
|
|
672
|
+
agent_id: str,
|
|
673
|
+
*,
|
|
674
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
675
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
676
|
+
extra_headers: Headers | None = None,
|
|
677
|
+
extra_query: Query | None = None,
|
|
678
|
+
extra_body: Body | None = None,
|
|
679
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
680
|
+
) -> None:
|
|
681
|
+
"""
|
|
682
|
+
Summarize an agent's conversation history.
|
|
683
|
+
|
|
684
|
+
Args:
|
|
685
|
+
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
686
|
+
|
|
687
|
+
extra_headers: Send extra headers
|
|
688
|
+
|
|
689
|
+
extra_query: Add additional query parameters to the request
|
|
690
|
+
|
|
691
|
+
extra_body: Add additional JSON properties to the request
|
|
692
|
+
|
|
693
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
694
|
+
"""
|
|
695
|
+
if not agent_id:
|
|
696
|
+
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
697
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
698
|
+
return self._post(
|
|
699
|
+
f"/v1/agents/{agent_id}/summarize",
|
|
700
|
+
options=make_request_options(
|
|
701
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
702
|
+
),
|
|
703
|
+
cast_to=NoneType,
|
|
704
|
+
)
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
class AsyncMessagesResource(AsyncAPIResource):
|
|
708
|
+
@cached_property
|
|
709
|
+
def with_raw_response(self) -> AsyncMessagesResourceWithRawResponse:
|
|
710
|
+
"""
|
|
711
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
712
|
+
the raw response object instead of the parsed content.
|
|
713
|
+
|
|
714
|
+
For more information, see https://www.github.com/letta-ai/letta-python#accessing-raw-response-data-eg-headers
|
|
715
|
+
"""
|
|
716
|
+
return AsyncMessagesResourceWithRawResponse(self)
|
|
717
|
+
|
|
718
|
+
@cached_property
|
|
719
|
+
def with_streaming_response(self) -> AsyncMessagesResourceWithStreamingResponse:
|
|
720
|
+
"""
|
|
721
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
722
|
+
|
|
723
|
+
For more information, see https://www.github.com/letta-ai/letta-python#with_streaming_response
|
|
724
|
+
"""
|
|
725
|
+
return AsyncMessagesResourceWithStreamingResponse(self)
|
|
726
|
+
|
|
727
|
+
def list(
|
|
728
|
+
self,
|
|
729
|
+
agent_id: str,
|
|
730
|
+
*,
|
|
731
|
+
after: Optional[str] | Omit = omit,
|
|
732
|
+
assistant_message_tool_kwarg: str | Omit = omit,
|
|
733
|
+
assistant_message_tool_name: str | Omit = omit,
|
|
734
|
+
before: Optional[str] | Omit = omit,
|
|
735
|
+
group_id: Optional[str] | Omit = omit,
|
|
736
|
+
include_err: Optional[bool] | Omit = omit,
|
|
737
|
+
limit: Optional[int] | Omit = omit,
|
|
738
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
739
|
+
order_by: Literal["created_at"] | Omit = omit,
|
|
740
|
+
use_assistant_message: bool | Omit = omit,
|
|
741
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
742
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
743
|
+
extra_headers: Headers | None = None,
|
|
744
|
+
extra_query: Query | None = None,
|
|
745
|
+
extra_body: Body | None = None,
|
|
746
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
747
|
+
) -> AsyncPaginator[LettaMessageUnion, AsyncArrayPage[LettaMessageUnion]]:
|
|
748
|
+
"""
|
|
749
|
+
Retrieve message history for an agent.
|
|
750
|
+
|
|
751
|
+
Args:
|
|
752
|
+
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
753
|
+
|
|
754
|
+
after: Message ID cursor for pagination. Returns messages that come after this message
|
|
755
|
+
ID in the specified sort order
|
|
611
756
|
|
|
612
|
-
assistant_message_tool_kwarg: The name of the message argument
|
|
613
|
-
for legacy agent types, but deprecated for letta_v1_agent onward.
|
|
757
|
+
assistant_message_tool_kwarg: The name of the message argument.
|
|
614
758
|
|
|
615
|
-
assistant_message_tool_name: The name of the designated message tool.
|
|
616
|
-
but deprecated for letta_v1_agent onward.
|
|
759
|
+
assistant_message_tool_name: The name of the designated message tool.
|
|
617
760
|
|
|
618
|
-
|
|
761
|
+
before: Message ID cursor for pagination. Returns messages that come before this message
|
|
762
|
+
ID in the specified sort order
|
|
619
763
|
|
|
620
|
-
|
|
764
|
+
group_id: Group ID to filter messages by.
|
|
621
765
|
|
|
622
|
-
|
|
623
|
-
|
|
766
|
+
include_err: Whether to include error messages and error statuses. For debugging purposes
|
|
767
|
+
only.
|
|
624
768
|
|
|
625
|
-
|
|
626
|
-
all messages.
|
|
769
|
+
limit: Maximum number of messages to return
|
|
627
770
|
|
|
628
|
-
|
|
771
|
+
order: Sort order for messages by creation time. 'asc' for oldest first, 'desc' for
|
|
772
|
+
newest first
|
|
629
773
|
|
|
630
|
-
|
|
631
|
-
per step.
|
|
774
|
+
order_by: Field to sort by
|
|
632
775
|
|
|
633
|
-
use_assistant_message: Whether
|
|
634
|
-
`send_message`) as `AssistantMessage` objects. Still supported for legacy agent
|
|
635
|
-
types, but deprecated for letta_v1_agent onward.
|
|
776
|
+
use_assistant_message: Whether to use assistant messages
|
|
636
777
|
|
|
637
778
|
extra_headers: Send extra headers
|
|
638
779
|
|
|
@@ -644,46 +785,57 @@ class MessagesResource(SyncAPIResource):
|
|
|
644
785
|
"""
|
|
645
786
|
if not agent_id:
|
|
646
787
|
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
647
|
-
return self.
|
|
648
|
-
f"/v1/agents/{agent_id}/messages
|
|
649
|
-
|
|
650
|
-
{
|
|
651
|
-
"messages": messages,
|
|
652
|
-
"assistant_message_tool_kwarg": assistant_message_tool_kwarg,
|
|
653
|
-
"assistant_message_tool_name": assistant_message_tool_name,
|
|
654
|
-
"background": background,
|
|
655
|
-
"enable_thinking": enable_thinking,
|
|
656
|
-
"include_pings": include_pings,
|
|
657
|
-
"include_return_message_types": include_return_message_types,
|
|
658
|
-
"max_steps": max_steps,
|
|
659
|
-
"stream_tokens": stream_tokens,
|
|
660
|
-
"use_assistant_message": use_assistant_message,
|
|
661
|
-
},
|
|
662
|
-
message_stream_params.MessageStreamParams,
|
|
663
|
-
),
|
|
788
|
+
return self._get_api_list(
|
|
789
|
+
f"/v1/agents/{agent_id}/messages",
|
|
790
|
+
page=AsyncArrayPage[LettaMessageUnion],
|
|
664
791
|
options=make_request_options(
|
|
665
|
-
extra_headers=extra_headers,
|
|
792
|
+
extra_headers=extra_headers,
|
|
793
|
+
extra_query=extra_query,
|
|
794
|
+
extra_body=extra_body,
|
|
795
|
+
timeout=timeout,
|
|
796
|
+
query=maybe_transform(
|
|
797
|
+
{
|
|
798
|
+
"after": after,
|
|
799
|
+
"assistant_message_tool_kwarg": assistant_message_tool_kwarg,
|
|
800
|
+
"assistant_message_tool_name": assistant_message_tool_name,
|
|
801
|
+
"before": before,
|
|
802
|
+
"group_id": group_id,
|
|
803
|
+
"include_err": include_err,
|
|
804
|
+
"limit": limit,
|
|
805
|
+
"order": order,
|
|
806
|
+
"order_by": order_by,
|
|
807
|
+
"use_assistant_message": use_assistant_message,
|
|
808
|
+
},
|
|
809
|
+
message_list_params.MessageListParams,
|
|
810
|
+
),
|
|
666
811
|
),
|
|
667
|
-
|
|
812
|
+
model=cast(Any, LettaMessageUnion), # Union types cannot be passed in as arguments in the type system
|
|
668
813
|
)
|
|
669
814
|
|
|
670
|
-
def
|
|
815
|
+
async def cancel(
|
|
671
816
|
self,
|
|
672
817
|
agent_id: str,
|
|
673
818
|
*,
|
|
819
|
+
run_ids: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
674
820
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
675
821
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
676
822
|
extra_headers: Headers | None = None,
|
|
677
823
|
extra_query: Query | None = None,
|
|
678
824
|
extra_body: Body | None = None,
|
|
679
825
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
680
|
-
) ->
|
|
681
|
-
"""
|
|
682
|
-
|
|
826
|
+
) -> MessageCancelResponse:
|
|
827
|
+
"""Cancel runs associated with an agent.
|
|
828
|
+
|
|
829
|
+
If run_ids are passed in, cancel those in
|
|
830
|
+
particular.
|
|
831
|
+
|
|
832
|
+
Note to cancel active runs associated with an agent, redis is required.
|
|
683
833
|
|
|
684
834
|
Args:
|
|
685
835
|
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
686
836
|
|
|
837
|
+
run_ids: Optional list of run IDs to cancel
|
|
838
|
+
|
|
687
839
|
extra_headers: Send extra headers
|
|
688
840
|
|
|
689
841
|
extra_query: Add additional query parameters to the request
|
|
@@ -694,38 +846,17 @@ class MessagesResource(SyncAPIResource):
|
|
|
694
846
|
"""
|
|
695
847
|
if not agent_id:
|
|
696
848
|
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
849
|
+
return await self._post(
|
|
850
|
+
f"/v1/agents/{agent_id}/messages/cancel",
|
|
851
|
+
body=await async_maybe_transform({"run_ids": run_ids}, message_cancel_params.MessageCancelParams),
|
|
700
852
|
options=make_request_options(
|
|
701
853
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
702
854
|
),
|
|
703
|
-
cast_to=
|
|
855
|
+
cast_to=MessageCancelResponse,
|
|
704
856
|
)
|
|
705
857
|
|
|
706
|
-
|
|
707
|
-
class AsyncMessagesResource(AsyncAPIResource):
|
|
708
|
-
@cached_property
|
|
709
|
-
def with_raw_response(self) -> AsyncMessagesResourceWithRawResponse:
|
|
710
|
-
"""
|
|
711
|
-
This property can be used as a prefix for any HTTP method call to return
|
|
712
|
-
the raw response object instead of the parsed content.
|
|
713
|
-
|
|
714
|
-
For more information, see https://www.github.com/letta-ai/letta-python#accessing-raw-response-data-eg-headers
|
|
715
|
-
"""
|
|
716
|
-
return AsyncMessagesResourceWithRawResponse(self)
|
|
717
|
-
|
|
718
|
-
@cached_property
|
|
719
|
-
def with_streaming_response(self) -> AsyncMessagesResourceWithStreamingResponse:
|
|
720
|
-
"""
|
|
721
|
-
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
722
|
-
|
|
723
|
-
For more information, see https://www.github.com/letta-ai/letta-python#with_streaming_response
|
|
724
|
-
"""
|
|
725
|
-
return AsyncMessagesResourceWithStreamingResponse(self)
|
|
726
|
-
|
|
727
858
|
@overload
|
|
728
|
-
async def
|
|
859
|
+
async def modify(
|
|
729
860
|
self,
|
|
730
861
|
message_id: str,
|
|
731
862
|
*,
|
|
@@ -738,7 +869,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
738
869
|
extra_query: Query | None = None,
|
|
739
870
|
extra_body: Body | None = None,
|
|
740
871
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
741
|
-
) ->
|
|
872
|
+
) -> MessageModifyResponse:
|
|
742
873
|
"""
|
|
743
874
|
Update the details of a message associated with an agent.
|
|
744
875
|
|
|
@@ -761,7 +892,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
761
892
|
...
|
|
762
893
|
|
|
763
894
|
@overload
|
|
764
|
-
async def
|
|
895
|
+
async def modify(
|
|
765
896
|
self,
|
|
766
897
|
message_id: str,
|
|
767
898
|
*,
|
|
@@ -774,7 +905,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
774
905
|
extra_query: Query | None = None,
|
|
775
906
|
extra_body: Body | None = None,
|
|
776
907
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
777
|
-
) ->
|
|
908
|
+
) -> MessageModifyResponse:
|
|
778
909
|
"""
|
|
779
910
|
Update the details of a message associated with an agent.
|
|
780
911
|
|
|
@@ -797,7 +928,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
797
928
|
...
|
|
798
929
|
|
|
799
930
|
@overload
|
|
800
|
-
async def
|
|
931
|
+
async def modify(
|
|
801
932
|
self,
|
|
802
933
|
message_id: str,
|
|
803
934
|
*,
|
|
@@ -810,7 +941,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
810
941
|
extra_query: Query | None = None,
|
|
811
942
|
extra_body: Body | None = None,
|
|
812
943
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
813
|
-
) ->
|
|
944
|
+
) -> MessageModifyResponse:
|
|
814
945
|
"""
|
|
815
946
|
Update the details of a message associated with an agent.
|
|
816
947
|
|
|
@@ -830,7 +961,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
830
961
|
...
|
|
831
962
|
|
|
832
963
|
@overload
|
|
833
|
-
async def
|
|
964
|
+
async def modify(
|
|
834
965
|
self,
|
|
835
966
|
message_id: str,
|
|
836
967
|
*,
|
|
@@ -843,7 +974,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
843
974
|
extra_query: Query | None = None,
|
|
844
975
|
extra_body: Body | None = None,
|
|
845
976
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
846
|
-
) ->
|
|
977
|
+
) -> MessageModifyResponse:
|
|
847
978
|
"""
|
|
848
979
|
Update the details of a message associated with an agent.
|
|
849
980
|
|
|
@@ -866,7 +997,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
866
997
|
...
|
|
867
998
|
|
|
868
999
|
@required_args(["agent_id", "content"], ["agent_id", "reasoning"])
|
|
869
|
-
async def
|
|
1000
|
+
async def modify(
|
|
870
1001
|
self,
|
|
871
1002
|
message_id: str,
|
|
872
1003
|
*,
|
|
@@ -884,13 +1015,13 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
884
1015
|
extra_query: Query | None = None,
|
|
885
1016
|
extra_body: Body | None = None,
|
|
886
1017
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
887
|
-
) ->
|
|
1018
|
+
) -> MessageModifyResponse:
|
|
888
1019
|
if not agent_id:
|
|
889
1020
|
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
890
1021
|
if not message_id:
|
|
891
1022
|
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
892
1023
|
return cast(
|
|
893
|
-
|
|
1024
|
+
MessageModifyResponse,
|
|
894
1025
|
await self._patch(
|
|
895
1026
|
f"/v1/agents/{agent_id}/messages/{message_id}",
|
|
896
1027
|
body=await async_maybe_transform(
|
|
@@ -899,148 +1030,17 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
899
1030
|
"message_type": message_type,
|
|
900
1031
|
"reasoning": reasoning,
|
|
901
1032
|
},
|
|
902
|
-
|
|
1033
|
+
message_modify_params.MessageModifyParams,
|
|
903
1034
|
),
|
|
904
1035
|
options=make_request_options(
|
|
905
1036
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
906
1037
|
),
|
|
907
1038
|
cast_to=cast(
|
|
908
|
-
Any,
|
|
1039
|
+
Any, MessageModifyResponse
|
|
909
1040
|
), # Union types cannot be passed in as arguments in the type system
|
|
910
1041
|
),
|
|
911
1042
|
)
|
|
912
1043
|
|
|
913
|
-
def list(
|
|
914
|
-
self,
|
|
915
|
-
agent_id: str,
|
|
916
|
-
*,
|
|
917
|
-
after: Optional[str] | Omit = omit,
|
|
918
|
-
assistant_message_tool_kwarg: str | Omit = omit,
|
|
919
|
-
assistant_message_tool_name: str | Omit = omit,
|
|
920
|
-
before: Optional[str] | Omit = omit,
|
|
921
|
-
group_id: Optional[str] | Omit = omit,
|
|
922
|
-
include_err: Optional[bool] | Omit = omit,
|
|
923
|
-
limit: Optional[int] | Omit = omit,
|
|
924
|
-
order: Literal["asc", "desc"] | Omit = omit,
|
|
925
|
-
order_by: Literal["created_at"] | Omit = omit,
|
|
926
|
-
use_assistant_message: bool | Omit = omit,
|
|
927
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
928
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
929
|
-
extra_headers: Headers | None = None,
|
|
930
|
-
extra_query: Query | None = None,
|
|
931
|
-
extra_body: Body | None = None,
|
|
932
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
933
|
-
) -> AsyncPaginator[LettaMessageUnion, AsyncArrayPage[LettaMessageUnion]]:
|
|
934
|
-
"""
|
|
935
|
-
Retrieve message history for an agent.
|
|
936
|
-
|
|
937
|
-
Args:
|
|
938
|
-
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
939
|
-
|
|
940
|
-
after: Message ID cursor for pagination. Returns messages that come after this message
|
|
941
|
-
ID in the specified sort order
|
|
942
|
-
|
|
943
|
-
assistant_message_tool_kwarg: The name of the message argument.
|
|
944
|
-
|
|
945
|
-
assistant_message_tool_name: The name of the designated message tool.
|
|
946
|
-
|
|
947
|
-
before: Message ID cursor for pagination. Returns messages that come before this message
|
|
948
|
-
ID in the specified sort order
|
|
949
|
-
|
|
950
|
-
group_id: Group ID to filter messages by.
|
|
951
|
-
|
|
952
|
-
include_err: Whether to include error messages and error statuses. For debugging purposes
|
|
953
|
-
only.
|
|
954
|
-
|
|
955
|
-
limit: Maximum number of messages to return
|
|
956
|
-
|
|
957
|
-
order: Sort order for messages by creation time. 'asc' for oldest first, 'desc' for
|
|
958
|
-
newest first
|
|
959
|
-
|
|
960
|
-
order_by: Field to sort by
|
|
961
|
-
|
|
962
|
-
use_assistant_message: Whether to use assistant messages
|
|
963
|
-
|
|
964
|
-
extra_headers: Send extra headers
|
|
965
|
-
|
|
966
|
-
extra_query: Add additional query parameters to the request
|
|
967
|
-
|
|
968
|
-
extra_body: Add additional JSON properties to the request
|
|
969
|
-
|
|
970
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
971
|
-
"""
|
|
972
|
-
if not agent_id:
|
|
973
|
-
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
974
|
-
return self._get_api_list(
|
|
975
|
-
f"/v1/agents/{agent_id}/messages",
|
|
976
|
-
page=AsyncArrayPage[LettaMessageUnion],
|
|
977
|
-
options=make_request_options(
|
|
978
|
-
extra_headers=extra_headers,
|
|
979
|
-
extra_query=extra_query,
|
|
980
|
-
extra_body=extra_body,
|
|
981
|
-
timeout=timeout,
|
|
982
|
-
query=maybe_transform(
|
|
983
|
-
{
|
|
984
|
-
"after": after,
|
|
985
|
-
"assistant_message_tool_kwarg": assistant_message_tool_kwarg,
|
|
986
|
-
"assistant_message_tool_name": assistant_message_tool_name,
|
|
987
|
-
"before": before,
|
|
988
|
-
"group_id": group_id,
|
|
989
|
-
"include_err": include_err,
|
|
990
|
-
"limit": limit,
|
|
991
|
-
"order": order,
|
|
992
|
-
"order_by": order_by,
|
|
993
|
-
"use_assistant_message": use_assistant_message,
|
|
994
|
-
},
|
|
995
|
-
message_list_params.MessageListParams,
|
|
996
|
-
),
|
|
997
|
-
),
|
|
998
|
-
model=cast(Any, LettaMessageUnion), # Union types cannot be passed in as arguments in the type system
|
|
999
|
-
)
|
|
1000
|
-
|
|
1001
|
-
async def cancel(
|
|
1002
|
-
self,
|
|
1003
|
-
agent_id: str,
|
|
1004
|
-
*,
|
|
1005
|
-
run_ids: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
1006
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
1007
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
1008
|
-
extra_headers: Headers | None = None,
|
|
1009
|
-
extra_query: Query | None = None,
|
|
1010
|
-
extra_body: Body | None = None,
|
|
1011
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1012
|
-
) -> MessageCancelResponse:
|
|
1013
|
-
"""Cancel runs associated with an agent.
|
|
1014
|
-
|
|
1015
|
-
If run_ids are passed in, cancel those in
|
|
1016
|
-
particular.
|
|
1017
|
-
|
|
1018
|
-
Note to cancel active runs associated with an agent, redis is required.
|
|
1019
|
-
|
|
1020
|
-
Args:
|
|
1021
|
-
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
1022
|
-
|
|
1023
|
-
run_ids: Optional list of run IDs to cancel
|
|
1024
|
-
|
|
1025
|
-
extra_headers: Send extra headers
|
|
1026
|
-
|
|
1027
|
-
extra_query: Add additional query parameters to the request
|
|
1028
|
-
|
|
1029
|
-
extra_body: Add additional JSON properties to the request
|
|
1030
|
-
|
|
1031
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
1032
|
-
"""
|
|
1033
|
-
if not agent_id:
|
|
1034
|
-
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
1035
|
-
return await self._post(
|
|
1036
|
-
f"/v1/agents/{agent_id}/messages/cancel",
|
|
1037
|
-
body=await async_maybe_transform({"run_ids": run_ids}, message_cancel_params.MessageCancelParams),
|
|
1038
|
-
options=make_request_options(
|
|
1039
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1040
|
-
),
|
|
1041
|
-
cast_to=MessageCancelResponse,
|
|
1042
|
-
)
|
|
1043
|
-
|
|
1044
1044
|
async def reset(
|
|
1045
1045
|
self,
|
|
1046
1046
|
agent_id: str,
|
|
@@ -1371,15 +1371,15 @@ class MessagesResourceWithRawResponse:
|
|
|
1371
1371
|
def __init__(self, messages: MessagesResource) -> None:
|
|
1372
1372
|
self._messages = messages
|
|
1373
1373
|
|
|
1374
|
-
self.update = to_raw_response_wrapper(
|
|
1375
|
-
messages.update,
|
|
1376
|
-
)
|
|
1377
1374
|
self.list = to_raw_response_wrapper(
|
|
1378
1375
|
messages.list,
|
|
1379
1376
|
)
|
|
1380
1377
|
self.cancel = to_raw_response_wrapper(
|
|
1381
1378
|
messages.cancel,
|
|
1382
1379
|
)
|
|
1380
|
+
self.modify = to_raw_response_wrapper(
|
|
1381
|
+
messages.modify,
|
|
1382
|
+
)
|
|
1383
1383
|
self.reset = to_raw_response_wrapper(
|
|
1384
1384
|
messages.reset,
|
|
1385
1385
|
)
|
|
@@ -1401,15 +1401,15 @@ class AsyncMessagesResourceWithRawResponse:
|
|
|
1401
1401
|
def __init__(self, messages: AsyncMessagesResource) -> None:
|
|
1402
1402
|
self._messages = messages
|
|
1403
1403
|
|
|
1404
|
-
self.update = async_to_raw_response_wrapper(
|
|
1405
|
-
messages.update,
|
|
1406
|
-
)
|
|
1407
1404
|
self.list = async_to_raw_response_wrapper(
|
|
1408
1405
|
messages.list,
|
|
1409
1406
|
)
|
|
1410
1407
|
self.cancel = async_to_raw_response_wrapper(
|
|
1411
1408
|
messages.cancel,
|
|
1412
1409
|
)
|
|
1410
|
+
self.modify = async_to_raw_response_wrapper(
|
|
1411
|
+
messages.modify,
|
|
1412
|
+
)
|
|
1413
1413
|
self.reset = async_to_raw_response_wrapper(
|
|
1414
1414
|
messages.reset,
|
|
1415
1415
|
)
|
|
@@ -1431,15 +1431,15 @@ class MessagesResourceWithStreamingResponse:
|
|
|
1431
1431
|
def __init__(self, messages: MessagesResource) -> None:
|
|
1432
1432
|
self._messages = messages
|
|
1433
1433
|
|
|
1434
|
-
self.update = to_streamed_response_wrapper(
|
|
1435
|
-
messages.update,
|
|
1436
|
-
)
|
|
1437
1434
|
self.list = to_streamed_response_wrapper(
|
|
1438
1435
|
messages.list,
|
|
1439
1436
|
)
|
|
1440
1437
|
self.cancel = to_streamed_response_wrapper(
|
|
1441
1438
|
messages.cancel,
|
|
1442
1439
|
)
|
|
1440
|
+
self.modify = to_streamed_response_wrapper(
|
|
1441
|
+
messages.modify,
|
|
1442
|
+
)
|
|
1443
1443
|
self.reset = to_streamed_response_wrapper(
|
|
1444
1444
|
messages.reset,
|
|
1445
1445
|
)
|
|
@@ -1461,15 +1461,15 @@ class AsyncMessagesResourceWithStreamingResponse:
|
|
|
1461
1461
|
def __init__(self, messages: AsyncMessagesResource) -> None:
|
|
1462
1462
|
self._messages = messages
|
|
1463
1463
|
|
|
1464
|
-
self.update = async_to_streamed_response_wrapper(
|
|
1465
|
-
messages.update,
|
|
1466
|
-
)
|
|
1467
1464
|
self.list = async_to_streamed_response_wrapper(
|
|
1468
1465
|
messages.list,
|
|
1469
1466
|
)
|
|
1470
1467
|
self.cancel = async_to_streamed_response_wrapper(
|
|
1471
1468
|
messages.cancel,
|
|
1472
1469
|
)
|
|
1470
|
+
self.modify = async_to_streamed_response_wrapper(
|
|
1471
|
+
messages.modify,
|
|
1472
|
+
)
|
|
1473
1473
|
self.reset = async_to_streamed_response_wrapper(
|
|
1474
1474
|
messages.reset,
|
|
1475
1475
|
)
|