letta-client 1.0.0a9__py3-none-any.whl → 1.0.0a11__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/_client.py +5 -1
- letta_client/_streaming.py +40 -2
- letta_client/_version.py +1 -1
- letta_client/resources/agents/agents.py +396 -396
- letta_client/resources/agents/blocks.py +198 -190
- letta_client/resources/agents/files.py +10 -13
- letta_client/resources/agents/folders.py +10 -13
- letta_client/resources/agents/messages.py +380 -370
- letta_client/resources/agents/tools.py +10 -13
- letta_client/resources/archives.py +111 -113
- letta_client/resources/batches/batches.py +10 -12
- letta_client/resources/batches/messages.py +11 -14
- letta_client/resources/blocks/blocks.py +238 -222
- letta_client/resources/folders/agents.py +10 -13
- letta_client/resources/folders/files.py +9 -12
- letta_client/resources/folders/folders.py +143 -145
- 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 +151 -153
- letta_client/resources/runs/runs.py +11 -13
- letta_client/resources/tags.py +10 -13
- letta_client/resources/tools.py +802 -204
- letta_client/types/__init__.py +14 -7
- 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 +5 -3
- letta_client/types/agents/block.py +6 -3
- letta_client/types/agents/{block_update_params.py → block_modify_params.py} +8 -5
- letta_client/types/agents/file_list_response.py +14 -3
- letta_client/types/agents/folder_list_response.py +7 -3
- letta_client/types/agents/letta_streaming_response.py +70 -0
- 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/agents/tool_list_response.py +10 -0
- letta_client/types/archive_list_response.py +10 -0
- letta_client/types/{archive_update_params.py → archive_modify_params.py} +2 -2
- letta_client/types/batch_list_response.py +10 -0
- letta_client/types/batches/__init__.py +1 -0
- letta_client/types/batches/message_list_response.py +12 -0
- letta_client/types/block_create_params.py +6 -3
- letta_client/types/{block_update_params.py → block_modify_params.py} +8 -5
- letta_client/types/block_response.py +63 -0
- letta_client/types/create_block_param.py +6 -3
- letta_client/types/folder_list_response.py +10 -0
- letta_client/types/{folder_update_params.py → folder_modify_params.py} +2 -2
- letta_client/types/folders/agent_list_response.py +2 -1
- letta_client/types/folders/file_list_response.py +7 -4
- 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/identity_list_response.py +10 -0
- letta_client/types/{identity_update_params.py → identity_modify_params.py} +2 -2
- letta_client/types/run_list_response.py +10 -0
- letta_client/types/tag_list_response.py +2 -1
- letta_client/types/tool.py +106 -2
- letta_client/types/tool_list_response.py +10 -0
- letta_client/types/{tool_update_params.py → tool_modify_params.py} +2 -2
- {letta_client-1.0.0a9.dist-info → letta_client-1.0.0a11.dist-info}/METADATA +1 -1
- {letta_client-1.0.0a9.dist-info → letta_client-1.0.0a11.dist-info}/RECORD +63 -53
- {letta_client-1.0.0a9.dist-info → letta_client-1.0.0a11.dist-info}/WHEEL +0 -0
- {letta_client-1.0.0a9.dist-info → letta_client-1.0.0a11.dist-info}/licenses/LICENSE +0 -0
|
@@ -17,6 +17,7 @@ from ..._response import (
|
|
|
17
17
|
async_to_raw_response_wrapper,
|
|
18
18
|
async_to_streamed_response_wrapper,
|
|
19
19
|
)
|
|
20
|
+
from ..._streaming import Stream, AsyncStream
|
|
20
21
|
from ...pagination import SyncArrayPage, AsyncArrayPage
|
|
21
22
|
from ..._base_client import AsyncPaginator, make_request_options
|
|
22
23
|
from ...types.agents import (
|
|
@@ -24,8 +25,8 @@ from ...types.agents import (
|
|
|
24
25
|
message_send_params,
|
|
25
26
|
message_reset_params,
|
|
26
27
|
message_cancel_params,
|
|
28
|
+
message_modify_params,
|
|
27
29
|
message_stream_params,
|
|
28
|
-
message_update_params,
|
|
29
30
|
message_send_async_params,
|
|
30
31
|
)
|
|
31
32
|
from ...types.agents.run import Run
|
|
@@ -34,7 +35,8 @@ from ...types.agents.message_type import MessageType
|
|
|
34
35
|
from ...types.agents.letta_response import LettaResponse
|
|
35
36
|
from ...types.agents.letta_message_union import LettaMessageUnion
|
|
36
37
|
from ...types.agents.message_cancel_response import MessageCancelResponse
|
|
37
|
-
from ...types.agents.
|
|
38
|
+
from ...types.agents.message_modify_response import MessageModifyResponse
|
|
39
|
+
from ...types.agents.letta_streaming_response import LettaStreamingResponse
|
|
38
40
|
from ...types.agents.letta_user_message_content_union_param import LettaUserMessageContentUnionParam
|
|
39
41
|
from ...types.agents.letta_assistant_message_content_union_param import LettaAssistantMessageContentUnionParam
|
|
40
42
|
|
|
@@ -61,8 +63,139 @@ class MessagesResource(SyncAPIResource):
|
|
|
61
63
|
"""
|
|
62
64
|
return MessagesResourceWithStreamingResponse(self)
|
|
63
65
|
|
|
66
|
+
def list(
|
|
67
|
+
self,
|
|
68
|
+
agent_id: str,
|
|
69
|
+
*,
|
|
70
|
+
after: Optional[str] | Omit = omit,
|
|
71
|
+
assistant_message_tool_kwarg: str | Omit = omit,
|
|
72
|
+
assistant_message_tool_name: str | Omit = omit,
|
|
73
|
+
before: Optional[str] | Omit = omit,
|
|
74
|
+
group_id: Optional[str] | Omit = omit,
|
|
75
|
+
include_err: Optional[bool] | Omit = omit,
|
|
76
|
+
limit: Optional[int] | Omit = omit,
|
|
77
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
78
|
+
order_by: Literal["created_at"] | Omit = omit,
|
|
79
|
+
use_assistant_message: bool | Omit = omit,
|
|
80
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
81
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
82
|
+
extra_headers: Headers | None = None,
|
|
83
|
+
extra_query: Query | None = None,
|
|
84
|
+
extra_body: Body | None = None,
|
|
85
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
86
|
+
) -> SyncArrayPage[LettaMessageUnion]:
|
|
87
|
+
"""
|
|
88
|
+
Retrieve message history for an agent.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
92
|
+
|
|
93
|
+
after: Message ID cursor for pagination. Returns messages that come after this message
|
|
94
|
+
ID in the specified sort order
|
|
95
|
+
|
|
96
|
+
assistant_message_tool_kwarg: The name of the message argument.
|
|
97
|
+
|
|
98
|
+
assistant_message_tool_name: The name of the designated message tool.
|
|
99
|
+
|
|
100
|
+
before: Message ID cursor for pagination. Returns messages that come before this message
|
|
101
|
+
ID in the specified sort order
|
|
102
|
+
|
|
103
|
+
group_id: Group ID to filter messages by.
|
|
104
|
+
|
|
105
|
+
include_err: Whether to include error messages and error statuses. For debugging purposes
|
|
106
|
+
only.
|
|
107
|
+
|
|
108
|
+
limit: Maximum number of messages to return
|
|
109
|
+
|
|
110
|
+
order: Sort order for messages by creation time. 'asc' for oldest first, 'desc' for
|
|
111
|
+
newest first
|
|
112
|
+
|
|
113
|
+
order_by: Field to sort by
|
|
114
|
+
|
|
115
|
+
use_assistant_message: Whether to use assistant messages
|
|
116
|
+
|
|
117
|
+
extra_headers: Send extra headers
|
|
118
|
+
|
|
119
|
+
extra_query: Add additional query parameters to the request
|
|
120
|
+
|
|
121
|
+
extra_body: Add additional JSON properties to the request
|
|
122
|
+
|
|
123
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
124
|
+
"""
|
|
125
|
+
if not agent_id:
|
|
126
|
+
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
127
|
+
return self._get_api_list(
|
|
128
|
+
f"/v1/agents/{agent_id}/messages",
|
|
129
|
+
page=SyncArrayPage[LettaMessageUnion],
|
|
130
|
+
options=make_request_options(
|
|
131
|
+
extra_headers=extra_headers,
|
|
132
|
+
extra_query=extra_query,
|
|
133
|
+
extra_body=extra_body,
|
|
134
|
+
timeout=timeout,
|
|
135
|
+
query=maybe_transform(
|
|
136
|
+
{
|
|
137
|
+
"after": after,
|
|
138
|
+
"assistant_message_tool_kwarg": assistant_message_tool_kwarg,
|
|
139
|
+
"assistant_message_tool_name": assistant_message_tool_name,
|
|
140
|
+
"before": before,
|
|
141
|
+
"group_id": group_id,
|
|
142
|
+
"include_err": include_err,
|
|
143
|
+
"limit": limit,
|
|
144
|
+
"order": order,
|
|
145
|
+
"order_by": order_by,
|
|
146
|
+
"use_assistant_message": use_assistant_message,
|
|
147
|
+
},
|
|
148
|
+
message_list_params.MessageListParams,
|
|
149
|
+
),
|
|
150
|
+
),
|
|
151
|
+
model=cast(Any, LettaMessageUnion), # Union types cannot be passed in as arguments in the type system
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
def cancel(
|
|
155
|
+
self,
|
|
156
|
+
agent_id: str,
|
|
157
|
+
*,
|
|
158
|
+
run_ids: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
159
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
160
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
161
|
+
extra_headers: Headers | None = None,
|
|
162
|
+
extra_query: Query | None = None,
|
|
163
|
+
extra_body: Body | None = None,
|
|
164
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
165
|
+
) -> MessageCancelResponse:
|
|
166
|
+
"""Cancel runs associated with an agent.
|
|
167
|
+
|
|
168
|
+
If run_ids are passed in, cancel those in
|
|
169
|
+
particular.
|
|
170
|
+
|
|
171
|
+
Note to cancel active runs associated with an agent, redis is required.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
175
|
+
|
|
176
|
+
run_ids: Optional list of run IDs to cancel
|
|
177
|
+
|
|
178
|
+
extra_headers: Send extra headers
|
|
179
|
+
|
|
180
|
+
extra_query: Add additional query parameters to the request
|
|
181
|
+
|
|
182
|
+
extra_body: Add additional JSON properties to the request
|
|
183
|
+
|
|
184
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
185
|
+
"""
|
|
186
|
+
if not agent_id:
|
|
187
|
+
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
188
|
+
return self._post(
|
|
189
|
+
f"/v1/agents/{agent_id}/messages/cancel",
|
|
190
|
+
body=maybe_transform({"run_ids": run_ids}, message_cancel_params.MessageCancelParams),
|
|
191
|
+
options=make_request_options(
|
|
192
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
193
|
+
),
|
|
194
|
+
cast_to=MessageCancelResponse,
|
|
195
|
+
)
|
|
196
|
+
|
|
64
197
|
@overload
|
|
65
|
-
def
|
|
198
|
+
def modify(
|
|
66
199
|
self,
|
|
67
200
|
message_id: str,
|
|
68
201
|
*,
|
|
@@ -75,7 +208,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
75
208
|
extra_query: Query | None = None,
|
|
76
209
|
extra_body: Body | None = None,
|
|
77
210
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
78
|
-
) ->
|
|
211
|
+
) -> MessageModifyResponse:
|
|
79
212
|
"""
|
|
80
213
|
Update the details of a message associated with an agent.
|
|
81
214
|
|
|
@@ -98,7 +231,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
98
231
|
...
|
|
99
232
|
|
|
100
233
|
@overload
|
|
101
|
-
def
|
|
234
|
+
def modify(
|
|
102
235
|
self,
|
|
103
236
|
message_id: str,
|
|
104
237
|
*,
|
|
@@ -111,7 +244,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
111
244
|
extra_query: Query | None = None,
|
|
112
245
|
extra_body: Body | None = None,
|
|
113
246
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
114
|
-
) ->
|
|
247
|
+
) -> MessageModifyResponse:
|
|
115
248
|
"""
|
|
116
249
|
Update the details of a message associated with an agent.
|
|
117
250
|
|
|
@@ -134,7 +267,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
134
267
|
...
|
|
135
268
|
|
|
136
269
|
@overload
|
|
137
|
-
def
|
|
270
|
+
def modify(
|
|
138
271
|
self,
|
|
139
272
|
message_id: str,
|
|
140
273
|
*,
|
|
@@ -147,7 +280,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
147
280
|
extra_query: Query | None = None,
|
|
148
281
|
extra_body: Body | None = None,
|
|
149
282
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
150
|
-
) ->
|
|
283
|
+
) -> MessageModifyResponse:
|
|
151
284
|
"""
|
|
152
285
|
Update the details of a message associated with an agent.
|
|
153
286
|
|
|
@@ -167,7 +300,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
167
300
|
...
|
|
168
301
|
|
|
169
302
|
@overload
|
|
170
|
-
def
|
|
303
|
+
def modify(
|
|
171
304
|
self,
|
|
172
305
|
message_id: str,
|
|
173
306
|
*,
|
|
@@ -180,7 +313,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
180
313
|
extra_query: Query | None = None,
|
|
181
314
|
extra_body: Body | None = None,
|
|
182
315
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
183
|
-
) ->
|
|
316
|
+
) -> MessageModifyResponse:
|
|
184
317
|
"""
|
|
185
318
|
Update the details of a message associated with an agent.
|
|
186
319
|
|
|
@@ -203,7 +336,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
203
336
|
...
|
|
204
337
|
|
|
205
338
|
@required_args(["agent_id", "content"], ["agent_id", "reasoning"])
|
|
206
|
-
def
|
|
339
|
+
def modify(
|
|
207
340
|
self,
|
|
208
341
|
message_id: str,
|
|
209
342
|
*,
|
|
@@ -221,13 +354,13 @@ class MessagesResource(SyncAPIResource):
|
|
|
221
354
|
extra_query: Query | None = None,
|
|
222
355
|
extra_body: Body | None = None,
|
|
223
356
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
224
|
-
) ->
|
|
357
|
+
) -> MessageModifyResponse:
|
|
225
358
|
if not agent_id:
|
|
226
359
|
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
227
360
|
if not message_id:
|
|
228
361
|
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
229
362
|
return cast(
|
|
230
|
-
|
|
363
|
+
MessageModifyResponse,
|
|
231
364
|
self._patch(
|
|
232
365
|
f"/v1/agents/{agent_id}/messages/{message_id}",
|
|
233
366
|
body=maybe_transform(
|
|
@@ -236,148 +369,17 @@ class MessagesResource(SyncAPIResource):
|
|
|
236
369
|
"message_type": message_type,
|
|
237
370
|
"reasoning": reasoning,
|
|
238
371
|
},
|
|
239
|
-
|
|
372
|
+
message_modify_params.MessageModifyParams,
|
|
240
373
|
),
|
|
241
374
|
options=make_request_options(
|
|
242
375
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
243
376
|
),
|
|
244
377
|
cast_to=cast(
|
|
245
|
-
Any,
|
|
378
|
+
Any, MessageModifyResponse
|
|
246
379
|
), # Union types cannot be passed in as arguments in the type system
|
|
247
380
|
),
|
|
248
381
|
)
|
|
249
382
|
|
|
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
383
|
def reset(
|
|
382
384
|
self,
|
|
383
385
|
agent_id: str,
|
|
@@ -597,7 +599,7 @@ class MessagesResource(SyncAPIResource):
|
|
|
597
599
|
extra_query: Query | None = None,
|
|
598
600
|
extra_body: Body | None = None,
|
|
599
601
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
600
|
-
) ->
|
|
602
|
+
) -> Stream[LettaStreamingResponse]:
|
|
601
603
|
"""Process a user message and return the agent's response.
|
|
602
604
|
|
|
603
605
|
This endpoint accepts a
|
|
@@ -607,32 +609,177 @@ class MessagesResource(SyncAPIResource):
|
|
|
607
609
|
Args:
|
|
608
610
|
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
609
611
|
|
|
610
|
-
messages: The messages to be sent to the agent.
|
|
612
|
+
messages: The messages to be sent to the agent.
|
|
613
|
+
|
|
614
|
+
assistant_message_tool_kwarg: The name of the message argument in the designated message tool. Still supported
|
|
615
|
+
for legacy agent types, but deprecated for letta_v1_agent onward.
|
|
616
|
+
|
|
617
|
+
assistant_message_tool_name: The name of the designated message tool. Still supported for legacy agent types,
|
|
618
|
+
but deprecated for letta_v1_agent onward.
|
|
619
|
+
|
|
620
|
+
background: Whether to process the request in the background.
|
|
621
|
+
|
|
622
|
+
enable_thinking: If set to True, enables reasoning before responses or tool calls from the agent.
|
|
623
|
+
|
|
624
|
+
include_pings: Whether to include periodic keepalive ping messages in the stream to prevent
|
|
625
|
+
connection timeouts.
|
|
626
|
+
|
|
627
|
+
include_return_message_types: Only return specified message types in the response. If `None` (default) returns
|
|
628
|
+
all messages.
|
|
629
|
+
|
|
630
|
+
max_steps: Maximum number of steps the agent should take to process the request.
|
|
631
|
+
|
|
632
|
+
stream_tokens: Flag to determine if individual tokens should be streamed, rather than streaming
|
|
633
|
+
per step.
|
|
634
|
+
|
|
635
|
+
use_assistant_message: Whether the server should parse specific tool call arguments (default
|
|
636
|
+
`send_message`) as `AssistantMessage` objects. Still supported for legacy agent
|
|
637
|
+
types, but deprecated for letta_v1_agent onward.
|
|
638
|
+
|
|
639
|
+
extra_headers: Send extra headers
|
|
640
|
+
|
|
641
|
+
extra_query: Add additional query parameters to the request
|
|
642
|
+
|
|
643
|
+
extra_body: Add additional JSON properties to the request
|
|
644
|
+
|
|
645
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
646
|
+
"""
|
|
647
|
+
if not agent_id:
|
|
648
|
+
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
649
|
+
return self._post(
|
|
650
|
+
f"/v1/agents/{agent_id}/messages/stream",
|
|
651
|
+
body=maybe_transform(
|
|
652
|
+
{
|
|
653
|
+
"messages": messages,
|
|
654
|
+
"assistant_message_tool_kwarg": assistant_message_tool_kwarg,
|
|
655
|
+
"assistant_message_tool_name": assistant_message_tool_name,
|
|
656
|
+
"background": background,
|
|
657
|
+
"enable_thinking": enable_thinking,
|
|
658
|
+
"include_pings": include_pings,
|
|
659
|
+
"include_return_message_types": include_return_message_types,
|
|
660
|
+
"max_steps": max_steps,
|
|
661
|
+
"stream_tokens": stream_tokens,
|
|
662
|
+
"use_assistant_message": use_assistant_message,
|
|
663
|
+
},
|
|
664
|
+
message_stream_params.MessageStreamParams,
|
|
665
|
+
),
|
|
666
|
+
options=make_request_options(
|
|
667
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
668
|
+
),
|
|
669
|
+
cast_to=cast(
|
|
670
|
+
Any, LettaStreamingResponse
|
|
671
|
+
), # Union types cannot be passed in as arguments in the type system
|
|
672
|
+
stream=True,
|
|
673
|
+
stream_cls=Stream[LettaStreamingResponse],
|
|
674
|
+
)
|
|
675
|
+
|
|
676
|
+
def summarize(
|
|
677
|
+
self,
|
|
678
|
+
agent_id: str,
|
|
679
|
+
*,
|
|
680
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
681
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
682
|
+
extra_headers: Headers | None = None,
|
|
683
|
+
extra_query: Query | None = None,
|
|
684
|
+
extra_body: Body | None = None,
|
|
685
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
686
|
+
) -> None:
|
|
687
|
+
"""
|
|
688
|
+
Summarize an agent's conversation history.
|
|
689
|
+
|
|
690
|
+
Args:
|
|
691
|
+
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
692
|
+
|
|
693
|
+
extra_headers: Send extra headers
|
|
694
|
+
|
|
695
|
+
extra_query: Add additional query parameters to the request
|
|
696
|
+
|
|
697
|
+
extra_body: Add additional JSON properties to the request
|
|
698
|
+
|
|
699
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
700
|
+
"""
|
|
701
|
+
if not agent_id:
|
|
702
|
+
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
703
|
+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
|
|
704
|
+
return self._post(
|
|
705
|
+
f"/v1/agents/{agent_id}/summarize",
|
|
706
|
+
options=make_request_options(
|
|
707
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
708
|
+
),
|
|
709
|
+
cast_to=NoneType,
|
|
710
|
+
)
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
class AsyncMessagesResource(AsyncAPIResource):
|
|
714
|
+
@cached_property
|
|
715
|
+
def with_raw_response(self) -> AsyncMessagesResourceWithRawResponse:
|
|
716
|
+
"""
|
|
717
|
+
This property can be used as a prefix for any HTTP method call to return
|
|
718
|
+
the raw response object instead of the parsed content.
|
|
719
|
+
|
|
720
|
+
For more information, see https://www.github.com/letta-ai/letta-python#accessing-raw-response-data-eg-headers
|
|
721
|
+
"""
|
|
722
|
+
return AsyncMessagesResourceWithRawResponse(self)
|
|
723
|
+
|
|
724
|
+
@cached_property
|
|
725
|
+
def with_streaming_response(self) -> AsyncMessagesResourceWithStreamingResponse:
|
|
726
|
+
"""
|
|
727
|
+
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
728
|
+
|
|
729
|
+
For more information, see https://www.github.com/letta-ai/letta-python#with_streaming_response
|
|
730
|
+
"""
|
|
731
|
+
return AsyncMessagesResourceWithStreamingResponse(self)
|
|
732
|
+
|
|
733
|
+
def list(
|
|
734
|
+
self,
|
|
735
|
+
agent_id: str,
|
|
736
|
+
*,
|
|
737
|
+
after: Optional[str] | Omit = omit,
|
|
738
|
+
assistant_message_tool_kwarg: str | Omit = omit,
|
|
739
|
+
assistant_message_tool_name: str | Omit = omit,
|
|
740
|
+
before: Optional[str] | Omit = omit,
|
|
741
|
+
group_id: Optional[str] | Omit = omit,
|
|
742
|
+
include_err: Optional[bool] | Omit = omit,
|
|
743
|
+
limit: Optional[int] | Omit = omit,
|
|
744
|
+
order: Literal["asc", "desc"] | Omit = omit,
|
|
745
|
+
order_by: Literal["created_at"] | Omit = omit,
|
|
746
|
+
use_assistant_message: bool | Omit = omit,
|
|
747
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
748
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
749
|
+
extra_headers: Headers | None = None,
|
|
750
|
+
extra_query: Query | None = None,
|
|
751
|
+
extra_body: Body | None = None,
|
|
752
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
753
|
+
) -> AsyncPaginator[LettaMessageUnion, AsyncArrayPage[LettaMessageUnion]]:
|
|
754
|
+
"""
|
|
755
|
+
Retrieve message history for an agent.
|
|
756
|
+
|
|
757
|
+
Args:
|
|
758
|
+
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
759
|
+
|
|
760
|
+
after: Message ID cursor for pagination. Returns messages that come after this message
|
|
761
|
+
ID in the specified sort order
|
|
611
762
|
|
|
612
|
-
assistant_message_tool_kwarg: The name of the message argument
|
|
613
|
-
for legacy agent types, but deprecated for letta_v1_agent onward.
|
|
763
|
+
assistant_message_tool_kwarg: The name of the message argument.
|
|
614
764
|
|
|
615
|
-
assistant_message_tool_name: The name of the designated message tool.
|
|
616
|
-
but deprecated for letta_v1_agent onward.
|
|
765
|
+
assistant_message_tool_name: The name of the designated message tool.
|
|
617
766
|
|
|
618
|
-
|
|
767
|
+
before: Message ID cursor for pagination. Returns messages that come before this message
|
|
768
|
+
ID in the specified sort order
|
|
619
769
|
|
|
620
|
-
|
|
770
|
+
group_id: Group ID to filter messages by.
|
|
621
771
|
|
|
622
|
-
|
|
623
|
-
|
|
772
|
+
include_err: Whether to include error messages and error statuses. For debugging purposes
|
|
773
|
+
only.
|
|
624
774
|
|
|
625
|
-
|
|
626
|
-
all messages.
|
|
775
|
+
limit: Maximum number of messages to return
|
|
627
776
|
|
|
628
|
-
|
|
777
|
+
order: Sort order for messages by creation time. 'asc' for oldest first, 'desc' for
|
|
778
|
+
newest first
|
|
629
779
|
|
|
630
|
-
|
|
631
|
-
per step.
|
|
780
|
+
order_by: Field to sort by
|
|
632
781
|
|
|
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.
|
|
782
|
+
use_assistant_message: Whether to use assistant messages
|
|
636
783
|
|
|
637
784
|
extra_headers: Send extra headers
|
|
638
785
|
|
|
@@ -644,46 +791,57 @@ class MessagesResource(SyncAPIResource):
|
|
|
644
791
|
"""
|
|
645
792
|
if not agent_id:
|
|
646
793
|
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
|
-
),
|
|
794
|
+
return self._get_api_list(
|
|
795
|
+
f"/v1/agents/{agent_id}/messages",
|
|
796
|
+
page=AsyncArrayPage[LettaMessageUnion],
|
|
664
797
|
options=make_request_options(
|
|
665
|
-
extra_headers=extra_headers,
|
|
798
|
+
extra_headers=extra_headers,
|
|
799
|
+
extra_query=extra_query,
|
|
800
|
+
extra_body=extra_body,
|
|
801
|
+
timeout=timeout,
|
|
802
|
+
query=maybe_transform(
|
|
803
|
+
{
|
|
804
|
+
"after": after,
|
|
805
|
+
"assistant_message_tool_kwarg": assistant_message_tool_kwarg,
|
|
806
|
+
"assistant_message_tool_name": assistant_message_tool_name,
|
|
807
|
+
"before": before,
|
|
808
|
+
"group_id": group_id,
|
|
809
|
+
"include_err": include_err,
|
|
810
|
+
"limit": limit,
|
|
811
|
+
"order": order,
|
|
812
|
+
"order_by": order_by,
|
|
813
|
+
"use_assistant_message": use_assistant_message,
|
|
814
|
+
},
|
|
815
|
+
message_list_params.MessageListParams,
|
|
816
|
+
),
|
|
666
817
|
),
|
|
667
|
-
|
|
818
|
+
model=cast(Any, LettaMessageUnion), # Union types cannot be passed in as arguments in the type system
|
|
668
819
|
)
|
|
669
820
|
|
|
670
|
-
def
|
|
821
|
+
async def cancel(
|
|
671
822
|
self,
|
|
672
823
|
agent_id: str,
|
|
673
824
|
*,
|
|
825
|
+
run_ids: Optional[SequenceNotStr[str]] | Omit = omit,
|
|
674
826
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
675
827
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
676
828
|
extra_headers: Headers | None = None,
|
|
677
829
|
extra_query: Query | None = None,
|
|
678
830
|
extra_body: Body | None = None,
|
|
679
831
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
680
|
-
) ->
|
|
681
|
-
"""
|
|
682
|
-
|
|
832
|
+
) -> MessageCancelResponse:
|
|
833
|
+
"""Cancel runs associated with an agent.
|
|
834
|
+
|
|
835
|
+
If run_ids are passed in, cancel those in
|
|
836
|
+
particular.
|
|
837
|
+
|
|
838
|
+
Note to cancel active runs associated with an agent, redis is required.
|
|
683
839
|
|
|
684
840
|
Args:
|
|
685
841
|
agent_id: The ID of the agent in the format 'agent-<uuid4>'
|
|
686
842
|
|
|
843
|
+
run_ids: Optional list of run IDs to cancel
|
|
844
|
+
|
|
687
845
|
extra_headers: Send extra headers
|
|
688
846
|
|
|
689
847
|
extra_query: Add additional query parameters to the request
|
|
@@ -694,38 +852,17 @@ class MessagesResource(SyncAPIResource):
|
|
|
694
852
|
"""
|
|
695
853
|
if not agent_id:
|
|
696
854
|
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
855
|
+
return await self._post(
|
|
856
|
+
f"/v1/agents/{agent_id}/messages/cancel",
|
|
857
|
+
body=await async_maybe_transform({"run_ids": run_ids}, message_cancel_params.MessageCancelParams),
|
|
700
858
|
options=make_request_options(
|
|
701
859
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
702
860
|
),
|
|
703
|
-
cast_to=
|
|
861
|
+
cast_to=MessageCancelResponse,
|
|
704
862
|
)
|
|
705
863
|
|
|
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
864
|
@overload
|
|
728
|
-
async def
|
|
865
|
+
async def modify(
|
|
729
866
|
self,
|
|
730
867
|
message_id: str,
|
|
731
868
|
*,
|
|
@@ -738,7 +875,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
738
875
|
extra_query: Query | None = None,
|
|
739
876
|
extra_body: Body | None = None,
|
|
740
877
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
741
|
-
) ->
|
|
878
|
+
) -> MessageModifyResponse:
|
|
742
879
|
"""
|
|
743
880
|
Update the details of a message associated with an agent.
|
|
744
881
|
|
|
@@ -761,7 +898,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
761
898
|
...
|
|
762
899
|
|
|
763
900
|
@overload
|
|
764
|
-
async def
|
|
901
|
+
async def modify(
|
|
765
902
|
self,
|
|
766
903
|
message_id: str,
|
|
767
904
|
*,
|
|
@@ -774,7 +911,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
774
911
|
extra_query: Query | None = None,
|
|
775
912
|
extra_body: Body | None = None,
|
|
776
913
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
777
|
-
) ->
|
|
914
|
+
) -> MessageModifyResponse:
|
|
778
915
|
"""
|
|
779
916
|
Update the details of a message associated with an agent.
|
|
780
917
|
|
|
@@ -797,7 +934,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
797
934
|
...
|
|
798
935
|
|
|
799
936
|
@overload
|
|
800
|
-
async def
|
|
937
|
+
async def modify(
|
|
801
938
|
self,
|
|
802
939
|
message_id: str,
|
|
803
940
|
*,
|
|
@@ -810,7 +947,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
810
947
|
extra_query: Query | None = None,
|
|
811
948
|
extra_body: Body | None = None,
|
|
812
949
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
813
|
-
) ->
|
|
950
|
+
) -> MessageModifyResponse:
|
|
814
951
|
"""
|
|
815
952
|
Update the details of a message associated with an agent.
|
|
816
953
|
|
|
@@ -830,7 +967,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
830
967
|
...
|
|
831
968
|
|
|
832
969
|
@overload
|
|
833
|
-
async def
|
|
970
|
+
async def modify(
|
|
834
971
|
self,
|
|
835
972
|
message_id: str,
|
|
836
973
|
*,
|
|
@@ -843,7 +980,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
843
980
|
extra_query: Query | None = None,
|
|
844
981
|
extra_body: Body | None = None,
|
|
845
982
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
846
|
-
) ->
|
|
983
|
+
) -> MessageModifyResponse:
|
|
847
984
|
"""
|
|
848
985
|
Update the details of a message associated with an agent.
|
|
849
986
|
|
|
@@ -866,7 +1003,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
866
1003
|
...
|
|
867
1004
|
|
|
868
1005
|
@required_args(["agent_id", "content"], ["agent_id", "reasoning"])
|
|
869
|
-
async def
|
|
1006
|
+
async def modify(
|
|
870
1007
|
self,
|
|
871
1008
|
message_id: str,
|
|
872
1009
|
*,
|
|
@@ -884,13 +1021,13 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
884
1021
|
extra_query: Query | None = None,
|
|
885
1022
|
extra_body: Body | None = None,
|
|
886
1023
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
887
|
-
) ->
|
|
1024
|
+
) -> MessageModifyResponse:
|
|
888
1025
|
if not agent_id:
|
|
889
1026
|
raise ValueError(f"Expected a non-empty value for `agent_id` but received {agent_id!r}")
|
|
890
1027
|
if not message_id:
|
|
891
1028
|
raise ValueError(f"Expected a non-empty value for `message_id` but received {message_id!r}")
|
|
892
1029
|
return cast(
|
|
893
|
-
|
|
1030
|
+
MessageModifyResponse,
|
|
894
1031
|
await self._patch(
|
|
895
1032
|
f"/v1/agents/{agent_id}/messages/{message_id}",
|
|
896
1033
|
body=await async_maybe_transform(
|
|
@@ -899,148 +1036,17 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
899
1036
|
"message_type": message_type,
|
|
900
1037
|
"reasoning": reasoning,
|
|
901
1038
|
},
|
|
902
|
-
|
|
1039
|
+
message_modify_params.MessageModifyParams,
|
|
903
1040
|
),
|
|
904
1041
|
options=make_request_options(
|
|
905
1042
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
906
1043
|
),
|
|
907
1044
|
cast_to=cast(
|
|
908
|
-
Any,
|
|
1045
|
+
Any, MessageModifyResponse
|
|
909
1046
|
), # Union types cannot be passed in as arguments in the type system
|
|
910
1047
|
),
|
|
911
1048
|
)
|
|
912
1049
|
|
|
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
1050
|
async def reset(
|
|
1045
1051
|
self,
|
|
1046
1052
|
agent_id: str,
|
|
@@ -1260,7 +1266,7 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
1260
1266
|
extra_query: Query | None = None,
|
|
1261
1267
|
extra_body: Body | None = None,
|
|
1262
1268
|
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
1263
|
-
) ->
|
|
1269
|
+
) -> AsyncStream[LettaStreamingResponse]:
|
|
1264
1270
|
"""Process a user message and return the agent's response.
|
|
1265
1271
|
|
|
1266
1272
|
This endpoint accepts a
|
|
@@ -1327,7 +1333,11 @@ class AsyncMessagesResource(AsyncAPIResource):
|
|
|
1327
1333
|
options=make_request_options(
|
|
1328
1334
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
1329
1335
|
),
|
|
1330
|
-
cast_to=
|
|
1336
|
+
cast_to=cast(
|
|
1337
|
+
Any, LettaStreamingResponse
|
|
1338
|
+
), # Union types cannot be passed in as arguments in the type system
|
|
1339
|
+
stream=True,
|
|
1340
|
+
stream_cls=AsyncStream[LettaStreamingResponse],
|
|
1331
1341
|
)
|
|
1332
1342
|
|
|
1333
1343
|
async def summarize(
|
|
@@ -1371,15 +1381,15 @@ class MessagesResourceWithRawResponse:
|
|
|
1371
1381
|
def __init__(self, messages: MessagesResource) -> None:
|
|
1372
1382
|
self._messages = messages
|
|
1373
1383
|
|
|
1374
|
-
self.update = to_raw_response_wrapper(
|
|
1375
|
-
messages.update,
|
|
1376
|
-
)
|
|
1377
1384
|
self.list = to_raw_response_wrapper(
|
|
1378
1385
|
messages.list,
|
|
1379
1386
|
)
|
|
1380
1387
|
self.cancel = to_raw_response_wrapper(
|
|
1381
1388
|
messages.cancel,
|
|
1382
1389
|
)
|
|
1390
|
+
self.modify = to_raw_response_wrapper(
|
|
1391
|
+
messages.modify,
|
|
1392
|
+
)
|
|
1383
1393
|
self.reset = to_raw_response_wrapper(
|
|
1384
1394
|
messages.reset,
|
|
1385
1395
|
)
|
|
@@ -1401,15 +1411,15 @@ class AsyncMessagesResourceWithRawResponse:
|
|
|
1401
1411
|
def __init__(self, messages: AsyncMessagesResource) -> None:
|
|
1402
1412
|
self._messages = messages
|
|
1403
1413
|
|
|
1404
|
-
self.update = async_to_raw_response_wrapper(
|
|
1405
|
-
messages.update,
|
|
1406
|
-
)
|
|
1407
1414
|
self.list = async_to_raw_response_wrapper(
|
|
1408
1415
|
messages.list,
|
|
1409
1416
|
)
|
|
1410
1417
|
self.cancel = async_to_raw_response_wrapper(
|
|
1411
1418
|
messages.cancel,
|
|
1412
1419
|
)
|
|
1420
|
+
self.modify = async_to_raw_response_wrapper(
|
|
1421
|
+
messages.modify,
|
|
1422
|
+
)
|
|
1413
1423
|
self.reset = async_to_raw_response_wrapper(
|
|
1414
1424
|
messages.reset,
|
|
1415
1425
|
)
|
|
@@ -1431,15 +1441,15 @@ class MessagesResourceWithStreamingResponse:
|
|
|
1431
1441
|
def __init__(self, messages: MessagesResource) -> None:
|
|
1432
1442
|
self._messages = messages
|
|
1433
1443
|
|
|
1434
|
-
self.update = to_streamed_response_wrapper(
|
|
1435
|
-
messages.update,
|
|
1436
|
-
)
|
|
1437
1444
|
self.list = to_streamed_response_wrapper(
|
|
1438
1445
|
messages.list,
|
|
1439
1446
|
)
|
|
1440
1447
|
self.cancel = to_streamed_response_wrapper(
|
|
1441
1448
|
messages.cancel,
|
|
1442
1449
|
)
|
|
1450
|
+
self.modify = to_streamed_response_wrapper(
|
|
1451
|
+
messages.modify,
|
|
1452
|
+
)
|
|
1443
1453
|
self.reset = to_streamed_response_wrapper(
|
|
1444
1454
|
messages.reset,
|
|
1445
1455
|
)
|
|
@@ -1461,15 +1471,15 @@ class AsyncMessagesResourceWithStreamingResponse:
|
|
|
1461
1471
|
def __init__(self, messages: AsyncMessagesResource) -> None:
|
|
1462
1472
|
self._messages = messages
|
|
1463
1473
|
|
|
1464
|
-
self.update = async_to_streamed_response_wrapper(
|
|
1465
|
-
messages.update,
|
|
1466
|
-
)
|
|
1467
1474
|
self.list = async_to_streamed_response_wrapper(
|
|
1468
1475
|
messages.list,
|
|
1469
1476
|
)
|
|
1470
1477
|
self.cancel = async_to_streamed_response_wrapper(
|
|
1471
1478
|
messages.cancel,
|
|
1472
1479
|
)
|
|
1480
|
+
self.modify = async_to_streamed_response_wrapper(
|
|
1481
|
+
messages.modify,
|
|
1482
|
+
)
|
|
1473
1483
|
self.reset = async_to_streamed_response_wrapper(
|
|
1474
1484
|
messages.reset,
|
|
1475
1485
|
)
|