letta-client 0.1.17__py3-none-any.whl → 0.1.21__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.
- letta_client/__init__.py +44 -116
- letta_client/agents/__init__.py +18 -42
- letta_client/agents/archival_memory/client.py +6 -6
- letta_client/agents/client.py +28 -18
- letta_client/agents/context/client.py +6 -4
- letta_client/agents/core_memory/client.py +152 -227
- letta_client/agents/memory_variables/__init__.py +2 -2
- letta_client/agents/memory_variables/client.py +15 -15
- letta_client/agents/memory_variables/types/__init__.py +2 -2
- letta_client/agents/memory_variables/types/{memory_variables_get_response.py → memory_variables_list_response.py} +1 -1
- letta_client/agents/messages/__init__.py +2 -22
- letta_client/agents/messages/client.py +39 -40
- letta_client/agents/messages/types/__init__.py +3 -21
- letta_client/agents/messages/types/letta_streaming_response.py +16 -139
- letta_client/agents/messages/types/message_update_content.py +6 -0
- letta_client/agents/messages/types/messages_list_response.py +2 -2
- letta_client/agents/sources/client.py +266 -5
- letta_client/agents/tools/client.py +25 -27
- letta_client/agents/types/__init__.py +15 -25
- letta_client/agents/types/agents_search_request_search_item.py +10 -78
- letta_client/agents/types/{agents_search_request_search_item_order_by.py → agents_search_request_search_item_direction.py} +7 -6
- letta_client/agents/types/agents_search_request_search_item_direction_direction.py +5 -0
- letta_client/agents/types/agents_search_request_search_item_direction_value.py +5 -0
- letta_client/agents/types/{agents_search_request_search_item_name.py → agents_search_request_search_item_one.py} +5 -4
- letta_client/agents/types/agents_search_request_search_item_one_operator.py +5 -0
- letta_client/agents/types/{agents_search_request_search_item_tags.py → agents_search_request_search_item_two.py} +2 -1
- letta_client/agents/types/{agents_search_request_search_item_version.py → agents_search_request_search_item_zero.py} +3 -2
- letta_client/blocks/client.py +45 -166
- letta_client/client.py +3 -3
- letta_client/core/client_wrapper.py +1 -1
- letta_client/jobs/client.py +4 -4
- letta_client/providers/client.py +10 -10
- letta_client/runs/client.py +44 -30
- letta_client/sources/client.py +12 -288
- letta_client/sources/files/client.py +6 -6
- letta_client/tag/client.py +6 -6
- letta_client/tools/client.py +69 -75
- letta_client/types/__init__.py +31 -99
- letta_client/types/agent_state.py +3 -7
- letta_client/types/{letta_schemas_openai_chat_completion_response_tool_call.py → assistant_message.py} +6 -4
- letta_client/types/assistant_message_content.py +6 -0
- letta_client/types/block.py +2 -6
- letta_client/types/block_update.py +1 -5
- letta_client/types/{assistant_message_output.py → chat_completion_message_tool_call.py} +5 -5
- letta_client/types/context_window_overview.py +4 -6
- letta_client/types/create_block.py +1 -5
- letta_client/types/{function_call_output.py → function.py} +1 -1
- letta_client/types/{function_schema.py → function_definition.py} +2 -1
- letta_client/types/{function_call_input.py → function_tool.py} +5 -3
- letta_client/types/job.py +1 -5
- letta_client/types/letta_message_union.py +9 -121
- letta_client/types/letta_usage_statistics.py +1 -0
- letta_client/types/llm_config.py +6 -0
- letta_client/types/{letta_schemas_message_message.py → message.py} +7 -8
- letta_client/types/message_create.py +3 -2
- letta_client/types/message_create_content.py +6 -0
- letta_client/types/passage.py +1 -5
- letta_client/types/reasoning_message.py +2 -1
- letta_client/types/run.py +1 -5
- letta_client/types/source.py +2 -6
- letta_client/types/{system_message_output.py → system_message.py} +6 -4
- letta_client/types/system_message_content.py +6 -0
- letta_client/types/{create_assistant_file_request.py → text_content.py} +5 -4
- letta_client/types/{letta_schemas_tool_tool.py → tool.py} +1 -1
- letta_client/types/{letta_schemas_letta_message_tool_call.py → tool_call.py} +1 -1
- letta_client/types/tool_call_message.py +2 -1
- letta_client/types/tool_call_message_tool_call.py +2 -2
- letta_client/types/tool_return_message.py +2 -1
- letta_client/types/tool_type.py +2 -1
- letta_client/types/{user_message_output.py → user_message.py} +6 -4
- letta_client/types/user_message_content.py +6 -0
- {letta_client-0.1.17.dist-info → letta_client-0.1.21.dist-info}/METADATA +2 -2
- {letta_client-0.1.17.dist-info → letta_client-0.1.21.dist-info}/RECORD +74 -99
- letta_client/agents/types/agents_search_request_search_item_name_operator.py +0 -5
- letta_client/agents/types/agents_search_request_search_item_order_by_direction.py +0 -5
- letta_client/agents/types/agents_search_request_search_item_order_by_value.py +0 -5
- letta_client/types/assistant_file.py +0 -33
- letta_client/types/assistant_message_input.py +0 -23
- letta_client/types/chat_completion_request.py +0 -49
- letta_client/types/chat_completion_request_function_call.py +0 -6
- letta_client/types/chat_completion_request_messages_item.py +0 -11
- letta_client/types/chat_completion_request_stop.py +0 -5
- letta_client/types/chat_completion_request_tool_choice.py +0 -8
- letta_client/types/chat_completion_response.py +0 -32
- letta_client/types/choice.py +0 -25
- letta_client/types/create_assistant_request.py +0 -57
- letta_client/types/delete_assistant_file_response.py +0 -28
- letta_client/types/delete_assistant_response.py +0 -28
- letta_client/types/letta_schemas_openai_chat_completion_request_tool.py +0 -21
- letta_client/types/letta_schemas_openai_chat_completion_request_tool_call.py +0 -24
- letta_client/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +0 -20
- letta_client/types/letta_schemas_openai_chat_completion_response_message.py +0 -24
- letta_client/types/letta_schemas_openai_chat_completions_tool_call_function.py +0 -27
- letta_client/types/letta_schemas_openai_chat_completions_tool_call_input.py +0 -29
- letta_client/types/letta_schemas_openai_chat_completions_tool_call_output.py +0 -29
- letta_client/types/log_prob_token.py +0 -21
- letta_client/types/message_content_log_prob.py +0 -23
- letta_client/types/open_ai_assistant.py +0 -67
- letta_client/types/response_format.py +0 -19
- letta_client/types/system_message_input.py +0 -21
- letta_client/types/tool_call_function_output.py +0 -27
- letta_client/types/tool_function_choice.py +0 -21
- letta_client/types/tool_input.py +0 -21
- letta_client/types/tool_message.py +0 -21
- letta_client/types/user_message_input.py +0 -22
- letta_client/types/user_message_input_content.py +0 -5
- {letta_client-0.1.17.dist-info → letta_client-0.1.21.dist-info}/WHEEL +0 -0
letta_client/runs/client.py
CHANGED
|
@@ -124,7 +124,7 @@ class RunsClient:
|
|
|
124
124
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
125
125
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
126
126
|
|
|
127
|
-
def
|
|
127
|
+
def retrieve_run(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
128
128
|
"""
|
|
129
129
|
Get the status of a run.
|
|
130
130
|
|
|
@@ -147,7 +147,7 @@ class RunsClient:
|
|
|
147
147
|
client = Letta(
|
|
148
148
|
token="YOUR_TOKEN",
|
|
149
149
|
)
|
|
150
|
-
client.runs.
|
|
150
|
+
client.runs.retrieve_run(
|
|
151
151
|
run_id="run_id",
|
|
152
152
|
)
|
|
153
153
|
"""
|
|
@@ -236,13 +236,14 @@ class RunsClient:
|
|
|
236
236
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
237
237
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
238
238
|
|
|
239
|
-
def
|
|
239
|
+
def list_run_messages(
|
|
240
240
|
self,
|
|
241
241
|
run_id: str,
|
|
242
242
|
*,
|
|
243
|
-
|
|
243
|
+
before: typing.Optional[str] = None,
|
|
244
|
+
after: typing.Optional[str] = None,
|
|
244
245
|
limit: typing.Optional[int] = None,
|
|
245
|
-
|
|
246
|
+
order: typing.Optional[str] = None,
|
|
246
247
|
role: typing.Optional[MessageRole] = None,
|
|
247
248
|
request_options: typing.Optional[RequestOptions] = None,
|
|
248
249
|
) -> typing.List[LettaMessageUnion]:
|
|
@@ -251,9 +252,10 @@ class RunsClient:
|
|
|
251
252
|
|
|
252
253
|
Args:
|
|
253
254
|
run_id: ID of the run
|
|
254
|
-
|
|
255
|
+
before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
|
|
256
|
+
after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
|
|
255
257
|
limit: Maximum number of messages to return
|
|
256
|
-
|
|
258
|
+
order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
257
259
|
role: Filter by role (user/assistant/system/tool)
|
|
258
260
|
return_message_object: Whether to return Message objects or LettaMessage objects
|
|
259
261
|
user_id: ID of the user making the request
|
|
@@ -265,14 +267,17 @@ class RunsClient:
|
|
|
265
267
|
----------
|
|
266
268
|
run_id : str
|
|
267
269
|
|
|
268
|
-
|
|
270
|
+
before : typing.Optional[str]
|
|
271
|
+
Cursor for pagination
|
|
272
|
+
|
|
273
|
+
after : typing.Optional[str]
|
|
269
274
|
Cursor for pagination
|
|
270
275
|
|
|
271
276
|
limit : typing.Optional[int]
|
|
272
277
|
Maximum number of messages to return
|
|
273
278
|
|
|
274
|
-
|
|
275
|
-
Sort order by
|
|
279
|
+
order : typing.Optional[str]
|
|
280
|
+
Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
276
281
|
|
|
277
282
|
role : typing.Optional[MessageRole]
|
|
278
283
|
Filter by role
|
|
@@ -292,7 +297,7 @@ class RunsClient:
|
|
|
292
297
|
client = Letta(
|
|
293
298
|
token="YOUR_TOKEN",
|
|
294
299
|
)
|
|
295
|
-
client.runs.
|
|
300
|
+
client.runs.list_run_messages(
|
|
296
301
|
run_id="run_id",
|
|
297
302
|
)
|
|
298
303
|
"""
|
|
@@ -300,9 +305,10 @@ class RunsClient:
|
|
|
300
305
|
f"v1/runs/{jsonable_encoder(run_id)}/messages",
|
|
301
306
|
method="GET",
|
|
302
307
|
params={
|
|
303
|
-
"
|
|
308
|
+
"before": before,
|
|
309
|
+
"after": after,
|
|
304
310
|
"limit": limit,
|
|
305
|
-
"
|
|
311
|
+
"order": order,
|
|
306
312
|
"role": role,
|
|
307
313
|
},
|
|
308
314
|
request_options=request_options,
|
|
@@ -331,7 +337,9 @@ class RunsClient:
|
|
|
331
337
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
332
338
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
333
339
|
|
|
334
|
-
def
|
|
340
|
+
def retrieve_run_usage(
|
|
341
|
+
self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
342
|
+
) -> UsageStatistics:
|
|
335
343
|
"""
|
|
336
344
|
Get usage statistics for a run.
|
|
337
345
|
|
|
@@ -354,7 +362,7 @@ class RunsClient:
|
|
|
354
362
|
client = Letta(
|
|
355
363
|
token="YOUR_TOKEN",
|
|
356
364
|
)
|
|
357
|
-
client.runs.
|
|
365
|
+
client.runs.retrieve_run_usage(
|
|
358
366
|
run_id="run_id",
|
|
359
367
|
)
|
|
360
368
|
"""
|
|
@@ -512,7 +520,7 @@ class AsyncRunsClient:
|
|
|
512
520
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
513
521
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
514
522
|
|
|
515
|
-
async def
|
|
523
|
+
async def retrieve_run(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
516
524
|
"""
|
|
517
525
|
Get the status of a run.
|
|
518
526
|
|
|
@@ -540,7 +548,7 @@ class AsyncRunsClient:
|
|
|
540
548
|
|
|
541
549
|
|
|
542
550
|
async def main() -> None:
|
|
543
|
-
await client.runs.
|
|
551
|
+
await client.runs.retrieve_run(
|
|
544
552
|
run_id="run_id",
|
|
545
553
|
)
|
|
546
554
|
|
|
@@ -640,13 +648,14 @@ class AsyncRunsClient:
|
|
|
640
648
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
641
649
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
642
650
|
|
|
643
|
-
async def
|
|
651
|
+
async def list_run_messages(
|
|
644
652
|
self,
|
|
645
653
|
run_id: str,
|
|
646
654
|
*,
|
|
647
|
-
|
|
655
|
+
before: typing.Optional[str] = None,
|
|
656
|
+
after: typing.Optional[str] = None,
|
|
648
657
|
limit: typing.Optional[int] = None,
|
|
649
|
-
|
|
658
|
+
order: typing.Optional[str] = None,
|
|
650
659
|
role: typing.Optional[MessageRole] = None,
|
|
651
660
|
request_options: typing.Optional[RequestOptions] = None,
|
|
652
661
|
) -> typing.List[LettaMessageUnion]:
|
|
@@ -655,9 +664,10 @@ class AsyncRunsClient:
|
|
|
655
664
|
|
|
656
665
|
Args:
|
|
657
666
|
run_id: ID of the run
|
|
658
|
-
|
|
667
|
+
before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
|
|
668
|
+
after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
|
|
659
669
|
limit: Maximum number of messages to return
|
|
660
|
-
|
|
670
|
+
order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
661
671
|
role: Filter by role (user/assistant/system/tool)
|
|
662
672
|
return_message_object: Whether to return Message objects or LettaMessage objects
|
|
663
673
|
user_id: ID of the user making the request
|
|
@@ -669,14 +679,17 @@ class AsyncRunsClient:
|
|
|
669
679
|
----------
|
|
670
680
|
run_id : str
|
|
671
681
|
|
|
672
|
-
|
|
682
|
+
before : typing.Optional[str]
|
|
683
|
+
Cursor for pagination
|
|
684
|
+
|
|
685
|
+
after : typing.Optional[str]
|
|
673
686
|
Cursor for pagination
|
|
674
687
|
|
|
675
688
|
limit : typing.Optional[int]
|
|
676
689
|
Maximum number of messages to return
|
|
677
690
|
|
|
678
|
-
|
|
679
|
-
Sort order by
|
|
691
|
+
order : typing.Optional[str]
|
|
692
|
+
Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
680
693
|
|
|
681
694
|
role : typing.Optional[MessageRole]
|
|
682
695
|
Filter by role
|
|
@@ -701,7 +714,7 @@ class AsyncRunsClient:
|
|
|
701
714
|
|
|
702
715
|
|
|
703
716
|
async def main() -> None:
|
|
704
|
-
await client.runs.
|
|
717
|
+
await client.runs.list_run_messages(
|
|
705
718
|
run_id="run_id",
|
|
706
719
|
)
|
|
707
720
|
|
|
@@ -712,9 +725,10 @@ class AsyncRunsClient:
|
|
|
712
725
|
f"v1/runs/{jsonable_encoder(run_id)}/messages",
|
|
713
726
|
method="GET",
|
|
714
727
|
params={
|
|
715
|
-
"
|
|
728
|
+
"before": before,
|
|
729
|
+
"after": after,
|
|
716
730
|
"limit": limit,
|
|
717
|
-
"
|
|
731
|
+
"order": order,
|
|
718
732
|
"role": role,
|
|
719
733
|
},
|
|
720
734
|
request_options=request_options,
|
|
@@ -743,7 +757,7 @@ class AsyncRunsClient:
|
|
|
743
757
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
744
758
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
745
759
|
|
|
746
|
-
async def
|
|
760
|
+
async def retrieve_run_usage(
|
|
747
761
|
self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
748
762
|
) -> UsageStatistics:
|
|
749
763
|
"""
|
|
@@ -773,7 +787,7 @@ class AsyncRunsClient:
|
|
|
773
787
|
|
|
774
788
|
|
|
775
789
|
async def main() -> None:
|
|
776
|
-
await client.runs.
|
|
790
|
+
await client.runs.retrieve_run_usage(
|
|
777
791
|
run_id="run_id",
|
|
778
792
|
)
|
|
779
793
|
|
letta_client/sources/client.py
CHANGED
|
@@ -28,7 +28,7 @@ class SourcesClient:
|
|
|
28
28
|
self.files = FilesClient(client_wrapper=self._client_wrapper)
|
|
29
29
|
self.passages = PassagesClient(client_wrapper=self._client_wrapper)
|
|
30
30
|
|
|
31
|
-
def
|
|
31
|
+
def retrieve(self, source_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Source:
|
|
32
32
|
"""
|
|
33
33
|
Get all sources
|
|
34
34
|
|
|
@@ -51,7 +51,7 @@ class SourcesClient:
|
|
|
51
51
|
client = Letta(
|
|
52
52
|
token="YOUR_TOKEN",
|
|
53
53
|
)
|
|
54
|
-
client.sources.
|
|
54
|
+
client.sources.retrieve(
|
|
55
55
|
source_id="source_id",
|
|
56
56
|
)
|
|
57
57
|
"""
|
|
@@ -142,7 +142,7 @@ class SourcesClient:
|
|
|
142
142
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
143
143
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
144
144
|
|
|
145
|
-
def
|
|
145
|
+
def modify(
|
|
146
146
|
self,
|
|
147
147
|
source_id: str,
|
|
148
148
|
*,
|
|
@@ -186,7 +186,7 @@ class SourcesClient:
|
|
|
186
186
|
client = Letta(
|
|
187
187
|
token="YOUR_TOKEN",
|
|
188
188
|
)
|
|
189
|
-
client.sources.
|
|
189
|
+
client.sources.modify(
|
|
190
190
|
source_id="source_id",
|
|
191
191
|
)
|
|
192
192
|
"""
|
|
@@ -196,7 +196,7 @@ class SourcesClient:
|
|
|
196
196
|
json={
|
|
197
197
|
"name": name,
|
|
198
198
|
"description": description,
|
|
199
|
-
"
|
|
199
|
+
"metadata": metadata,
|
|
200
200
|
"embedding_config": convert_and_respect_annotation_metadata(
|
|
201
201
|
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
202
202
|
),
|
|
@@ -393,7 +393,7 @@ class SourcesClient:
|
|
|
393
393
|
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
394
394
|
),
|
|
395
395
|
"description": description,
|
|
396
|
-
"
|
|
396
|
+
"metadata": metadata,
|
|
397
397
|
},
|
|
398
398
|
headers={
|
|
399
399
|
"content-type": "application/json",
|
|
@@ -425,136 +425,6 @@ class SourcesClient:
|
|
|
425
425
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
426
426
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
427
427
|
|
|
428
|
-
def attach(
|
|
429
|
-
self, source_id: str, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
430
|
-
) -> Source:
|
|
431
|
-
"""
|
|
432
|
-
Attach a data source to an existing agent.
|
|
433
|
-
|
|
434
|
-
Parameters
|
|
435
|
-
----------
|
|
436
|
-
source_id : str
|
|
437
|
-
|
|
438
|
-
agent_id : str
|
|
439
|
-
The unique identifier of the agent to attach the source to.
|
|
440
|
-
|
|
441
|
-
request_options : typing.Optional[RequestOptions]
|
|
442
|
-
Request-specific configuration.
|
|
443
|
-
|
|
444
|
-
Returns
|
|
445
|
-
-------
|
|
446
|
-
Source
|
|
447
|
-
Successful Response
|
|
448
|
-
|
|
449
|
-
Examples
|
|
450
|
-
--------
|
|
451
|
-
from letta_client import Letta
|
|
452
|
-
|
|
453
|
-
client = Letta(
|
|
454
|
-
token="YOUR_TOKEN",
|
|
455
|
-
)
|
|
456
|
-
client.sources.attach(
|
|
457
|
-
source_id="source_id",
|
|
458
|
-
agent_id="agent_id",
|
|
459
|
-
)
|
|
460
|
-
"""
|
|
461
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
462
|
-
f"v1/sources/{jsonable_encoder(source_id)}/attach",
|
|
463
|
-
method="POST",
|
|
464
|
-
params={
|
|
465
|
-
"agent_id": agent_id,
|
|
466
|
-
},
|
|
467
|
-
request_options=request_options,
|
|
468
|
-
)
|
|
469
|
-
try:
|
|
470
|
-
if 200 <= _response.status_code < 300:
|
|
471
|
-
return typing.cast(
|
|
472
|
-
Source,
|
|
473
|
-
construct_type(
|
|
474
|
-
type_=Source, # type: ignore
|
|
475
|
-
object_=_response.json(),
|
|
476
|
-
),
|
|
477
|
-
)
|
|
478
|
-
if _response.status_code == 422:
|
|
479
|
-
raise UnprocessableEntityError(
|
|
480
|
-
typing.cast(
|
|
481
|
-
HttpValidationError,
|
|
482
|
-
construct_type(
|
|
483
|
-
type_=HttpValidationError, # type: ignore
|
|
484
|
-
object_=_response.json(),
|
|
485
|
-
),
|
|
486
|
-
)
|
|
487
|
-
)
|
|
488
|
-
_response_json = _response.json()
|
|
489
|
-
except JSONDecodeError:
|
|
490
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
491
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
492
|
-
|
|
493
|
-
def detach(
|
|
494
|
-
self, source_id: str, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
495
|
-
) -> Source:
|
|
496
|
-
"""
|
|
497
|
-
Detach a data source from an existing agent.
|
|
498
|
-
|
|
499
|
-
Parameters
|
|
500
|
-
----------
|
|
501
|
-
source_id : str
|
|
502
|
-
|
|
503
|
-
agent_id : str
|
|
504
|
-
The unique identifier of the agent to detach the source from.
|
|
505
|
-
|
|
506
|
-
request_options : typing.Optional[RequestOptions]
|
|
507
|
-
Request-specific configuration.
|
|
508
|
-
|
|
509
|
-
Returns
|
|
510
|
-
-------
|
|
511
|
-
Source
|
|
512
|
-
Successful Response
|
|
513
|
-
|
|
514
|
-
Examples
|
|
515
|
-
--------
|
|
516
|
-
from letta_client import Letta
|
|
517
|
-
|
|
518
|
-
client = Letta(
|
|
519
|
-
token="YOUR_TOKEN",
|
|
520
|
-
)
|
|
521
|
-
client.sources.detach(
|
|
522
|
-
source_id="source_id",
|
|
523
|
-
agent_id="agent_id",
|
|
524
|
-
)
|
|
525
|
-
"""
|
|
526
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
527
|
-
f"v1/sources/{jsonable_encoder(source_id)}/detach",
|
|
528
|
-
method="POST",
|
|
529
|
-
params={
|
|
530
|
-
"agent_id": agent_id,
|
|
531
|
-
},
|
|
532
|
-
request_options=request_options,
|
|
533
|
-
)
|
|
534
|
-
try:
|
|
535
|
-
if 200 <= _response.status_code < 300:
|
|
536
|
-
return typing.cast(
|
|
537
|
-
Source,
|
|
538
|
-
construct_type(
|
|
539
|
-
type_=Source, # type: ignore
|
|
540
|
-
object_=_response.json(),
|
|
541
|
-
),
|
|
542
|
-
)
|
|
543
|
-
if _response.status_code == 422:
|
|
544
|
-
raise UnprocessableEntityError(
|
|
545
|
-
typing.cast(
|
|
546
|
-
HttpValidationError,
|
|
547
|
-
construct_type(
|
|
548
|
-
type_=HttpValidationError, # type: ignore
|
|
549
|
-
object_=_response.json(),
|
|
550
|
-
),
|
|
551
|
-
)
|
|
552
|
-
)
|
|
553
|
-
_response_json = _response.json()
|
|
554
|
-
except JSONDecodeError:
|
|
555
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
556
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
557
|
-
|
|
558
428
|
|
|
559
429
|
class AsyncSourcesClient:
|
|
560
430
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -562,7 +432,7 @@ class AsyncSourcesClient:
|
|
|
562
432
|
self.files = AsyncFilesClient(client_wrapper=self._client_wrapper)
|
|
563
433
|
self.passages = AsyncPassagesClient(client_wrapper=self._client_wrapper)
|
|
564
434
|
|
|
565
|
-
async def
|
|
435
|
+
async def retrieve(self, source_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Source:
|
|
566
436
|
"""
|
|
567
437
|
Get all sources
|
|
568
438
|
|
|
@@ -590,7 +460,7 @@ class AsyncSourcesClient:
|
|
|
590
460
|
|
|
591
461
|
|
|
592
462
|
async def main() -> None:
|
|
593
|
-
await client.sources.
|
|
463
|
+
await client.sources.retrieve(
|
|
594
464
|
source_id="source_id",
|
|
595
465
|
)
|
|
596
466
|
|
|
@@ -692,7 +562,7 @@ class AsyncSourcesClient:
|
|
|
692
562
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
693
563
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
694
564
|
|
|
695
|
-
async def
|
|
565
|
+
async def modify(
|
|
696
566
|
self,
|
|
697
567
|
source_id: str,
|
|
698
568
|
*,
|
|
@@ -741,7 +611,7 @@ class AsyncSourcesClient:
|
|
|
741
611
|
|
|
742
612
|
|
|
743
613
|
async def main() -> None:
|
|
744
|
-
await client.sources.
|
|
614
|
+
await client.sources.modify(
|
|
745
615
|
source_id="source_id",
|
|
746
616
|
)
|
|
747
617
|
|
|
@@ -754,7 +624,7 @@ class AsyncSourcesClient:
|
|
|
754
624
|
json={
|
|
755
625
|
"name": name,
|
|
756
626
|
"description": description,
|
|
757
|
-
"
|
|
627
|
+
"metadata": metadata,
|
|
758
628
|
"embedding_config": convert_and_respect_annotation_metadata(
|
|
759
629
|
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
760
630
|
),
|
|
@@ -975,7 +845,7 @@ class AsyncSourcesClient:
|
|
|
975
845
|
object_=embedding_config, annotation=EmbeddingConfig, direction="write"
|
|
976
846
|
),
|
|
977
847
|
"description": description,
|
|
978
|
-
"
|
|
848
|
+
"metadata": metadata,
|
|
979
849
|
},
|
|
980
850
|
headers={
|
|
981
851
|
"content-type": "application/json",
|
|
@@ -1006,149 +876,3 @@ class AsyncSourcesClient:
|
|
|
1006
876
|
except JSONDecodeError:
|
|
1007
877
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1008
878
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1009
|
-
|
|
1010
|
-
async def attach(
|
|
1011
|
-
self, source_id: str, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
1012
|
-
) -> Source:
|
|
1013
|
-
"""
|
|
1014
|
-
Attach a data source to an existing agent.
|
|
1015
|
-
|
|
1016
|
-
Parameters
|
|
1017
|
-
----------
|
|
1018
|
-
source_id : str
|
|
1019
|
-
|
|
1020
|
-
agent_id : str
|
|
1021
|
-
The unique identifier of the agent to attach the source to.
|
|
1022
|
-
|
|
1023
|
-
request_options : typing.Optional[RequestOptions]
|
|
1024
|
-
Request-specific configuration.
|
|
1025
|
-
|
|
1026
|
-
Returns
|
|
1027
|
-
-------
|
|
1028
|
-
Source
|
|
1029
|
-
Successful Response
|
|
1030
|
-
|
|
1031
|
-
Examples
|
|
1032
|
-
--------
|
|
1033
|
-
import asyncio
|
|
1034
|
-
|
|
1035
|
-
from letta_client import AsyncLetta
|
|
1036
|
-
|
|
1037
|
-
client = AsyncLetta(
|
|
1038
|
-
token="YOUR_TOKEN",
|
|
1039
|
-
)
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
async def main() -> None:
|
|
1043
|
-
await client.sources.attach(
|
|
1044
|
-
source_id="source_id",
|
|
1045
|
-
agent_id="agent_id",
|
|
1046
|
-
)
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
asyncio.run(main())
|
|
1050
|
-
"""
|
|
1051
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1052
|
-
f"v1/sources/{jsonable_encoder(source_id)}/attach",
|
|
1053
|
-
method="POST",
|
|
1054
|
-
params={
|
|
1055
|
-
"agent_id": agent_id,
|
|
1056
|
-
},
|
|
1057
|
-
request_options=request_options,
|
|
1058
|
-
)
|
|
1059
|
-
try:
|
|
1060
|
-
if 200 <= _response.status_code < 300:
|
|
1061
|
-
return typing.cast(
|
|
1062
|
-
Source,
|
|
1063
|
-
construct_type(
|
|
1064
|
-
type_=Source, # type: ignore
|
|
1065
|
-
object_=_response.json(),
|
|
1066
|
-
),
|
|
1067
|
-
)
|
|
1068
|
-
if _response.status_code == 422:
|
|
1069
|
-
raise UnprocessableEntityError(
|
|
1070
|
-
typing.cast(
|
|
1071
|
-
HttpValidationError,
|
|
1072
|
-
construct_type(
|
|
1073
|
-
type_=HttpValidationError, # type: ignore
|
|
1074
|
-
object_=_response.json(),
|
|
1075
|
-
),
|
|
1076
|
-
)
|
|
1077
|
-
)
|
|
1078
|
-
_response_json = _response.json()
|
|
1079
|
-
except JSONDecodeError:
|
|
1080
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1081
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1082
|
-
|
|
1083
|
-
async def detach(
|
|
1084
|
-
self, source_id: str, *, agent_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
1085
|
-
) -> Source:
|
|
1086
|
-
"""
|
|
1087
|
-
Detach a data source from an existing agent.
|
|
1088
|
-
|
|
1089
|
-
Parameters
|
|
1090
|
-
----------
|
|
1091
|
-
source_id : str
|
|
1092
|
-
|
|
1093
|
-
agent_id : str
|
|
1094
|
-
The unique identifier of the agent to detach the source from.
|
|
1095
|
-
|
|
1096
|
-
request_options : typing.Optional[RequestOptions]
|
|
1097
|
-
Request-specific configuration.
|
|
1098
|
-
|
|
1099
|
-
Returns
|
|
1100
|
-
-------
|
|
1101
|
-
Source
|
|
1102
|
-
Successful Response
|
|
1103
|
-
|
|
1104
|
-
Examples
|
|
1105
|
-
--------
|
|
1106
|
-
import asyncio
|
|
1107
|
-
|
|
1108
|
-
from letta_client import AsyncLetta
|
|
1109
|
-
|
|
1110
|
-
client = AsyncLetta(
|
|
1111
|
-
token="YOUR_TOKEN",
|
|
1112
|
-
)
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
async def main() -> None:
|
|
1116
|
-
await client.sources.detach(
|
|
1117
|
-
source_id="source_id",
|
|
1118
|
-
agent_id="agent_id",
|
|
1119
|
-
)
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
asyncio.run(main())
|
|
1123
|
-
"""
|
|
1124
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1125
|
-
f"v1/sources/{jsonable_encoder(source_id)}/detach",
|
|
1126
|
-
method="POST",
|
|
1127
|
-
params={
|
|
1128
|
-
"agent_id": agent_id,
|
|
1129
|
-
},
|
|
1130
|
-
request_options=request_options,
|
|
1131
|
-
)
|
|
1132
|
-
try:
|
|
1133
|
-
if 200 <= _response.status_code < 300:
|
|
1134
|
-
return typing.cast(
|
|
1135
|
-
Source,
|
|
1136
|
-
construct_type(
|
|
1137
|
-
type_=Source, # type: ignore
|
|
1138
|
-
object_=_response.json(),
|
|
1139
|
-
),
|
|
1140
|
-
)
|
|
1141
|
-
if _response.status_code == 422:
|
|
1142
|
-
raise UnprocessableEntityError(
|
|
1143
|
-
typing.cast(
|
|
1144
|
-
HttpValidationError,
|
|
1145
|
-
construct_type(
|
|
1146
|
-
type_=HttpValidationError, # type: ignore
|
|
1147
|
-
object_=_response.json(),
|
|
1148
|
-
),
|
|
1149
|
-
)
|
|
1150
|
-
)
|
|
1151
|
-
_response_json = _response.json()
|
|
1152
|
-
except JSONDecodeError:
|
|
1153
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1154
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -93,7 +93,7 @@ class FilesClient:
|
|
|
93
93
|
source_id: str,
|
|
94
94
|
*,
|
|
95
95
|
limit: typing.Optional[int] = None,
|
|
96
|
-
|
|
96
|
+
after: typing.Optional[str] = None,
|
|
97
97
|
request_options: typing.Optional[RequestOptions] = None,
|
|
98
98
|
) -> typing.List[FileMetadata]:
|
|
99
99
|
"""
|
|
@@ -106,7 +106,7 @@ class FilesClient:
|
|
|
106
106
|
limit : typing.Optional[int]
|
|
107
107
|
Number of files to return
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
after : typing.Optional[str]
|
|
110
110
|
Pagination cursor to fetch the next set of results
|
|
111
111
|
|
|
112
112
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -133,7 +133,7 @@ class FilesClient:
|
|
|
133
133
|
method="GET",
|
|
134
134
|
params={
|
|
135
135
|
"limit": limit,
|
|
136
|
-
"
|
|
136
|
+
"after": after,
|
|
137
137
|
},
|
|
138
138
|
request_options=request_options,
|
|
139
139
|
)
|
|
@@ -297,7 +297,7 @@ class AsyncFilesClient:
|
|
|
297
297
|
source_id: str,
|
|
298
298
|
*,
|
|
299
299
|
limit: typing.Optional[int] = None,
|
|
300
|
-
|
|
300
|
+
after: typing.Optional[str] = None,
|
|
301
301
|
request_options: typing.Optional[RequestOptions] = None,
|
|
302
302
|
) -> typing.List[FileMetadata]:
|
|
303
303
|
"""
|
|
@@ -310,7 +310,7 @@ class AsyncFilesClient:
|
|
|
310
310
|
limit : typing.Optional[int]
|
|
311
311
|
Number of files to return
|
|
312
312
|
|
|
313
|
-
|
|
313
|
+
after : typing.Optional[str]
|
|
314
314
|
Pagination cursor to fetch the next set of results
|
|
315
315
|
|
|
316
316
|
request_options : typing.Optional[RequestOptions]
|
|
@@ -345,7 +345,7 @@ class AsyncFilesClient:
|
|
|
345
345
|
method="GET",
|
|
346
346
|
params={
|
|
347
347
|
"limit": limit,
|
|
348
|
-
"
|
|
348
|
+
"after": after,
|
|
349
349
|
},
|
|
350
350
|
request_options=request_options,
|
|
351
351
|
)
|