letta-client 0.1.6__py3-none-any.whl → 0.1.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (153) hide show
  1. letta/__init__.py +28 -27
  2. letta/agents/__init__.py +40 -29
  3. letta/agents/archival_memory/client.py +17 -17
  4. letta/agents/client.py +405 -1721
  5. letta/agents/context/client.py +5 -5
  6. letta/agents/core_memory/client.py +1080 -0
  7. letta/agents/memory_variables/__init__.py +5 -0
  8. letta/agents/{memory → memory_variables}/client.py +41 -40
  9. letta/agents/memory_variables/types/__init__.py +5 -0
  10. letta/agents/{types/agents_get_agent_variables_response.py → memory_variables/types/memory_variables_get_response.py} +3 -3
  11. letta/agents/messages/client.py +232 -17
  12. letta/agents/messages/types/letta_streaming_response.py +21 -16
  13. letta/agents/messages/types/messages_list_response_item.py +19 -14
  14. letta/agents/recall_memory/client.py +5 -5
  15. letta/agents/sources/client.py +5 -5
  16. letta/agents/templates/__init__.py +5 -0
  17. letta/agents/templates/client.py +578 -0
  18. letta/agents/templates/types/__init__.py +5 -0
  19. letta/agents/{types/agents_migrate_response.py → templates/types/templates_migrate_response.py} +3 -3
  20. letta/agents/tools/client.py +13 -13
  21. letta/agents/types/__init__.py +23 -37
  22. letta/agents/types/agents_search_request_combinator.py +5 -0
  23. letta/agents/types/{agents_search_deployed_agents_request_search_item.py → agents_search_request_search_item.py} +17 -20
  24. letta/agents/types/{agents_search_deployed_agents_request_search_item_name.py → agents_search_request_search_item_name.py} +4 -6
  25. letta/agents/types/agents_search_request_search_item_name_operator.py +5 -0
  26. letta/agents/types/agents_search_request_search_item_order_by.py +22 -0
  27. letta/agents/types/agents_search_request_search_item_order_by_direction.py +5 -0
  28. letta/agents/types/agents_search_request_search_item_order_by_value.py +5 -0
  29. letta/agents/types/{agents_search_deployed_agents_request_search_item_version.py → agents_search_request_search_item_version.py} +2 -2
  30. letta/blocks/client.py +25 -25
  31. letta/client.py +4 -0
  32. letta/core/__init__.py +4 -0
  33. letta/core/client_wrapper.py +1 -1
  34. letta/core/unchecked_base_model.py +305 -0
  35. letta/health/client.py +3 -3
  36. letta/jobs/client.py +17 -17
  37. letta/models/client.py +5 -5
  38. letta/providers/client.py +597 -0
  39. letta/sources/client.py +33 -33
  40. letta/sources/files/client.py +11 -11
  41. letta/sources/passages/client.py +5 -5
  42. letta/tools/client.py +77 -57
  43. letta/types/__init__.py +4 -0
  44. letta/types/action_model.py +2 -2
  45. letta/types/action_parameters_model.py +2 -2
  46. letta/types/action_response_model.py +2 -2
  47. letta/types/agent_environment_variable.py +2 -7
  48. letta/types/agent_state.py +5 -8
  49. letta/types/agent_type.py +1 -2
  50. letta/types/app_auth_scheme.py +2 -2
  51. letta/types/app_model.py +2 -2
  52. letta/types/archival_memory_summary.py +2 -2
  53. letta/types/assistant_file.py +2 -2
  54. letta/types/assistant_message_input.py +2 -2
  55. letta/types/assistant_message_output.py +2 -2
  56. letta/types/auth_request.py +2 -2
  57. letta/types/auth_response.py +2 -2
  58. letta/types/auth_scheme_field.py +2 -2
  59. letta/types/block.py +2 -7
  60. letta/types/block_update.py +2 -2
  61. letta/types/chat_completion_request.py +2 -2
  62. letta/types/chat_completion_response.py +2 -2
  63. letta/types/child_tool_rule.py +2 -2
  64. letta/types/choice.py +2 -2
  65. letta/types/conditional_tool_rule.py +2 -2
  66. letta/types/conflict_error_body.py +2 -2
  67. letta/types/context_window_overview.py +2 -2
  68. letta/types/create_assistant_file_request.py +2 -2
  69. letta/types/create_assistant_request.py +2 -2
  70. letta/types/create_block.py +2 -2
  71. letta/types/delete_assistant_file_response.py +2 -2
  72. letta/types/delete_assistant_response.py +2 -2
  73. letta/types/e_2_b_sandbox_config.py +2 -2
  74. letta/types/embedding_config.py +2 -2
  75. letta/types/file_metadata.py +2 -7
  76. letta/types/function_call_input.py +2 -2
  77. letta/types/function_call_output.py +2 -2
  78. letta/types/function_schema.py +2 -2
  79. letta/types/health.py +2 -2
  80. letta/types/http_validation_error.py +2 -2
  81. letta/types/init_tool_rule.py +2 -2
  82. letta/types/internal_server_error_body.py +2 -2
  83. letta/types/job.py +2 -7
  84. letta/types/letta_request.py +7 -2
  85. letta/types/letta_response.py +2 -2
  86. letta/types/letta_response_messages_item.py +19 -14
  87. letta/types/letta_schemas_letta_message_tool_call.py +2 -2
  88. letta/types/letta_schemas_message_message.py +2 -7
  89. letta/types/letta_schemas_openai_chat_completion_request_tool.py +2 -2
  90. letta/types/letta_schemas_openai_chat_completion_request_tool_call.py +2 -2
  91. letta/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +2 -2
  92. letta/types/letta_schemas_openai_chat_completion_response_message.py +2 -2
  93. letta/types/letta_schemas_openai_chat_completion_response_tool_call.py +2 -2
  94. letta/types/letta_schemas_openai_chat_completions_tool_call_function.py +2 -2
  95. letta/types/letta_schemas_openai_chat_completions_tool_call_input.py +2 -2
  96. letta/types/letta_schemas_openai_chat_completions_tool_call_output.py +2 -2
  97. letta/types/letta_schemas_tool_tool.py +9 -8
  98. letta/types/letta_usage_statistics.py +2 -2
  99. letta/types/llm_config.py +2 -2
  100. letta/types/local_sandbox_config.py +2 -2
  101. letta/types/log_prob_token.py +2 -2
  102. letta/types/memory.py +2 -2
  103. letta/types/message_content_log_prob.py +2 -2
  104. letta/types/message_create.py +2 -2
  105. letta/types/not_found_error_body.py +2 -2
  106. letta/types/open_ai_assistant.py +2 -2
  107. letta/types/organization.py +2 -2
  108. letta/types/organization_create.py +2 -2
  109. letta/types/passage.py +2 -7
  110. letta/types/provider.py +38 -0
  111. letta/types/reasoning_message.py +2 -2
  112. letta/types/recall_memory_summary.py +2 -2
  113. letta/types/response_format.py +2 -2
  114. letta/types/sandbox_config.py +2 -7
  115. letta/types/sandbox_config_create.py +2 -2
  116. letta/types/sandbox_config_update.py +2 -2
  117. letta/types/sandbox_environment_variable.py +2 -7
  118. letta/types/sandbox_environment_variable_create.py +2 -2
  119. letta/types/sandbox_environment_variable_update.py +2 -2
  120. letta/types/source.py +2 -7
  121. letta/types/system_message_input.py +2 -2
  122. letta/types/system_message_output.py +2 -2
  123. letta/types/terminal_tool_rule.py +2 -2
  124. letta/types/tool_call_delta.py +2 -2
  125. letta/types/tool_call_function_output.py +2 -2
  126. letta/types/tool_call_message.py +2 -2
  127. letta/types/tool_create.py +2 -2
  128. letta/types/tool_function_choice.py +2 -2
  129. letta/types/tool_input.py +2 -2
  130. letta/types/tool_message.py +2 -2
  131. letta/types/tool_return_message.py +2 -2
  132. letta/types/tool_type.py +5 -0
  133. letta/types/usage_statistics.py +2 -2
  134. letta/types/user.py +2 -7
  135. letta/types/user_create.py +2 -7
  136. letta/types/user_message_input.py +2 -2
  137. letta/types/user_message_output.py +2 -2
  138. letta/types/user_update.py +2 -7
  139. letta/types/validation_error.py +2 -2
  140. {letta_client-0.1.6.dist-info → letta_client-0.1.9.dist-info}/METADATA +1 -1
  141. letta_client-0.1.9.dist-info/RECORD +200 -0
  142. letta/agents/memory/__init__.py +0 -5
  143. letta/agents/memory/messages/client.py +0 -147
  144. letta/agents/memory_blocks/client.py +0 -364
  145. letta/agents/types/agents_search_deployed_agents_request_combinator.py +0 -5
  146. letta/agents/types/agents_search_deployed_agents_request_search_item_name_operator.py +0 -7
  147. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by.py +0 -26
  148. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_direction.py +0 -5
  149. letta/agents/types/agents_search_deployed_agents_request_search_item_order_by_value.py +0 -7
  150. letta_client-0.1.6.dist-info/RECORD +0 -193
  151. /letta/agents/{memory/messages → core_memory}/__init__.py +0 -0
  152. /letta/{agents/memory_blocks → providers}/__init__.py +0 -0
  153. {letta_client-0.1.6.dist-info → letta_client-0.1.9.dist-info}/WHEEL +0 -0
letta/agents/client.py CHANGED
@@ -5,14 +5,15 @@ from ..core.client_wrapper import SyncClientWrapper
5
5
  from .context.client import ContextClient
6
6
  from .tools.client import ToolsClient
7
7
  from .sources.client import SourcesClient
8
- from .memory.client import MemoryClient
9
- from .memory_blocks.client import MemoryBlocksClient
8
+ from .core_memory.client import CoreMemoryClient
10
9
  from .recall_memory.client import RecallMemoryClient
11
10
  from .archival_memory.client import ArchivalMemoryClient
12
11
  from .messages.client import MessagesClient
12
+ from .templates.client import TemplatesClient
13
+ from .memory_variables.client import MemoryVariablesClient
13
14
  from ..core.request_options import RequestOptions
14
15
  from ..types.agent_state import AgentState
15
- from ..core.pydantic_utilities import parse_obj_as
16
+ from ..core.unchecked_base_model import construct_type
16
17
  from ..errors.unprocessable_entity_error import UnprocessableEntityError
17
18
  from ..types.http_validation_error import HttpValidationError
18
19
  from json.decoder import JSONDecodeError
@@ -26,25 +27,18 @@ from ..types.message_create import MessageCreate
26
27
  from ..core.serialization import convert_and_respect_annotation_metadata
27
28
  from ..core.jsonable_encoder import jsonable_encoder
28
29
  from .types.update_agent_tool_rules_item import UpdateAgentToolRulesItem
29
- from ..types.block import Block
30
- from ..types.job import Job
31
- from .types.agents_search_deployed_agents_request_search_item import AgentsSearchDeployedAgentsRequestSearchItem
32
- from .types.agents_search_deployed_agents_request_combinator import AgentsSearchDeployedAgentsRequestCombinator
33
- from ..errors.not_found_error import NotFoundError
34
- from ..errors.internal_server_error import InternalServerError
35
- from .types.agents_migrate_response import AgentsMigrateResponse
36
- from ..errors.conflict_error import ConflictError
37
- from ..types.conflict_error_body import ConflictErrorBody
38
- from .types.agents_get_agent_variables_response import AgentsGetAgentVariablesResponse
30
+ from .types.agents_search_request_search_item import AgentsSearchRequestSearchItem
31
+ from .types.agents_search_request_combinator import AgentsSearchRequestCombinator
39
32
  from ..core.client_wrapper import AsyncClientWrapper
40
33
  from .context.client import AsyncContextClient
41
34
  from .tools.client import AsyncToolsClient
42
35
  from .sources.client import AsyncSourcesClient
43
- from .memory.client import AsyncMemoryClient
44
- from .memory_blocks.client import AsyncMemoryBlocksClient
36
+ from .core_memory.client import AsyncCoreMemoryClient
45
37
  from .recall_memory.client import AsyncRecallMemoryClient
46
38
  from .archival_memory.client import AsyncArchivalMemoryClient
47
39
  from .messages.client import AsyncMessagesClient
40
+ from .templates.client import AsyncTemplatesClient
41
+ from .memory_variables.client import AsyncMemoryVariablesClient
48
42
 
49
43
  # this is used as the default value for optional parameters
50
44
  OMIT = typing.cast(typing.Any, ...)
@@ -56,11 +50,12 @@ class AgentsClient:
56
50
  self.context = ContextClient(client_wrapper=self._client_wrapper)
57
51
  self.tools = ToolsClient(client_wrapper=self._client_wrapper)
58
52
  self.sources = SourcesClient(client_wrapper=self._client_wrapper)
59
- self.memory = MemoryClient(client_wrapper=self._client_wrapper)
60
- self.memory_blocks = MemoryBlocksClient(client_wrapper=self._client_wrapper)
53
+ self.core_memory = CoreMemoryClient(client_wrapper=self._client_wrapper)
61
54
  self.recall_memory = RecallMemoryClient(client_wrapper=self._client_wrapper)
62
55
  self.archival_memory = ArchivalMemoryClient(client_wrapper=self._client_wrapper)
63
56
  self.messages = MessagesClient(client_wrapper=self._client_wrapper)
57
+ self.templates = TemplatesClient(client_wrapper=self._client_wrapper)
58
+ self.memory_variables = MemoryVariablesClient(client_wrapper=self._client_wrapper)
64
59
 
65
60
  def list(
66
61
  self,
@@ -126,7 +121,7 @@ class AgentsClient:
126
121
  if 200 <= _response.status_code < 300:
127
122
  return typing.cast(
128
123
  typing.List[AgentState],
129
- parse_obj_as(
124
+ construct_type(
130
125
  type_=typing.List[AgentState], # type: ignore
131
126
  object_=_response.json(),
132
127
  ),
@@ -135,7 +130,7 @@ class AgentsClient:
135
130
  raise UnprocessableEntityError(
136
131
  typing.cast(
137
132
  HttpValidationError,
138
- parse_obj_as(
133
+ construct_type(
139
134
  type_=HttpValidationError, # type: ignore
140
135
  object_=_response.json(),
141
136
  ),
@@ -172,7 +167,7 @@ class AgentsClient:
172
167
  from_template: typing.Optional[str] = OMIT,
173
168
  project_id: typing.Optional[str] = OMIT,
174
169
  tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
175
- user_id: typing.Optional[str] = OMIT,
170
+ variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
176
171
  request_options: typing.Optional[RequestOptions] = None,
177
172
  ) -> AgentState:
178
173
  """
@@ -249,7 +244,8 @@ class AgentsClient:
249
244
  tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
250
245
  The environment variables for tool execution specific to this agent.
251
246
 
252
- user_id : typing.Optional[str]
247
+ variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
248
+ The variables that should be set for the agent.
253
249
 
254
250
  request_options : typing.Optional[RequestOptions]
255
251
  Request-specific configuration.
@@ -312,7 +308,7 @@ class AgentsClient:
312
308
  "from_template": from_template,
313
309
  "project_id": project_id,
314
310
  "tool_exec_environment_variables": tool_exec_environment_variables,
315
- "user_id": user_id,
311
+ "variables": variables,
316
312
  },
317
313
  headers={
318
314
  "content-type": "application/json",
@@ -324,7 +320,7 @@ class AgentsClient:
324
320
  if 200 <= _response.status_code < 300:
325
321
  return typing.cast(
326
322
  AgentState,
327
- parse_obj_as(
323
+ construct_type(
328
324
  type_=AgentState, # type: ignore
329
325
  object_=_response.json(),
330
326
  ),
@@ -333,7 +329,7 @@ class AgentsClient:
333
329
  raise UnprocessableEntityError(
334
330
  typing.cast(
335
331
  HttpValidationError,
336
- parse_obj_as(
332
+ construct_type(
337
333
  type_=HttpValidationError, # type: ignore
338
334
  object_=_response.json(),
339
335
  ),
@@ -380,7 +376,7 @@ class AgentsClient:
380
376
  if 200 <= _response.status_code < 300:
381
377
  return typing.cast(
382
378
  AgentState,
383
- parse_obj_as(
379
+ construct_type(
384
380
  type_=AgentState, # type: ignore
385
381
  object_=_response.json(),
386
382
  ),
@@ -389,7 +385,7 @@ class AgentsClient:
389
385
  raise UnprocessableEntityError(
390
386
  typing.cast(
391
387
  HttpValidationError,
392
- parse_obj_as(
388
+ construct_type(
393
389
  type_=HttpValidationError, # type: ignore
394
390
  object_=_response.json(),
395
391
  ),
@@ -438,7 +434,7 @@ class AgentsClient:
438
434
  if 200 <= _response.status_code < 300:
439
435
  return typing.cast(
440
436
  typing.Optional[typing.Any],
441
- parse_obj_as(
437
+ construct_type(
442
438
  type_=typing.Optional[typing.Any], # type: ignore
443
439
  object_=_response.json(),
444
440
  ),
@@ -447,7 +443,7 @@ class AgentsClient:
447
443
  raise UnprocessableEntityError(
448
444
  typing.cast(
449
445
  HttpValidationError,
450
- parse_obj_as(
446
+ construct_type(
451
447
  type_=HttpValidationError, # type: ignore
452
448
  object_=_response.json(),
453
449
  ),
@@ -576,7 +572,7 @@ class AgentsClient:
576
572
  if 200 <= _response.status_code < 300:
577
573
  return typing.cast(
578
574
  AgentState,
579
- parse_obj_as(
575
+ construct_type(
580
576
  type_=AgentState, # type: ignore
581
577
  object_=_response.json(),
582
578
  ),
@@ -585,68 +581,7 @@ class AgentsClient:
585
581
  raise UnprocessableEntityError(
586
582
  typing.cast(
587
583
  HttpValidationError,
588
- parse_obj_as(
589
- type_=HttpValidationError, # type: ignore
590
- object_=_response.json(),
591
- ),
592
- )
593
- )
594
- _response_json = _response.json()
595
- except JSONDecodeError:
596
- raise ApiError(status_code=_response.status_code, body=_response.text)
597
- raise ApiError(status_code=_response.status_code, body=_response_json)
598
-
599
- def get_agent_memory_block(
600
- self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
601
- ) -> Block:
602
- """
603
- Retrieve a memory block from an agent.
604
-
605
- Parameters
606
- ----------
607
- agent_id : str
608
-
609
- block_label : str
610
-
611
- request_options : typing.Optional[RequestOptions]
612
- Request-specific configuration.
613
-
614
- Returns
615
- -------
616
- Block
617
- Successful Response
618
-
619
- Examples
620
- --------
621
- from letta import Letta
622
-
623
- client = Letta(
624
- token="YOUR_TOKEN",
625
- )
626
- client.agents.get_agent_memory_block(
627
- agent_id="agent_id",
628
- block_label="block_label",
629
- )
630
- """
631
- _response = self._client_wrapper.httpx_client.request(
632
- f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
633
- method="GET",
634
- request_options=request_options,
635
- )
636
- try:
637
- if 200 <= _response.status_code < 300:
638
- return typing.cast(
639
- Block,
640
- parse_obj_as(
641
- type_=Block, # type: ignore
642
- object_=_response.json(),
643
- ),
644
- )
645
- if _response.status_code == 422:
646
- raise UnprocessableEntityError(
647
- typing.cast(
648
- HttpValidationError,
649
- parse_obj_as(
584
+ construct_type(
650
585
  type_=HttpValidationError, # type: ignore
651
586
  object_=_response.json(),
652
587
  ),
@@ -657,57 +592,39 @@ class AgentsClient:
657
592
  raise ApiError(status_code=_response.status_code, body=_response.text)
658
593
  raise ApiError(status_code=_response.status_code, body=_response_json)
659
594
 
660
- def update_agent_memory_block_by_label(
595
+ def search(
661
596
  self,
662
- agent_id: str,
663
- block_label: str,
664
597
  *,
665
- value: typing.Optional[str] = OMIT,
666
- limit: typing.Optional[int] = OMIT,
667
- name: typing.Optional[str] = OMIT,
668
- is_template: typing.Optional[bool] = OMIT,
669
- label: typing.Optional[str] = OMIT,
670
- description: typing.Optional[str] = OMIT,
671
- metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
598
+ search: typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]] = OMIT,
599
+ project_id: typing.Optional[str] = OMIT,
600
+ combinator: typing.Optional[AgentsSearchRequestCombinator] = OMIT,
601
+ limit: typing.Optional[float] = OMIT,
602
+ offset: typing.Optional[float] = OMIT,
672
603
  request_options: typing.Optional[RequestOptions] = None,
673
- ) -> Block:
604
+ ) -> None:
674
605
  """
675
- Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
606
+ <Note>This endpoint is only available on Letta Cloud.</Note>
607
+
608
+ Search deployed agents.
676
609
 
677
610
  Parameters
678
611
  ----------
679
- agent_id : str
680
-
681
- block_label : str
682
-
683
- value : typing.Optional[str]
684
- Value of the block.
685
-
686
- limit : typing.Optional[int]
687
- Character limit of the block.
688
-
689
- name : typing.Optional[str]
690
- Name of the block if it is a template.
612
+ search : typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]]
691
613
 
692
- is_template : typing.Optional[bool]
693
- Whether the block is a template (e.g. saved human/persona options).
614
+ project_id : typing.Optional[str]
694
615
 
695
- label : typing.Optional[str]
696
- Label of the block (e.g. 'human', 'persona') in the context window.
616
+ combinator : typing.Optional[AgentsSearchRequestCombinator]
697
617
 
698
- description : typing.Optional[str]
699
- Description of the block.
618
+ limit : typing.Optional[float]
700
619
 
701
- metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
702
- Metadata of the block.
620
+ offset : typing.Optional[float]
703
621
 
704
622
  request_options : typing.Optional[RequestOptions]
705
623
  Request-specific configuration.
706
624
 
707
625
  Returns
708
626
  -------
709
- Block
710
- Successful Response
627
+ None
711
628
 
712
629
  Examples
713
630
  --------
@@ -716,178 +633,122 @@ class AgentsClient:
716
633
  client = Letta(
717
634
  token="YOUR_TOKEN",
718
635
  )
719
- client.agents.update_agent_memory_block_by_label(
720
- agent_id="agent_id",
721
- block_label="block_label",
722
- )
636
+ client.agents.search()
723
637
  """
724
638
  _response = self._client_wrapper.httpx_client.request(
725
- f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
726
- method="PATCH",
639
+ "v1/agents/search",
640
+ method="POST",
727
641
  json={
728
- "value": value,
642
+ "search": convert_and_respect_annotation_metadata(
643
+ object_=search, annotation=typing.Sequence[AgentsSearchRequestSearchItem], direction="write"
644
+ ),
645
+ "project_id": project_id,
646
+ "combinator": combinator,
729
647
  "limit": limit,
730
- "name": name,
731
- "is_template": is_template,
732
- "label": label,
733
- "description": description,
734
- "metadata_": metadata,
648
+ "offset": offset,
649
+ },
650
+ headers={
651
+ "content-type": "application/json",
735
652
  },
736
653
  request_options=request_options,
737
654
  omit=OMIT,
738
655
  )
739
656
  try:
740
657
  if 200 <= _response.status_code < 300:
741
- return typing.cast(
742
- Block,
743
- parse_obj_as(
744
- type_=Block, # type: ignore
745
- object_=_response.json(),
746
- ),
747
- )
748
- if _response.status_code == 422:
749
- raise UnprocessableEntityError(
750
- typing.cast(
751
- HttpValidationError,
752
- parse_obj_as(
753
- type_=HttpValidationError, # type: ignore
754
- object_=_response.json(),
755
- ),
756
- )
757
- )
658
+ return
758
659
  _response_json = _response.json()
759
660
  except JSONDecodeError:
760
661
  raise ApiError(status_code=_response.status_code, body=_response.text)
761
662
  raise ApiError(status_code=_response.status_code, body=_response_json)
762
663
 
763
- def get_agent_memory_blocks(
764
- self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
765
- ) -> typing.List[Block]:
766
- """
767
- Retrieve the memory blocks of a specific agent.
768
-
769
- Parameters
770
- ----------
771
- agent_id : str
772
-
773
- request_options : typing.Optional[RequestOptions]
774
- Request-specific configuration.
775
-
776
- Returns
777
- -------
778
- typing.List[Block]
779
- Successful Response
780
-
781
- Examples
782
- --------
783
- from letta import Letta
784
664
 
785
- client = Letta(
786
- token="YOUR_TOKEN",
787
- )
788
- client.agents.get_agent_memory_blocks(
789
- agent_id="agent_id",
790
- )
791
- """
792
- _response = self._client_wrapper.httpx_client.request(
793
- f"v1/agents/{jsonable_encoder(agent_id)}/memory/block",
794
- method="GET",
795
- request_options=request_options,
796
- )
797
- try:
798
- if 200 <= _response.status_code < 300:
799
- return typing.cast(
800
- typing.List[Block],
801
- parse_obj_as(
802
- type_=typing.List[Block], # type: ignore
803
- object_=_response.json(),
804
- ),
805
- )
806
- if _response.status_code == 422:
807
- raise UnprocessableEntityError(
808
- typing.cast(
809
- HttpValidationError,
810
- parse_obj_as(
811
- type_=HttpValidationError, # type: ignore
812
- object_=_response.json(),
813
- ),
814
- )
815
- )
816
- _response_json = _response.json()
817
- except JSONDecodeError:
818
- raise ApiError(status_code=_response.status_code, body=_response.text)
819
- raise ApiError(status_code=_response.status_code, body=_response_json)
665
+ class AsyncAgentsClient:
666
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
667
+ self._client_wrapper = client_wrapper
668
+ self.context = AsyncContextClient(client_wrapper=self._client_wrapper)
669
+ self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
670
+ self.sources = AsyncSourcesClient(client_wrapper=self._client_wrapper)
671
+ self.core_memory = AsyncCoreMemoryClient(client_wrapper=self._client_wrapper)
672
+ self.recall_memory = AsyncRecallMemoryClient(client_wrapper=self._client_wrapper)
673
+ self.archival_memory = AsyncArchivalMemoryClient(client_wrapper=self._client_wrapper)
674
+ self.messages = AsyncMessagesClient(client_wrapper=self._client_wrapper)
675
+ self.templates = AsyncTemplatesClient(client_wrapper=self._client_wrapper)
676
+ self.memory_variables = AsyncMemoryVariablesClient(client_wrapper=self._client_wrapper)
820
677
 
821
- def create_agent_message_async(
678
+ async def list(
822
679
  self,
823
- agent_id: str,
824
680
  *,
825
- messages: typing.Sequence[MessageCreate],
826
- assistant_message_tool_name: typing.Optional[str] = OMIT,
827
- assistant_message_tool_kwarg: typing.Optional[str] = OMIT,
681
+ name: typing.Optional[str] = None,
682
+ tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
683
+ match_all_tags: typing.Optional[bool] = None,
684
+ cursor: typing.Optional[int] = None,
685
+ limit: typing.Optional[int] = None,
828
686
  request_options: typing.Optional[RequestOptions] = None,
829
- ) -> Job:
687
+ ) -> typing.List[AgentState]:
830
688
  """
831
- Asynchronously process a user message and return a job ID.
832
- The actual processing happens in the background, and the status can be checked using the job ID.
689
+ List all agents associated with a given user.
690
+ This endpoint retrieves a list of all agents and their configurations associated with the specified user ID.
833
691
 
834
692
  Parameters
835
693
  ----------
836
- agent_id : str
694
+ name : typing.Optional[str]
695
+ Name of the agent
696
+
697
+ tags : typing.Optional[typing.Union[str, typing.Sequence[str]]]
698
+ List of tags to filter agents by
837
699
 
838
- messages : typing.Sequence[MessageCreate]
839
- The messages to be sent to the agent.
700
+ match_all_tags : typing.Optional[bool]
701
+ If True, only returns agents that match ALL given tags. Otherwise, return agents that have ANY of the passed in tags.
840
702
 
841
- assistant_message_tool_name : typing.Optional[str]
842
- The name of the designated message tool.
703
+ cursor : typing.Optional[int]
704
+ Cursor for pagination
843
705
 
844
- assistant_message_tool_kwarg : typing.Optional[str]
845
- The name of the message argument in the designated message tool.
706
+ limit : typing.Optional[int]
707
+ Limit for pagination
846
708
 
847
709
  request_options : typing.Optional[RequestOptions]
848
710
  Request-specific configuration.
849
711
 
850
712
  Returns
851
713
  -------
852
- Job
714
+ typing.List[AgentState]
853
715
  Successful Response
854
716
 
855
717
  Examples
856
718
  --------
857
- from letta import Letta, MessageCreate
719
+ import asyncio
858
720
 
859
- client = Letta(
721
+ from letta import AsyncLetta
722
+
723
+ client = AsyncLetta(
860
724
  token="YOUR_TOKEN",
861
725
  )
862
- client.agents.create_agent_message_async(
863
- agent_id="agent_id",
864
- messages=[
865
- MessageCreate(
866
- role="user",
867
- text="text",
868
- )
869
- ],
870
- )
726
+
727
+
728
+ async def main() -> None:
729
+ await client.agents.list()
730
+
731
+
732
+ asyncio.run(main())
871
733
  """
872
- _response = self._client_wrapper.httpx_client.request(
873
- f"v1/agents/{jsonable_encoder(agent_id)}/messages/async",
874
- method="POST",
875
- json={
876
- "messages": convert_and_respect_annotation_metadata(
877
- object_=messages, annotation=typing.Sequence[MessageCreate], direction="write"
878
- ),
879
- "assistant_message_tool_name": assistant_message_tool_name,
880
- "assistant_message_tool_kwarg": assistant_message_tool_kwarg,
734
+ _response = await self._client_wrapper.httpx_client.request(
735
+ "v1/agents/",
736
+ method="GET",
737
+ params={
738
+ "name": name,
739
+ "tags": tags,
740
+ "match_all_tags": match_all_tags,
741
+ "cursor": cursor,
742
+ "limit": limit,
881
743
  },
882
744
  request_options=request_options,
883
- omit=OMIT,
884
745
  )
885
746
  try:
886
747
  if 200 <= _response.status_code < 300:
887
748
  return typing.cast(
888
- Job,
889
- parse_obj_as(
890
- type_=Job, # type: ignore
749
+ typing.List[AgentState],
750
+ construct_type(
751
+ type_=typing.List[AgentState], # type: ignore
891
752
  object_=_response.json(),
892
753
  ),
893
754
  )
@@ -895,7 +756,7 @@ class AgentsClient:
895
756
  raise UnprocessableEntityError(
896
757
  typing.cast(
897
758
  HttpValidationError,
898
- parse_obj_as(
759
+ construct_type(
899
760
  type_=HttpValidationError, # type: ignore
900
761
  object_=_response.json(),
901
762
  ),
@@ -906,1262 +767,125 @@ class AgentsClient:
906
767
  raise ApiError(status_code=_response.status_code, body=_response.text)
907
768
  raise ApiError(status_code=_response.status_code, body=_response_json)
908
769
 
909
- def searchdeployedagents(
770
+ async def create(
910
771
  self,
911
772
  *,
912
- search: typing.Optional[typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem]] = OMIT,
773
+ memory_blocks: typing.Sequence[CreateBlock],
774
+ name: typing.Optional[str] = OMIT,
775
+ tools: typing.Optional[typing.Sequence[str]] = OMIT,
776
+ tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
777
+ source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
778
+ block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
779
+ tool_rules: typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]] = OMIT,
780
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
781
+ system: typing.Optional[str] = OMIT,
782
+ agent_type: typing.Optional[AgentType] = OMIT,
783
+ llm_config: typing.Optional[LlmConfig] = OMIT,
784
+ embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
785
+ initial_message_sequence: typing.Optional[typing.Sequence[MessageCreate]] = OMIT,
786
+ include_base_tools: typing.Optional[bool] = OMIT,
787
+ description: typing.Optional[str] = OMIT,
788
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
789
+ llm: typing.Optional[str] = OMIT,
790
+ embedding: typing.Optional[str] = OMIT,
791
+ context_window_limit: typing.Optional[int] = OMIT,
792
+ embedding_chunk_size: typing.Optional[int] = OMIT,
793
+ from_template: typing.Optional[str] = OMIT,
913
794
  project_id: typing.Optional[str] = OMIT,
914
- combinator: typing.Optional[AgentsSearchDeployedAgentsRequestCombinator] = OMIT,
915
- limit: typing.Optional[float] = OMIT,
916
- offset: typing.Optional[float] = OMIT,
795
+ tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
796
+ variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
917
797
  request_options: typing.Optional[RequestOptions] = None,
918
- ) -> None:
798
+ ) -> AgentState:
919
799
  """
920
- Search deployed agents
800
+ Create a new agent with the specified configuration.
921
801
 
922
802
  Parameters
923
803
  ----------
924
- search : typing.Optional[typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem]]
925
-
926
- project_id : typing.Optional[str]
804
+ memory_blocks : typing.Sequence[CreateBlock]
805
+ The blocks to create in the agent's in-context memory.
927
806
 
928
- combinator : typing.Optional[AgentsSearchDeployedAgentsRequestCombinator]
807
+ name : typing.Optional[str]
808
+ The name of the agent.
929
809
 
930
- limit : typing.Optional[float]
810
+ tools : typing.Optional[typing.Sequence[str]]
811
+ The tools used by the agent.
931
812
 
932
- offset : typing.Optional[float]
813
+ tool_ids : typing.Optional[typing.Sequence[str]]
814
+ The ids of the tools used by the agent.
933
815
 
934
- request_options : typing.Optional[RequestOptions]
935
- Request-specific configuration.
816
+ source_ids : typing.Optional[typing.Sequence[str]]
817
+ The ids of the sources used by the agent.
936
818
 
937
- Returns
938
- -------
939
- None
940
-
941
- Examples
942
- --------
943
- from letta import Letta
944
-
945
- client = Letta(
946
- token="YOUR_TOKEN",
947
- )
948
- client.agents.searchdeployedagents()
949
- """
950
- _response = self._client_wrapper.httpx_client.request(
951
- "v1/agents/search",
952
- method="POST",
953
- json={
954
- "search": convert_and_respect_annotation_metadata(
955
- object_=search,
956
- annotation=typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem],
957
- direction="write",
958
- ),
959
- "project_id": project_id,
960
- "combinator": combinator,
961
- "limit": limit,
962
- "offset": offset,
963
- },
964
- headers={
965
- "content-type": "application/json",
966
- },
967
- request_options=request_options,
968
- omit=OMIT,
969
- )
970
- try:
971
- if 200 <= _response.status_code < 300:
972
- return
973
- _response_json = _response.json()
974
- except JSONDecodeError:
975
- raise ApiError(status_code=_response.status_code, body=_response.text)
976
- raise ApiError(status_code=_response.status_code, body=_response_json)
977
-
978
- def create_version(
979
- self,
980
- agent_id: str,
981
- *,
982
- return_agent_state: typing.Optional[bool] = None,
983
- migrate_deployed_agents: typing.Optional[bool] = OMIT,
984
- request_options: typing.Optional[RequestOptions] = None,
985
- ) -> None:
986
- """
987
- Creates a versioned version of an agent
988
-
989
- Parameters
990
- ----------
991
- agent_id : str
992
- The agent ID of the agent to migrate, if this agent is not a template, it will create a agent template from the agent provided as well
993
-
994
- return_agent_state : typing.Optional[bool]
995
-
996
- migrate_deployed_agents : typing.Optional[bool]
997
-
998
- request_options : typing.Optional[RequestOptions]
999
- Request-specific configuration.
1000
-
1001
- Returns
1002
- -------
1003
- None
1004
-
1005
- Examples
1006
- --------
1007
- from letta import Letta
1008
-
1009
- client = Letta(
1010
- token="YOUR_TOKEN",
1011
- )
1012
- client.agents.create_version(
1013
- agent_id="agent_id",
1014
- )
1015
- """
1016
- _response = self._client_wrapper.httpx_client.request(
1017
- f"v1/agents/{jsonable_encoder(agent_id)}/version-template",
1018
- method="POST",
1019
- params={
1020
- "returnAgentState": return_agent_state,
1021
- },
1022
- json={
1023
- "migrate_deployed_agents": migrate_deployed_agents,
1024
- },
1025
- headers={
1026
- "content-type": "application/json",
1027
- },
1028
- request_options=request_options,
1029
- omit=OMIT,
1030
- )
1031
- try:
1032
- if 200 <= _response.status_code < 300:
1033
- return
1034
- if _response.status_code == 404:
1035
- raise NotFoundError(
1036
- typing.cast(
1037
- typing.Optional[typing.Any],
1038
- parse_obj_as(
1039
- type_=typing.Optional[typing.Any], # type: ignore
1040
- object_=_response.json(),
1041
- ),
1042
- )
1043
- )
1044
- if _response.status_code == 500:
1045
- raise InternalServerError(
1046
- typing.cast(
1047
- typing.Optional[typing.Any],
1048
- parse_obj_as(
1049
- type_=typing.Optional[typing.Any], # type: ignore
1050
- object_=_response.json(),
1051
- ),
1052
- )
1053
- )
1054
- _response_json = _response.json()
1055
- except JSONDecodeError:
1056
- raise ApiError(status_code=_response.status_code, body=_response.text)
1057
- raise ApiError(status_code=_response.status_code, body=_response_json)
1058
-
1059
- def migrate(
1060
- self,
1061
- agent_id: str,
1062
- *,
1063
- to_template: str,
1064
- preserve_core_memories: bool,
1065
- variables: typing.Optional[typing.Dict[str, str]] = OMIT,
1066
- request_options: typing.Optional[RequestOptions] = None,
1067
- ) -> AgentsMigrateResponse:
1068
- """
1069
- Migrate an agent to a new versioned agent template
1070
-
1071
- Parameters
1072
- ----------
1073
- agent_id : str
1074
-
1075
- to_template : str
1076
-
1077
- preserve_core_memories : bool
1078
-
1079
- variables : typing.Optional[typing.Dict[str, str]]
1080
- If you chose to not preserve core memories, you should provide the new variables for the core memories
1081
-
1082
- request_options : typing.Optional[RequestOptions]
1083
- Request-specific configuration.
1084
-
1085
- Returns
1086
- -------
1087
- AgentsMigrateResponse
1088
- 200
1089
-
1090
- Examples
1091
- --------
1092
- from letta import Letta
1093
-
1094
- client = Letta(
1095
- token="YOUR_TOKEN",
1096
- )
1097
- client.agents.migrate(
1098
- agent_id="agent_id",
1099
- to_template="to_template",
1100
- preserve_core_memories=True,
1101
- )
1102
- """
1103
- _response = self._client_wrapper.httpx_client.request(
1104
- f"v1/agents/{jsonable_encoder(agent_id)}/migrate",
1105
- method="POST",
1106
- json={
1107
- "to_template": to_template,
1108
- "variables": variables,
1109
- "preserve_core_memories": preserve_core_memories,
1110
- },
1111
- headers={
1112
- "content-type": "application/json",
1113
- },
1114
- request_options=request_options,
1115
- omit=OMIT,
1116
- )
1117
- try:
1118
- if 200 <= _response.status_code < 300:
1119
- return typing.cast(
1120
- AgentsMigrateResponse,
1121
- parse_obj_as(
1122
- type_=AgentsMigrateResponse, # type: ignore
1123
- object_=_response.json(),
1124
- ),
1125
- )
1126
- if _response.status_code == 404:
1127
- raise NotFoundError(
1128
- typing.cast(
1129
- typing.Optional[typing.Any],
1130
- parse_obj_as(
1131
- type_=typing.Optional[typing.Any], # type: ignore
1132
- object_=_response.json(),
1133
- ),
1134
- )
1135
- )
1136
- if _response.status_code == 409:
1137
- raise ConflictError(
1138
- typing.cast(
1139
- ConflictErrorBody,
1140
- parse_obj_as(
1141
- type_=ConflictErrorBody, # type: ignore
1142
- object_=_response.json(),
1143
- ),
1144
- )
1145
- )
1146
- if _response.status_code == 500:
1147
- raise InternalServerError(
1148
- typing.cast(
1149
- typing.Optional[typing.Any],
1150
- parse_obj_as(
1151
- type_=typing.Optional[typing.Any], # type: ignore
1152
- object_=_response.json(),
1153
- ),
1154
- )
1155
- )
1156
- _response_json = _response.json()
1157
- except JSONDecodeError:
1158
- raise ApiError(status_code=_response.status_code, body=_response.text)
1159
- raise ApiError(status_code=_response.status_code, body=_response_json)
1160
-
1161
- def createtemplatefromagent(
1162
- self,
1163
- agent_id: str,
1164
- *,
1165
- project_id: typing.Optional[str] = OMIT,
1166
- request_options: typing.Optional[RequestOptions] = None,
1167
- ) -> None:
1168
- """
1169
- Create a template from an agent
1170
-
1171
- Parameters
1172
- ----------
1173
- agent_id : str
1174
-
1175
- project_id : typing.Optional[str]
1176
-
1177
- request_options : typing.Optional[RequestOptions]
1178
- Request-specific configuration.
1179
-
1180
- Returns
1181
- -------
1182
- None
1183
-
1184
- Examples
1185
- --------
1186
- from letta import Letta
1187
-
1188
- client = Letta(
1189
- token="YOUR_TOKEN",
1190
- )
1191
- client.agents.createtemplatefromagent(
1192
- agent_id="agent_id",
1193
- )
1194
- """
1195
- _response = self._client_wrapper.httpx_client.request(
1196
- f"v1/agents/{jsonable_encoder(agent_id)}/template",
1197
- method="POST",
1198
- json={
1199
- "project_id": project_id,
1200
- },
1201
- headers={
1202
- "content-type": "application/json",
1203
- },
1204
- request_options=request_options,
1205
- omit=OMIT,
1206
- )
1207
- try:
1208
- if 200 <= _response.status_code < 300:
1209
- return
1210
- if _response.status_code == 404:
1211
- raise NotFoundError(
1212
- typing.cast(
1213
- typing.Optional[typing.Any],
1214
- parse_obj_as(
1215
- type_=typing.Optional[typing.Any], # type: ignore
1216
- object_=_response.json(),
1217
- ),
1218
- )
1219
- )
1220
- if _response.status_code == 500:
1221
- raise InternalServerError(
1222
- typing.cast(
1223
- typing.Optional[typing.Any],
1224
- parse_obj_as(
1225
- type_=typing.Optional[typing.Any], # type: ignore
1226
- object_=_response.json(),
1227
- ),
1228
- )
1229
- )
1230
- _response_json = _response.json()
1231
- except JSONDecodeError:
1232
- raise ApiError(status_code=_response.status_code, body=_response.text)
1233
- raise ApiError(status_code=_response.status_code, body=_response_json)
1234
-
1235
- def getagentvariables(
1236
- self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
1237
- ) -> AgentsGetAgentVariablesResponse:
1238
- """
1239
- Get the variables associated with an agent
1240
-
1241
- Parameters
1242
- ----------
1243
- agent_id : str
1244
-
1245
- request_options : typing.Optional[RequestOptions]
1246
- Request-specific configuration.
1247
-
1248
- Returns
1249
- -------
1250
- AgentsGetAgentVariablesResponse
1251
- 200
1252
-
1253
- Examples
1254
- --------
1255
- from letta import Letta
1256
-
1257
- client = Letta(
1258
- token="YOUR_TOKEN",
1259
- )
1260
- client.agents.getagentvariables(
1261
- agent_id="agent_id",
1262
- )
1263
- """
1264
- _response = self._client_wrapper.httpx_client.request(
1265
- f"v1/agents/{jsonable_encoder(agent_id)}/variables",
1266
- method="GET",
1267
- request_options=request_options,
1268
- )
1269
- try:
1270
- if 200 <= _response.status_code < 300:
1271
- return typing.cast(
1272
- AgentsGetAgentVariablesResponse,
1273
- parse_obj_as(
1274
- type_=AgentsGetAgentVariablesResponse, # type: ignore
1275
- object_=_response.json(),
1276
- ),
1277
- )
1278
- if _response.status_code == 404:
1279
- raise NotFoundError(
1280
- typing.cast(
1281
- typing.Optional[typing.Any],
1282
- parse_obj_as(
1283
- type_=typing.Optional[typing.Any], # type: ignore
1284
- object_=_response.json(),
1285
- ),
1286
- )
1287
- )
1288
- _response_json = _response.json()
1289
- except JSONDecodeError:
1290
- raise ApiError(status_code=_response.status_code, body=_response.text)
1291
- raise ApiError(status_code=_response.status_code, body=_response_json)
1292
-
1293
-
1294
- class AsyncAgentsClient:
1295
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
1296
- self._client_wrapper = client_wrapper
1297
- self.context = AsyncContextClient(client_wrapper=self._client_wrapper)
1298
- self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
1299
- self.sources = AsyncSourcesClient(client_wrapper=self._client_wrapper)
1300
- self.memory = AsyncMemoryClient(client_wrapper=self._client_wrapper)
1301
- self.memory_blocks = AsyncMemoryBlocksClient(client_wrapper=self._client_wrapper)
1302
- self.recall_memory = AsyncRecallMemoryClient(client_wrapper=self._client_wrapper)
1303
- self.archival_memory = AsyncArchivalMemoryClient(client_wrapper=self._client_wrapper)
1304
- self.messages = AsyncMessagesClient(client_wrapper=self._client_wrapper)
1305
-
1306
- async def list(
1307
- self,
1308
- *,
1309
- name: typing.Optional[str] = None,
1310
- tags: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
1311
- match_all_tags: typing.Optional[bool] = None,
1312
- cursor: typing.Optional[int] = None,
1313
- limit: typing.Optional[int] = None,
1314
- request_options: typing.Optional[RequestOptions] = None,
1315
- ) -> typing.List[AgentState]:
1316
- """
1317
- List all agents associated with a given user.
1318
- This endpoint retrieves a list of all agents and their configurations associated with the specified user ID.
1319
-
1320
- Parameters
1321
- ----------
1322
- name : typing.Optional[str]
1323
- Name of the agent
1324
-
1325
- tags : typing.Optional[typing.Union[str, typing.Sequence[str]]]
1326
- List of tags to filter agents by
1327
-
1328
- match_all_tags : typing.Optional[bool]
1329
- If True, only returns agents that match ALL given tags. Otherwise, return agents that have ANY of the passed in tags.
1330
-
1331
- cursor : typing.Optional[int]
1332
- Cursor for pagination
1333
-
1334
- limit : typing.Optional[int]
1335
- Limit for pagination
1336
-
1337
- request_options : typing.Optional[RequestOptions]
1338
- Request-specific configuration.
1339
-
1340
- Returns
1341
- -------
1342
- typing.List[AgentState]
1343
- Successful Response
1344
-
1345
- Examples
1346
- --------
1347
- import asyncio
1348
-
1349
- from letta import AsyncLetta
1350
-
1351
- client = AsyncLetta(
1352
- token="YOUR_TOKEN",
1353
- )
1354
-
1355
-
1356
- async def main() -> None:
1357
- await client.agents.list()
1358
-
1359
-
1360
- asyncio.run(main())
1361
- """
1362
- _response = await self._client_wrapper.httpx_client.request(
1363
- "v1/agents/",
1364
- method="GET",
1365
- params={
1366
- "name": name,
1367
- "tags": tags,
1368
- "match_all_tags": match_all_tags,
1369
- "cursor": cursor,
1370
- "limit": limit,
1371
- },
1372
- request_options=request_options,
1373
- )
1374
- try:
1375
- if 200 <= _response.status_code < 300:
1376
- return typing.cast(
1377
- typing.List[AgentState],
1378
- parse_obj_as(
1379
- type_=typing.List[AgentState], # type: ignore
1380
- object_=_response.json(),
1381
- ),
1382
- )
1383
- if _response.status_code == 422:
1384
- raise UnprocessableEntityError(
1385
- typing.cast(
1386
- HttpValidationError,
1387
- parse_obj_as(
1388
- type_=HttpValidationError, # type: ignore
1389
- object_=_response.json(),
1390
- ),
1391
- )
1392
- )
1393
- _response_json = _response.json()
1394
- except JSONDecodeError:
1395
- raise ApiError(status_code=_response.status_code, body=_response.text)
1396
- raise ApiError(status_code=_response.status_code, body=_response_json)
1397
-
1398
- async def create(
1399
- self,
1400
- *,
1401
- memory_blocks: typing.Sequence[CreateBlock],
1402
- name: typing.Optional[str] = OMIT,
1403
- tools: typing.Optional[typing.Sequence[str]] = OMIT,
1404
- tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1405
- source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1406
- block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1407
- tool_rules: typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]] = OMIT,
1408
- tags: typing.Optional[typing.Sequence[str]] = OMIT,
1409
- system: typing.Optional[str] = OMIT,
1410
- agent_type: typing.Optional[AgentType] = OMIT,
1411
- llm_config: typing.Optional[LlmConfig] = OMIT,
1412
- embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
1413
- initial_message_sequence: typing.Optional[typing.Sequence[MessageCreate]] = OMIT,
1414
- include_base_tools: typing.Optional[bool] = OMIT,
1415
- description: typing.Optional[str] = OMIT,
1416
- metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1417
- llm: typing.Optional[str] = OMIT,
1418
- embedding: typing.Optional[str] = OMIT,
1419
- context_window_limit: typing.Optional[int] = OMIT,
1420
- embedding_chunk_size: typing.Optional[int] = OMIT,
1421
- from_template: typing.Optional[str] = OMIT,
1422
- project_id: typing.Optional[str] = OMIT,
1423
- tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
1424
- user_id: typing.Optional[str] = OMIT,
1425
- request_options: typing.Optional[RequestOptions] = None,
1426
- ) -> AgentState:
1427
- """
1428
- Create a new agent with the specified configuration.
1429
-
1430
- Parameters
1431
- ----------
1432
- memory_blocks : typing.Sequence[CreateBlock]
1433
- The blocks to create in the agent's in-context memory.
1434
-
1435
- name : typing.Optional[str]
1436
- The name of the agent.
1437
-
1438
- tools : typing.Optional[typing.Sequence[str]]
1439
- The tools used by the agent.
1440
-
1441
- tool_ids : typing.Optional[typing.Sequence[str]]
1442
- The ids of the tools used by the agent.
1443
-
1444
- source_ids : typing.Optional[typing.Sequence[str]]
1445
- The ids of the sources used by the agent.
1446
-
1447
- block_ids : typing.Optional[typing.Sequence[str]]
1448
- The ids of the blocks used by the agent.
1449
-
1450
- tool_rules : typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]]
1451
- The tool rules governing the agent.
1452
-
1453
- tags : typing.Optional[typing.Sequence[str]]
1454
- The tags associated with the agent.
1455
-
1456
- system : typing.Optional[str]
1457
- The system prompt used by the agent.
1458
-
1459
- agent_type : typing.Optional[AgentType]
1460
- The type of agent.
1461
-
1462
- llm_config : typing.Optional[LlmConfig]
1463
- The LLM configuration used by the agent.
1464
-
1465
- embedding_config : typing.Optional[EmbeddingConfig]
1466
- The embedding configuration used by the agent.
1467
-
1468
- initial_message_sequence : typing.Optional[typing.Sequence[MessageCreate]]
1469
- The initial set of messages to put in the agent's in-context memory.
1470
-
1471
- include_base_tools : typing.Optional[bool]
1472
- The LLM configuration used by the agent.
1473
-
1474
- description : typing.Optional[str]
1475
- The description of the agent.
1476
-
1477
- metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1478
- The metadata of the agent.
1479
-
1480
- llm : typing.Optional[str]
1481
- The LLM configuration handle used by the agent, specified in the format provider/model-name, as an alternative to specifying llm_config.
1482
-
1483
- embedding : typing.Optional[str]
1484
- The embedding configuration handle used by the agent, specified in the format provider/model-name.
1485
-
1486
- context_window_limit : typing.Optional[int]
1487
- The context window limit used by the agent.
1488
-
1489
- embedding_chunk_size : typing.Optional[int]
1490
- The embedding chunk size used by the agent.
1491
-
1492
- from_template : typing.Optional[str]
1493
- The template id used to configure the agent
1494
-
1495
- project_id : typing.Optional[str]
1496
- The project id that the agent will be associated with.
1497
-
1498
- tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
1499
- The environment variables for tool execution specific to this agent.
1500
-
1501
- user_id : typing.Optional[str]
1502
-
1503
- request_options : typing.Optional[RequestOptions]
1504
- Request-specific configuration.
1505
-
1506
- Returns
1507
- -------
1508
- AgentState
1509
- Successful Response
1510
-
1511
- Examples
1512
- --------
1513
- import asyncio
1514
-
1515
- from letta import AsyncLetta, CreateBlock
1516
-
1517
- client = AsyncLetta(
1518
- token="YOUR_TOKEN",
1519
- )
1520
-
1521
-
1522
- async def main() -> None:
1523
- await client.agents.create(
1524
- memory_blocks=[
1525
- CreateBlock(
1526
- value="value",
1527
- label="label",
1528
- )
1529
- ],
1530
- )
1531
-
1532
-
1533
- asyncio.run(main())
1534
- """
1535
- _response = await self._client_wrapper.httpx_client.request(
1536
- "v1/agents/",
1537
- method="POST",
1538
- json={
1539
- "name": name,
1540
- "memory_blocks": convert_and_respect_annotation_metadata(
1541
- object_=memory_blocks, annotation=typing.Sequence[CreateBlock], direction="write"
1542
- ),
1543
- "tools": tools,
1544
- "tool_ids": tool_ids,
1545
- "source_ids": source_ids,
1546
- "block_ids": block_ids,
1547
- "tool_rules": convert_and_respect_annotation_metadata(
1548
- object_=tool_rules, annotation=typing.Sequence[CreateAgentRequestToolRulesItem], direction="write"
1549
- ),
1550
- "tags": tags,
1551
- "system": system,
1552
- "agent_type": agent_type,
1553
- "llm_config": convert_and_respect_annotation_metadata(
1554
- object_=llm_config, annotation=LlmConfig, direction="write"
1555
- ),
1556
- "embedding_config": convert_and_respect_annotation_metadata(
1557
- object_=embedding_config, annotation=EmbeddingConfig, direction="write"
1558
- ),
1559
- "initial_message_sequence": convert_and_respect_annotation_metadata(
1560
- object_=initial_message_sequence, annotation=typing.Sequence[MessageCreate], direction="write"
1561
- ),
1562
- "include_base_tools": include_base_tools,
1563
- "description": description,
1564
- "metadata_": metadata,
1565
- "llm": llm,
1566
- "embedding": embedding,
1567
- "context_window_limit": context_window_limit,
1568
- "embedding_chunk_size": embedding_chunk_size,
1569
- "from_template": from_template,
1570
- "project_id": project_id,
1571
- "tool_exec_environment_variables": tool_exec_environment_variables,
1572
- "user_id": user_id,
1573
- },
1574
- headers={
1575
- "content-type": "application/json",
1576
- },
1577
- request_options=request_options,
1578
- omit=OMIT,
1579
- )
1580
- try:
1581
- if 200 <= _response.status_code < 300:
1582
- return typing.cast(
1583
- AgentState,
1584
- parse_obj_as(
1585
- type_=AgentState, # type: ignore
1586
- object_=_response.json(),
1587
- ),
1588
- )
1589
- if _response.status_code == 422:
1590
- raise UnprocessableEntityError(
1591
- typing.cast(
1592
- HttpValidationError,
1593
- parse_obj_as(
1594
- type_=HttpValidationError, # type: ignore
1595
- object_=_response.json(),
1596
- ),
1597
- )
1598
- )
1599
- _response_json = _response.json()
1600
- except JSONDecodeError:
1601
- raise ApiError(status_code=_response.status_code, body=_response.text)
1602
- raise ApiError(status_code=_response.status_code, body=_response_json)
1603
-
1604
- async def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentState:
1605
- """
1606
- Get the state of the agent.
1607
-
1608
- Parameters
1609
- ----------
1610
- agent_id : str
1611
-
1612
- request_options : typing.Optional[RequestOptions]
1613
- Request-specific configuration.
1614
-
1615
- Returns
1616
- -------
1617
- AgentState
1618
- Successful Response
1619
-
1620
- Examples
1621
- --------
1622
- import asyncio
1623
-
1624
- from letta import AsyncLetta
1625
-
1626
- client = AsyncLetta(
1627
- token="YOUR_TOKEN",
1628
- )
1629
-
1630
-
1631
- async def main() -> None:
1632
- await client.agents.get(
1633
- agent_id="agent_id",
1634
- )
1635
-
1636
-
1637
- asyncio.run(main())
1638
- """
1639
- _response = await self._client_wrapper.httpx_client.request(
1640
- f"v1/agents/{jsonable_encoder(agent_id)}",
1641
- method="GET",
1642
- request_options=request_options,
1643
- )
1644
- try:
1645
- if 200 <= _response.status_code < 300:
1646
- return typing.cast(
1647
- AgentState,
1648
- parse_obj_as(
1649
- type_=AgentState, # type: ignore
1650
- object_=_response.json(),
1651
- ),
1652
- )
1653
- if _response.status_code == 422:
1654
- raise UnprocessableEntityError(
1655
- typing.cast(
1656
- HttpValidationError,
1657
- parse_obj_as(
1658
- type_=HttpValidationError, # type: ignore
1659
- object_=_response.json(),
1660
- ),
1661
- )
1662
- )
1663
- _response_json = _response.json()
1664
- except JSONDecodeError:
1665
- raise ApiError(status_code=_response.status_code, body=_response.text)
1666
- raise ApiError(status_code=_response.status_code, body=_response_json)
1667
-
1668
- async def delete(
1669
- self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
1670
- ) -> typing.Optional[typing.Any]:
1671
- """
1672
- Delete an agent.
1673
-
1674
- Parameters
1675
- ----------
1676
- agent_id : str
1677
-
1678
- request_options : typing.Optional[RequestOptions]
1679
- Request-specific configuration.
1680
-
1681
- Returns
1682
- -------
1683
- typing.Optional[typing.Any]
1684
- Successful Response
1685
-
1686
- Examples
1687
- --------
1688
- import asyncio
1689
-
1690
- from letta import AsyncLetta
1691
-
1692
- client = AsyncLetta(
1693
- token="YOUR_TOKEN",
1694
- )
1695
-
1696
-
1697
- async def main() -> None:
1698
- await client.agents.delete(
1699
- agent_id="agent_id",
1700
- )
1701
-
1702
-
1703
- asyncio.run(main())
1704
- """
1705
- _response = await self._client_wrapper.httpx_client.request(
1706
- f"v1/agents/{jsonable_encoder(agent_id)}",
1707
- method="DELETE",
1708
- request_options=request_options,
1709
- )
1710
- try:
1711
- if 200 <= _response.status_code < 300:
1712
- return typing.cast(
1713
- typing.Optional[typing.Any],
1714
- parse_obj_as(
1715
- type_=typing.Optional[typing.Any], # type: ignore
1716
- object_=_response.json(),
1717
- ),
1718
- )
1719
- if _response.status_code == 422:
1720
- raise UnprocessableEntityError(
1721
- typing.cast(
1722
- HttpValidationError,
1723
- parse_obj_as(
1724
- type_=HttpValidationError, # type: ignore
1725
- object_=_response.json(),
1726
- ),
1727
- )
1728
- )
1729
- _response_json = _response.json()
1730
- except JSONDecodeError:
1731
- raise ApiError(status_code=_response.status_code, body=_response.text)
1732
- raise ApiError(status_code=_response.status_code, body=_response_json)
1733
-
1734
- async def update(
1735
- self,
1736
- agent_id: str,
1737
- *,
1738
- name: typing.Optional[str] = OMIT,
1739
- tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1740
- source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1741
- block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1742
- tags: typing.Optional[typing.Sequence[str]] = OMIT,
1743
- system: typing.Optional[str] = OMIT,
1744
- tool_rules: typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]] = OMIT,
1745
- llm_config: typing.Optional[LlmConfig] = OMIT,
1746
- embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
1747
- message_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1748
- description: typing.Optional[str] = OMIT,
1749
- metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1750
- tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
1751
- request_options: typing.Optional[RequestOptions] = None,
1752
- ) -> AgentState:
1753
- """
1754
- Update an exsiting agent
1755
-
1756
- Parameters
1757
- ----------
1758
- agent_id : str
1759
-
1760
- name : typing.Optional[str]
1761
- The name of the agent.
1762
-
1763
- tool_ids : typing.Optional[typing.Sequence[str]]
1764
- The ids of the tools used by the agent.
1765
-
1766
- source_ids : typing.Optional[typing.Sequence[str]]
1767
- The ids of the sources used by the agent.
1768
-
1769
- block_ids : typing.Optional[typing.Sequence[str]]
1770
- The ids of the blocks used by the agent.
1771
-
1772
- tags : typing.Optional[typing.Sequence[str]]
1773
- The tags associated with the agent.
1774
-
1775
- system : typing.Optional[str]
1776
- The system prompt used by the agent.
1777
-
1778
- tool_rules : typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]]
1779
- The tool rules governing the agent.
1780
-
1781
- llm_config : typing.Optional[LlmConfig]
1782
- The LLM configuration used by the agent.
1783
-
1784
- embedding_config : typing.Optional[EmbeddingConfig]
1785
- The embedding configuration used by the agent.
1786
-
1787
- message_ids : typing.Optional[typing.Sequence[str]]
1788
- The ids of the messages in the agent's in-context memory.
1789
-
1790
- description : typing.Optional[str]
1791
- The description of the agent.
1792
-
1793
- metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1794
- The metadata of the agent.
1795
-
1796
- tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
1797
- The environment variables for tool execution specific to this agent.
1798
-
1799
- request_options : typing.Optional[RequestOptions]
1800
- Request-specific configuration.
1801
-
1802
- Returns
1803
- -------
1804
- AgentState
1805
- Successful Response
1806
-
1807
- Examples
1808
- --------
1809
- import asyncio
1810
-
1811
- from letta import AsyncLetta
1812
-
1813
- client = AsyncLetta(
1814
- token="YOUR_TOKEN",
1815
- )
1816
-
1817
-
1818
- async def main() -> None:
1819
- await client.agents.update(
1820
- agent_id="agent_id",
1821
- )
1822
-
1823
-
1824
- asyncio.run(main())
1825
- """
1826
- _response = await self._client_wrapper.httpx_client.request(
1827
- f"v1/agents/{jsonable_encoder(agent_id)}",
1828
- method="PATCH",
1829
- json={
1830
- "name": name,
1831
- "tool_ids": tool_ids,
1832
- "source_ids": source_ids,
1833
- "block_ids": block_ids,
1834
- "tags": tags,
1835
- "system": system,
1836
- "tool_rules": convert_and_respect_annotation_metadata(
1837
- object_=tool_rules, annotation=typing.Sequence[UpdateAgentToolRulesItem], direction="write"
1838
- ),
1839
- "llm_config": convert_and_respect_annotation_metadata(
1840
- object_=llm_config, annotation=LlmConfig, direction="write"
1841
- ),
1842
- "embedding_config": convert_and_respect_annotation_metadata(
1843
- object_=embedding_config, annotation=EmbeddingConfig, direction="write"
1844
- ),
1845
- "message_ids": message_ids,
1846
- "description": description,
1847
- "metadata_": metadata,
1848
- "tool_exec_environment_variables": tool_exec_environment_variables,
1849
- },
1850
- headers={
1851
- "content-type": "application/json",
1852
- },
1853
- request_options=request_options,
1854
- omit=OMIT,
1855
- )
1856
- try:
1857
- if 200 <= _response.status_code < 300:
1858
- return typing.cast(
1859
- AgentState,
1860
- parse_obj_as(
1861
- type_=AgentState, # type: ignore
1862
- object_=_response.json(),
1863
- ),
1864
- )
1865
- if _response.status_code == 422:
1866
- raise UnprocessableEntityError(
1867
- typing.cast(
1868
- HttpValidationError,
1869
- parse_obj_as(
1870
- type_=HttpValidationError, # type: ignore
1871
- object_=_response.json(),
1872
- ),
1873
- )
1874
- )
1875
- _response_json = _response.json()
1876
- except JSONDecodeError:
1877
- raise ApiError(status_code=_response.status_code, body=_response.text)
1878
- raise ApiError(status_code=_response.status_code, body=_response_json)
1879
-
1880
- async def get_agent_memory_block(
1881
- self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
1882
- ) -> Block:
1883
- """
1884
- Retrieve a memory block from an agent.
1885
-
1886
- Parameters
1887
- ----------
1888
- agent_id : str
1889
-
1890
- block_label : str
1891
-
1892
- request_options : typing.Optional[RequestOptions]
1893
- Request-specific configuration.
1894
-
1895
- Returns
1896
- -------
1897
- Block
1898
- Successful Response
1899
-
1900
- Examples
1901
- --------
1902
- import asyncio
1903
-
1904
- from letta import AsyncLetta
1905
-
1906
- client = AsyncLetta(
1907
- token="YOUR_TOKEN",
1908
- )
1909
-
1910
-
1911
- async def main() -> None:
1912
- await client.agents.get_agent_memory_block(
1913
- agent_id="agent_id",
1914
- block_label="block_label",
1915
- )
1916
-
1917
-
1918
- asyncio.run(main())
1919
- """
1920
- _response = await self._client_wrapper.httpx_client.request(
1921
- f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
1922
- method="GET",
1923
- request_options=request_options,
1924
- )
1925
- try:
1926
- if 200 <= _response.status_code < 300:
1927
- return typing.cast(
1928
- Block,
1929
- parse_obj_as(
1930
- type_=Block, # type: ignore
1931
- object_=_response.json(),
1932
- ),
1933
- )
1934
- if _response.status_code == 422:
1935
- raise UnprocessableEntityError(
1936
- typing.cast(
1937
- HttpValidationError,
1938
- parse_obj_as(
1939
- type_=HttpValidationError, # type: ignore
1940
- object_=_response.json(),
1941
- ),
1942
- )
1943
- )
1944
- _response_json = _response.json()
1945
- except JSONDecodeError:
1946
- raise ApiError(status_code=_response.status_code, body=_response.text)
1947
- raise ApiError(status_code=_response.status_code, body=_response_json)
1948
-
1949
- async def update_agent_memory_block_by_label(
1950
- self,
1951
- agent_id: str,
1952
- block_label: str,
1953
- *,
1954
- value: typing.Optional[str] = OMIT,
1955
- limit: typing.Optional[int] = OMIT,
1956
- name: typing.Optional[str] = OMIT,
1957
- is_template: typing.Optional[bool] = OMIT,
1958
- label: typing.Optional[str] = OMIT,
1959
- description: typing.Optional[str] = OMIT,
1960
- metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1961
- request_options: typing.Optional[RequestOptions] = None,
1962
- ) -> Block:
1963
- """
1964
- Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
819
+ block_ids : typing.Optional[typing.Sequence[str]]
820
+ The ids of the blocks used by the agent.
1965
821
 
1966
- Parameters
1967
- ----------
1968
- agent_id : str
822
+ tool_rules : typing.Optional[typing.Sequence[CreateAgentRequestToolRulesItem]]
823
+ The tool rules governing the agent.
1969
824
 
1970
- block_label : str
825
+ tags : typing.Optional[typing.Sequence[str]]
826
+ The tags associated with the agent.
1971
827
 
1972
- value : typing.Optional[str]
1973
- Value of the block.
828
+ system : typing.Optional[str]
829
+ The system prompt used by the agent.
1974
830
 
1975
- limit : typing.Optional[int]
1976
- Character limit of the block.
831
+ agent_type : typing.Optional[AgentType]
832
+ The type of agent.
1977
833
 
1978
- name : typing.Optional[str]
1979
- Name of the block if it is a template.
834
+ llm_config : typing.Optional[LlmConfig]
835
+ The LLM configuration used by the agent.
836
+
837
+ embedding_config : typing.Optional[EmbeddingConfig]
838
+ The embedding configuration used by the agent.
1980
839
 
1981
- is_template : typing.Optional[bool]
1982
- Whether the block is a template (e.g. saved human/persona options).
840
+ initial_message_sequence : typing.Optional[typing.Sequence[MessageCreate]]
841
+ The initial set of messages to put in the agent's in-context memory.
1983
842
 
1984
- label : typing.Optional[str]
1985
- Label of the block (e.g. 'human', 'persona') in the context window.
843
+ include_base_tools : typing.Optional[bool]
844
+ The LLM configuration used by the agent.
1986
845
 
1987
846
  description : typing.Optional[str]
1988
- Description of the block.
847
+ The description of the agent.
1989
848
 
1990
849
  metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1991
- Metadata of the block.
1992
-
1993
- request_options : typing.Optional[RequestOptions]
1994
- Request-specific configuration.
1995
-
1996
- Returns
1997
- -------
1998
- Block
1999
- Successful Response
2000
-
2001
- Examples
2002
- --------
2003
- import asyncio
2004
-
2005
- from letta import AsyncLetta
2006
-
2007
- client = AsyncLetta(
2008
- token="YOUR_TOKEN",
2009
- )
2010
-
2011
-
2012
- async def main() -> None:
2013
- await client.agents.update_agent_memory_block_by_label(
2014
- agent_id="agent_id",
2015
- block_label="block_label",
2016
- )
2017
-
2018
-
2019
- asyncio.run(main())
2020
- """
2021
- _response = await self._client_wrapper.httpx_client.request(
2022
- f"v1/agents/{jsonable_encoder(agent_id)}/memory/block/{jsonable_encoder(block_label)}",
2023
- method="PATCH",
2024
- json={
2025
- "value": value,
2026
- "limit": limit,
2027
- "name": name,
2028
- "is_template": is_template,
2029
- "label": label,
2030
- "description": description,
2031
- "metadata_": metadata,
2032
- },
2033
- request_options=request_options,
2034
- omit=OMIT,
2035
- )
2036
- try:
2037
- if 200 <= _response.status_code < 300:
2038
- return typing.cast(
2039
- Block,
2040
- parse_obj_as(
2041
- type_=Block, # type: ignore
2042
- object_=_response.json(),
2043
- ),
2044
- )
2045
- if _response.status_code == 422:
2046
- raise UnprocessableEntityError(
2047
- typing.cast(
2048
- HttpValidationError,
2049
- parse_obj_as(
2050
- type_=HttpValidationError, # type: ignore
2051
- object_=_response.json(),
2052
- ),
2053
- )
2054
- )
2055
- _response_json = _response.json()
2056
- except JSONDecodeError:
2057
- raise ApiError(status_code=_response.status_code, body=_response.text)
2058
- raise ApiError(status_code=_response.status_code, body=_response_json)
2059
-
2060
- async def get_agent_memory_blocks(
2061
- self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
2062
- ) -> typing.List[Block]:
2063
- """
2064
- Retrieve the memory blocks of a specific agent.
2065
-
2066
- Parameters
2067
- ----------
2068
- agent_id : str
2069
-
2070
- request_options : typing.Optional[RequestOptions]
2071
- Request-specific configuration.
2072
-
2073
- Returns
2074
- -------
2075
- typing.List[Block]
2076
- Successful Response
2077
-
2078
- Examples
2079
- --------
2080
- import asyncio
2081
-
2082
- from letta import AsyncLetta
2083
-
2084
- client = AsyncLetta(
2085
- token="YOUR_TOKEN",
2086
- )
2087
-
850
+ The metadata of the agent.
2088
851
 
2089
- async def main() -> None:
2090
- await client.agents.get_agent_memory_blocks(
2091
- agent_id="agent_id",
2092
- )
852
+ llm : typing.Optional[str]
853
+ The LLM configuration handle used by the agent, specified in the format provider/model-name, as an alternative to specifying llm_config.
2093
854
 
855
+ embedding : typing.Optional[str]
856
+ The embedding configuration handle used by the agent, specified in the format provider/model-name.
2094
857
 
2095
- asyncio.run(main())
2096
- """
2097
- _response = await self._client_wrapper.httpx_client.request(
2098
- f"v1/agents/{jsonable_encoder(agent_id)}/memory/block",
2099
- method="GET",
2100
- request_options=request_options,
2101
- )
2102
- try:
2103
- if 200 <= _response.status_code < 300:
2104
- return typing.cast(
2105
- typing.List[Block],
2106
- parse_obj_as(
2107
- type_=typing.List[Block], # type: ignore
2108
- object_=_response.json(),
2109
- ),
2110
- )
2111
- if _response.status_code == 422:
2112
- raise UnprocessableEntityError(
2113
- typing.cast(
2114
- HttpValidationError,
2115
- parse_obj_as(
2116
- type_=HttpValidationError, # type: ignore
2117
- object_=_response.json(),
2118
- ),
2119
- )
2120
- )
2121
- _response_json = _response.json()
2122
- except JSONDecodeError:
2123
- raise ApiError(status_code=_response.status_code, body=_response.text)
2124
- raise ApiError(status_code=_response.status_code, body=_response_json)
858
+ context_window_limit : typing.Optional[int]
859
+ The context window limit used by the agent.
2125
860
 
2126
- async def create_agent_message_async(
2127
- self,
2128
- agent_id: str,
2129
- *,
2130
- messages: typing.Sequence[MessageCreate],
2131
- assistant_message_tool_name: typing.Optional[str] = OMIT,
2132
- assistant_message_tool_kwarg: typing.Optional[str] = OMIT,
2133
- request_options: typing.Optional[RequestOptions] = None,
2134
- ) -> Job:
2135
- """
2136
- Asynchronously process a user message and return a job ID.
2137
- The actual processing happens in the background, and the status can be checked using the job ID.
861
+ embedding_chunk_size : typing.Optional[int]
862
+ The embedding chunk size used by the agent.
2138
863
 
2139
- Parameters
2140
- ----------
2141
- agent_id : str
864
+ from_template : typing.Optional[str]
865
+ The template id used to configure the agent
2142
866
 
2143
- messages : typing.Sequence[MessageCreate]
2144
- The messages to be sent to the agent.
867
+ project_id : typing.Optional[str]
868
+ The project id that the agent will be associated with.
2145
869
 
2146
- assistant_message_tool_name : typing.Optional[str]
2147
- The name of the designated message tool.
870
+ tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
871
+ The environment variables for tool execution specific to this agent.
2148
872
 
2149
- assistant_message_tool_kwarg : typing.Optional[str]
2150
- The name of the message argument in the designated message tool.
873
+ variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
874
+ The variables that should be set for the agent.
2151
875
 
2152
876
  request_options : typing.Optional[RequestOptions]
2153
877
  Request-specific configuration.
2154
878
 
2155
879
  Returns
2156
880
  -------
2157
- Job
881
+ AgentState
2158
882
  Successful Response
2159
883
 
2160
884
  Examples
2161
885
  --------
2162
886
  import asyncio
2163
887
 
2164
- from letta import AsyncLetta, MessageCreate
888
+ from letta import AsyncLetta, CreateBlock
2165
889
 
2166
890
  client = AsyncLetta(
2167
891
  token="YOUR_TOKEN",
@@ -2169,12 +893,11 @@ class AsyncAgentsClient:
2169
893
 
2170
894
 
2171
895
  async def main() -> None:
2172
- await client.agents.create_agent_message_async(
2173
- agent_id="agent_id",
2174
- messages=[
2175
- MessageCreate(
2176
- role="user",
2177
- text="text",
896
+ await client.agents.create(
897
+ memory_blocks=[
898
+ CreateBlock(
899
+ value="value",
900
+ label="label",
2178
901
  )
2179
902
  ],
2180
903
  )
@@ -2183,104 +906,43 @@ class AsyncAgentsClient:
2183
906
  asyncio.run(main())
2184
907
  """
2185
908
  _response = await self._client_wrapper.httpx_client.request(
2186
- f"v1/agents/{jsonable_encoder(agent_id)}/messages/async",
909
+ "v1/agents/",
2187
910
  method="POST",
2188
911
  json={
2189
- "messages": convert_and_respect_annotation_metadata(
2190
- object_=messages, annotation=typing.Sequence[MessageCreate], direction="write"
912
+ "name": name,
913
+ "memory_blocks": convert_and_respect_annotation_metadata(
914
+ object_=memory_blocks, annotation=typing.Sequence[CreateBlock], direction="write"
2191
915
  ),
2192
- "assistant_message_tool_name": assistant_message_tool_name,
2193
- "assistant_message_tool_kwarg": assistant_message_tool_kwarg,
2194
- },
2195
- request_options=request_options,
2196
- omit=OMIT,
2197
- )
2198
- try:
2199
- if 200 <= _response.status_code < 300:
2200
- return typing.cast(
2201
- Job,
2202
- parse_obj_as(
2203
- type_=Job, # type: ignore
2204
- object_=_response.json(),
2205
- ),
2206
- )
2207
- if _response.status_code == 422:
2208
- raise UnprocessableEntityError(
2209
- typing.cast(
2210
- HttpValidationError,
2211
- parse_obj_as(
2212
- type_=HttpValidationError, # type: ignore
2213
- object_=_response.json(),
2214
- ),
2215
- )
2216
- )
2217
- _response_json = _response.json()
2218
- except JSONDecodeError:
2219
- raise ApiError(status_code=_response.status_code, body=_response.text)
2220
- raise ApiError(status_code=_response.status_code, body=_response_json)
2221
-
2222
- async def searchdeployedagents(
2223
- self,
2224
- *,
2225
- search: typing.Optional[typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem]] = OMIT,
2226
- project_id: typing.Optional[str] = OMIT,
2227
- combinator: typing.Optional[AgentsSearchDeployedAgentsRequestCombinator] = OMIT,
2228
- limit: typing.Optional[float] = OMIT,
2229
- offset: typing.Optional[float] = OMIT,
2230
- request_options: typing.Optional[RequestOptions] = None,
2231
- ) -> None:
2232
- """
2233
- Search deployed agents
2234
-
2235
- Parameters
2236
- ----------
2237
- search : typing.Optional[typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem]]
2238
-
2239
- project_id : typing.Optional[str]
2240
-
2241
- combinator : typing.Optional[AgentsSearchDeployedAgentsRequestCombinator]
2242
-
2243
- limit : typing.Optional[float]
2244
-
2245
- offset : typing.Optional[float]
2246
-
2247
- request_options : typing.Optional[RequestOptions]
2248
- Request-specific configuration.
2249
-
2250
- Returns
2251
- -------
2252
- None
2253
-
2254
- Examples
2255
- --------
2256
- import asyncio
2257
-
2258
- from letta import AsyncLetta
2259
-
2260
- client = AsyncLetta(
2261
- token="YOUR_TOKEN",
2262
- )
2263
-
2264
-
2265
- async def main() -> None:
2266
- await client.agents.searchdeployedagents()
2267
-
2268
-
2269
- asyncio.run(main())
2270
- """
2271
- _response = await self._client_wrapper.httpx_client.request(
2272
- "v1/agents/search",
2273
- method="POST",
2274
- json={
2275
- "search": convert_and_respect_annotation_metadata(
2276
- object_=search,
2277
- annotation=typing.Sequence[AgentsSearchDeployedAgentsRequestSearchItem],
2278
- direction="write",
916
+ "tools": tools,
917
+ "tool_ids": tool_ids,
918
+ "source_ids": source_ids,
919
+ "block_ids": block_ids,
920
+ "tool_rules": convert_and_respect_annotation_metadata(
921
+ object_=tool_rules, annotation=typing.Sequence[CreateAgentRequestToolRulesItem], direction="write"
922
+ ),
923
+ "tags": tags,
924
+ "system": system,
925
+ "agent_type": agent_type,
926
+ "llm_config": convert_and_respect_annotation_metadata(
927
+ object_=llm_config, annotation=LlmConfig, direction="write"
2279
928
  ),
929
+ "embedding_config": convert_and_respect_annotation_metadata(
930
+ object_=embedding_config, annotation=EmbeddingConfig, direction="write"
931
+ ),
932
+ "initial_message_sequence": convert_and_respect_annotation_metadata(
933
+ object_=initial_message_sequence, annotation=typing.Sequence[MessageCreate], direction="write"
934
+ ),
935
+ "include_base_tools": include_base_tools,
936
+ "description": description,
937
+ "metadata_": metadata,
938
+ "llm": llm,
939
+ "embedding": embedding,
940
+ "context_window_limit": context_window_limit,
941
+ "embedding_chunk_size": embedding_chunk_size,
942
+ "from_template": from_template,
2280
943
  "project_id": project_id,
2281
- "combinator": combinator,
2282
- "limit": limit,
2283
- "offset": offset,
944
+ "tool_exec_environment_variables": tool_exec_environment_variables,
945
+ "variables": variables,
2284
946
  },
2285
947
  headers={
2286
948
  "content-type": "application/json",
@@ -2290,38 +952,43 @@ class AsyncAgentsClient:
2290
952
  )
2291
953
  try:
2292
954
  if 200 <= _response.status_code < 300:
2293
- return
955
+ return typing.cast(
956
+ AgentState,
957
+ construct_type(
958
+ type_=AgentState, # type: ignore
959
+ object_=_response.json(),
960
+ ),
961
+ )
962
+ if _response.status_code == 422:
963
+ raise UnprocessableEntityError(
964
+ typing.cast(
965
+ HttpValidationError,
966
+ construct_type(
967
+ type_=HttpValidationError, # type: ignore
968
+ object_=_response.json(),
969
+ ),
970
+ )
971
+ )
2294
972
  _response_json = _response.json()
2295
973
  except JSONDecodeError:
2296
974
  raise ApiError(status_code=_response.status_code, body=_response.text)
2297
975
  raise ApiError(status_code=_response.status_code, body=_response_json)
2298
976
 
2299
- async def create_version(
2300
- self,
2301
- agent_id: str,
2302
- *,
2303
- return_agent_state: typing.Optional[bool] = None,
2304
- migrate_deployed_agents: typing.Optional[bool] = OMIT,
2305
- request_options: typing.Optional[RequestOptions] = None,
2306
- ) -> None:
977
+ async def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> AgentState:
2307
978
  """
2308
- Creates a versioned version of an agent
979
+ Get the state of the agent.
2309
980
 
2310
981
  Parameters
2311
982
  ----------
2312
983
  agent_id : str
2313
- The agent ID of the agent to migrate, if this agent is not a template, it will create a agent template from the agent provided as well
2314
-
2315
- return_agent_state : typing.Optional[bool]
2316
-
2317
- migrate_deployed_agents : typing.Optional[bool]
2318
984
 
2319
985
  request_options : typing.Optional[RequestOptions]
2320
986
  Request-specific configuration.
2321
987
 
2322
988
  Returns
2323
989
  -------
2324
- None
990
+ AgentState
991
+ Successful Response
2325
992
 
2326
993
  Examples
2327
994
  --------
@@ -2335,7 +1002,7 @@ class AsyncAgentsClient:
2335
1002
 
2336
1003
 
2337
1004
  async def main() -> None:
2338
- await client.agents.create_version(
1005
+ await client.agents.get(
2339
1006
  agent_id="agent_id",
2340
1007
  )
2341
1008
 
@@ -2343,39 +1010,25 @@ class AsyncAgentsClient:
2343
1010
  asyncio.run(main())
2344
1011
  """
2345
1012
  _response = await self._client_wrapper.httpx_client.request(
2346
- f"v1/agents/{jsonable_encoder(agent_id)}/version-template",
2347
- method="POST",
2348
- params={
2349
- "returnAgentState": return_agent_state,
2350
- },
2351
- json={
2352
- "migrate_deployed_agents": migrate_deployed_agents,
2353
- },
2354
- headers={
2355
- "content-type": "application/json",
2356
- },
1013
+ f"v1/agents/{jsonable_encoder(agent_id)}",
1014
+ method="GET",
2357
1015
  request_options=request_options,
2358
- omit=OMIT,
2359
1016
  )
2360
1017
  try:
2361
1018
  if 200 <= _response.status_code < 300:
2362
- return
2363
- if _response.status_code == 404:
2364
- raise NotFoundError(
2365
- typing.cast(
2366
- typing.Optional[typing.Any],
2367
- parse_obj_as(
2368
- type_=typing.Optional[typing.Any], # type: ignore
2369
- object_=_response.json(),
2370
- ),
2371
- )
1019
+ return typing.cast(
1020
+ AgentState,
1021
+ construct_type(
1022
+ type_=AgentState, # type: ignore
1023
+ object_=_response.json(),
1024
+ ),
2372
1025
  )
2373
- if _response.status_code == 500:
2374
- raise InternalServerError(
1026
+ if _response.status_code == 422:
1027
+ raise UnprocessableEntityError(
2375
1028
  typing.cast(
2376
- typing.Optional[typing.Any],
2377
- parse_obj_as(
2378
- type_=typing.Optional[typing.Any], # type: ignore
1029
+ HttpValidationError,
1030
+ construct_type(
1031
+ type_=HttpValidationError, # type: ignore
2379
1032
  object_=_response.json(),
2380
1033
  ),
2381
1034
  )
@@ -2385,36 +1038,23 @@ class AsyncAgentsClient:
2385
1038
  raise ApiError(status_code=_response.status_code, body=_response.text)
2386
1039
  raise ApiError(status_code=_response.status_code, body=_response_json)
2387
1040
 
2388
- async def migrate(
2389
- self,
2390
- agent_id: str,
2391
- *,
2392
- to_template: str,
2393
- preserve_core_memories: bool,
2394
- variables: typing.Optional[typing.Dict[str, str]] = OMIT,
2395
- request_options: typing.Optional[RequestOptions] = None,
2396
- ) -> AgentsMigrateResponse:
1041
+ async def delete(
1042
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
1043
+ ) -> typing.Optional[typing.Any]:
2397
1044
  """
2398
- Migrate an agent to a new versioned agent template
1045
+ Delete an agent.
2399
1046
 
2400
1047
  Parameters
2401
1048
  ----------
2402
1049
  agent_id : str
2403
1050
 
2404
- to_template : str
2405
-
2406
- preserve_core_memories : bool
2407
-
2408
- variables : typing.Optional[typing.Dict[str, str]]
2409
- If you chose to not preserve core memories, you should provide the new variables for the core memories
2410
-
2411
1051
  request_options : typing.Optional[RequestOptions]
2412
1052
  Request-specific configuration.
2413
1053
 
2414
1054
  Returns
2415
1055
  -------
2416
- AgentsMigrateResponse
2417
- 200
1056
+ typing.Optional[typing.Any]
1057
+ Successful Response
2418
1058
 
2419
1059
  Examples
2420
1060
  --------
@@ -2428,64 +1068,33 @@ class AsyncAgentsClient:
2428
1068
 
2429
1069
 
2430
1070
  async def main() -> None:
2431
- await client.agents.migrate(
1071
+ await client.agents.delete(
2432
1072
  agent_id="agent_id",
2433
- to_template="to_template",
2434
- preserve_core_memories=True,
2435
1073
  )
2436
1074
 
2437
1075
 
2438
1076
  asyncio.run(main())
2439
1077
  """
2440
1078
  _response = await self._client_wrapper.httpx_client.request(
2441
- f"v1/agents/{jsonable_encoder(agent_id)}/migrate",
2442
- method="POST",
2443
- json={
2444
- "to_template": to_template,
2445
- "variables": variables,
2446
- "preserve_core_memories": preserve_core_memories,
2447
- },
2448
- headers={
2449
- "content-type": "application/json",
2450
- },
1079
+ f"v1/agents/{jsonable_encoder(agent_id)}",
1080
+ method="DELETE",
2451
1081
  request_options=request_options,
2452
- omit=OMIT,
2453
1082
  )
2454
1083
  try:
2455
1084
  if 200 <= _response.status_code < 300:
2456
1085
  return typing.cast(
2457
- AgentsMigrateResponse,
2458
- parse_obj_as(
2459
- type_=AgentsMigrateResponse, # type: ignore
1086
+ typing.Optional[typing.Any],
1087
+ construct_type(
1088
+ type_=typing.Optional[typing.Any], # type: ignore
2460
1089
  object_=_response.json(),
2461
1090
  ),
2462
1091
  )
2463
- if _response.status_code == 404:
2464
- raise NotFoundError(
2465
- typing.cast(
2466
- typing.Optional[typing.Any],
2467
- parse_obj_as(
2468
- type_=typing.Optional[typing.Any], # type: ignore
2469
- object_=_response.json(),
2470
- ),
2471
- )
2472
- )
2473
- if _response.status_code == 409:
2474
- raise ConflictError(
2475
- typing.cast(
2476
- ConflictErrorBody,
2477
- parse_obj_as(
2478
- type_=ConflictErrorBody, # type: ignore
2479
- object_=_response.json(),
2480
- ),
2481
- )
2482
- )
2483
- if _response.status_code == 500:
2484
- raise InternalServerError(
1092
+ if _response.status_code == 422:
1093
+ raise UnprocessableEntityError(
2485
1094
  typing.cast(
2486
- typing.Optional[typing.Any],
2487
- parse_obj_as(
2488
- type_=typing.Optional[typing.Any], # type: ignore
1095
+ HttpValidationError,
1096
+ construct_type(
1097
+ type_=HttpValidationError, # type: ignore
2489
1098
  object_=_response.json(),
2490
1099
  ),
2491
1100
  )
@@ -2495,28 +1104,78 @@ class AsyncAgentsClient:
2495
1104
  raise ApiError(status_code=_response.status_code, body=_response.text)
2496
1105
  raise ApiError(status_code=_response.status_code, body=_response_json)
2497
1106
 
2498
- async def createtemplatefromagent(
1107
+ async def update(
2499
1108
  self,
2500
1109
  agent_id: str,
2501
1110
  *,
2502
- project_id: typing.Optional[str] = OMIT,
1111
+ name: typing.Optional[str] = OMIT,
1112
+ tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1113
+ source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1114
+ block_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1115
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
1116
+ system: typing.Optional[str] = OMIT,
1117
+ tool_rules: typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]] = OMIT,
1118
+ llm_config: typing.Optional[LlmConfig] = OMIT,
1119
+ embedding_config: typing.Optional[EmbeddingConfig] = OMIT,
1120
+ message_ids: typing.Optional[typing.Sequence[str]] = OMIT,
1121
+ description: typing.Optional[str] = OMIT,
1122
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
1123
+ tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
2503
1124
  request_options: typing.Optional[RequestOptions] = None,
2504
- ) -> None:
1125
+ ) -> AgentState:
2505
1126
  """
2506
- Create a template from an agent
1127
+ Update an exsiting agent
2507
1128
 
2508
1129
  Parameters
2509
1130
  ----------
2510
1131
  agent_id : str
2511
1132
 
2512
- project_id : typing.Optional[str]
1133
+ name : typing.Optional[str]
1134
+ The name of the agent.
1135
+
1136
+ tool_ids : typing.Optional[typing.Sequence[str]]
1137
+ The ids of the tools used by the agent.
1138
+
1139
+ source_ids : typing.Optional[typing.Sequence[str]]
1140
+ The ids of the sources used by the agent.
1141
+
1142
+ block_ids : typing.Optional[typing.Sequence[str]]
1143
+ The ids of the blocks used by the agent.
1144
+
1145
+ tags : typing.Optional[typing.Sequence[str]]
1146
+ The tags associated with the agent.
1147
+
1148
+ system : typing.Optional[str]
1149
+ The system prompt used by the agent.
1150
+
1151
+ tool_rules : typing.Optional[typing.Sequence[UpdateAgentToolRulesItem]]
1152
+ The tool rules governing the agent.
1153
+
1154
+ llm_config : typing.Optional[LlmConfig]
1155
+ The LLM configuration used by the agent.
1156
+
1157
+ embedding_config : typing.Optional[EmbeddingConfig]
1158
+ The embedding configuration used by the agent.
1159
+
1160
+ message_ids : typing.Optional[typing.Sequence[str]]
1161
+ The ids of the messages in the agent's in-context memory.
1162
+
1163
+ description : typing.Optional[str]
1164
+ The description of the agent.
1165
+
1166
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
1167
+ The metadata of the agent.
1168
+
1169
+ tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
1170
+ The environment variables for tool execution specific to this agent.
2513
1171
 
2514
1172
  request_options : typing.Optional[RequestOptions]
2515
1173
  Request-specific configuration.
2516
1174
 
2517
1175
  Returns
2518
1176
  -------
2519
- None
1177
+ AgentState
1178
+ Successful Response
2520
1179
 
2521
1180
  Examples
2522
1181
  --------
@@ -2530,7 +1189,7 @@ class AsyncAgentsClient:
2530
1189
 
2531
1190
 
2532
1191
  async def main() -> None:
2533
- await client.agents.createtemplatefromagent(
1192
+ await client.agents.update(
2534
1193
  agent_id="agent_id",
2535
1194
  )
2536
1195
 
@@ -2538,10 +1197,28 @@ class AsyncAgentsClient:
2538
1197
  asyncio.run(main())
2539
1198
  """
2540
1199
  _response = await self._client_wrapper.httpx_client.request(
2541
- f"v1/agents/{jsonable_encoder(agent_id)}/template",
2542
- method="POST",
1200
+ f"v1/agents/{jsonable_encoder(agent_id)}",
1201
+ method="PATCH",
2543
1202
  json={
2544
- "project_id": project_id,
1203
+ "name": name,
1204
+ "tool_ids": tool_ids,
1205
+ "source_ids": source_ids,
1206
+ "block_ids": block_ids,
1207
+ "tags": tags,
1208
+ "system": system,
1209
+ "tool_rules": convert_and_respect_annotation_metadata(
1210
+ object_=tool_rules, annotation=typing.Sequence[UpdateAgentToolRulesItem], direction="write"
1211
+ ),
1212
+ "llm_config": convert_and_respect_annotation_metadata(
1213
+ object_=llm_config, annotation=LlmConfig, direction="write"
1214
+ ),
1215
+ "embedding_config": convert_and_respect_annotation_metadata(
1216
+ object_=embedding_config, annotation=EmbeddingConfig, direction="write"
1217
+ ),
1218
+ "message_ids": message_ids,
1219
+ "description": description,
1220
+ "metadata_": metadata,
1221
+ "tool_exec_environment_variables": tool_exec_environment_variables,
2545
1222
  },
2546
1223
  headers={
2547
1224
  "content-type": "application/json",
@@ -2551,23 +1228,19 @@ class AsyncAgentsClient:
2551
1228
  )
2552
1229
  try:
2553
1230
  if 200 <= _response.status_code < 300:
2554
- return
2555
- if _response.status_code == 404:
2556
- raise NotFoundError(
2557
- typing.cast(
2558
- typing.Optional[typing.Any],
2559
- parse_obj_as(
2560
- type_=typing.Optional[typing.Any], # type: ignore
2561
- object_=_response.json(),
2562
- ),
2563
- )
1231
+ return typing.cast(
1232
+ AgentState,
1233
+ construct_type(
1234
+ type_=AgentState, # type: ignore
1235
+ object_=_response.json(),
1236
+ ),
2564
1237
  )
2565
- if _response.status_code == 500:
2566
- raise InternalServerError(
1238
+ if _response.status_code == 422:
1239
+ raise UnprocessableEntityError(
2567
1240
  typing.cast(
2568
- typing.Optional[typing.Any],
2569
- parse_obj_as(
2570
- type_=typing.Optional[typing.Any], # type: ignore
1241
+ HttpValidationError,
1242
+ construct_type(
1243
+ type_=HttpValidationError, # type: ignore
2571
1244
  object_=_response.json(),
2572
1245
  ),
2573
1246
  )
@@ -2577,23 +1250,39 @@ class AsyncAgentsClient:
2577
1250
  raise ApiError(status_code=_response.status_code, body=_response.text)
2578
1251
  raise ApiError(status_code=_response.status_code, body=_response_json)
2579
1252
 
2580
- async def getagentvariables(
2581
- self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
2582
- ) -> AgentsGetAgentVariablesResponse:
1253
+ async def search(
1254
+ self,
1255
+ *,
1256
+ search: typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]] = OMIT,
1257
+ project_id: typing.Optional[str] = OMIT,
1258
+ combinator: typing.Optional[AgentsSearchRequestCombinator] = OMIT,
1259
+ limit: typing.Optional[float] = OMIT,
1260
+ offset: typing.Optional[float] = OMIT,
1261
+ request_options: typing.Optional[RequestOptions] = None,
1262
+ ) -> None:
2583
1263
  """
2584
- Get the variables associated with an agent
1264
+ <Note>This endpoint is only available on Letta Cloud.</Note>
1265
+
1266
+ Search deployed agents.
2585
1267
 
2586
1268
  Parameters
2587
1269
  ----------
2588
- agent_id : str
1270
+ search : typing.Optional[typing.Sequence[AgentsSearchRequestSearchItem]]
1271
+
1272
+ project_id : typing.Optional[str]
1273
+
1274
+ combinator : typing.Optional[AgentsSearchRequestCombinator]
1275
+
1276
+ limit : typing.Optional[float]
1277
+
1278
+ offset : typing.Optional[float]
2589
1279
 
2590
1280
  request_options : typing.Optional[RequestOptions]
2591
1281
  Request-specific configuration.
2592
1282
 
2593
1283
  Returns
2594
1284
  -------
2595
- AgentsGetAgentVariablesResponse
2596
- 200
1285
+ None
2597
1286
 
2598
1287
  Examples
2599
1288
  --------
@@ -2607,37 +1296,32 @@ class AsyncAgentsClient:
2607
1296
 
2608
1297
 
2609
1298
  async def main() -> None:
2610
- await client.agents.getagentvariables(
2611
- agent_id="agent_id",
2612
- )
1299
+ await client.agents.search()
2613
1300
 
2614
1301
 
2615
1302
  asyncio.run(main())
2616
1303
  """
2617
1304
  _response = await self._client_wrapper.httpx_client.request(
2618
- f"v1/agents/{jsonable_encoder(agent_id)}/variables",
2619
- method="GET",
1305
+ "v1/agents/search",
1306
+ method="POST",
1307
+ json={
1308
+ "search": convert_and_respect_annotation_metadata(
1309
+ object_=search, annotation=typing.Sequence[AgentsSearchRequestSearchItem], direction="write"
1310
+ ),
1311
+ "project_id": project_id,
1312
+ "combinator": combinator,
1313
+ "limit": limit,
1314
+ "offset": offset,
1315
+ },
1316
+ headers={
1317
+ "content-type": "application/json",
1318
+ },
2620
1319
  request_options=request_options,
1320
+ omit=OMIT,
2621
1321
  )
2622
1322
  try:
2623
1323
  if 200 <= _response.status_code < 300:
2624
- return typing.cast(
2625
- AgentsGetAgentVariablesResponse,
2626
- parse_obj_as(
2627
- type_=AgentsGetAgentVariablesResponse, # type: ignore
2628
- object_=_response.json(),
2629
- ),
2630
- )
2631
- if _response.status_code == 404:
2632
- raise NotFoundError(
2633
- typing.cast(
2634
- typing.Optional[typing.Any],
2635
- parse_obj_as(
2636
- type_=typing.Optional[typing.Any], # type: ignore
2637
- object_=_response.json(),
2638
- ),
2639
- )
2640
- )
1324
+ return
2641
1325
  _response_json = _response.json()
2642
1326
  except JSONDecodeError:
2643
1327
  raise ApiError(status_code=_response.status_code, body=_response.text)