letta-client 1.0.0a8__py3-none-any.whl → 1.0.0a10__py3-none-any.whl

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

Potentially problematic release.


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

Files changed (54) hide show
  1. letta_client/_version.py +1 -1
  2. letta_client/pagination.py +174 -1
  3. letta_client/resources/agents/agents.py +396 -396
  4. letta_client/resources/agents/blocks.py +200 -190
  5. letta_client/resources/agents/files.py +13 -10
  6. letta_client/resources/agents/messages.py +367 -367
  7. letta_client/resources/agents/tools.py +6 -6
  8. letta_client/resources/archives.py +121 -111
  9. letta_client/resources/batches/messages.py +14 -11
  10. letta_client/resources/blocks/blocks.py +241 -222
  11. letta_client/resources/folders/folders.py +133 -133
  12. letta_client/resources/groups/groups.py +141 -141
  13. letta_client/resources/groups/messages.py +198 -198
  14. letta_client/resources/identities/blocks.py +7 -7
  15. letta_client/resources/identities/identities.py +141 -141
  16. letta_client/resources/tools.py +794 -194
  17. letta_client/types/__init__.py +11 -8
  18. letta_client/types/{agent_update_params.py → agent_modify_params.py} +2 -2
  19. letta_client/types/agent_state.py +6 -3
  20. letta_client/types/agents/__init__.py +6 -3
  21. letta_client/types/agents/block.py +6 -3
  22. letta_client/types/agents/block_list_response.py +63 -0
  23. letta_client/types/agents/{block_update_params.py → block_modify_params.py} +8 -5
  24. letta_client/types/agents/block_modify_response.py +63 -0
  25. letta_client/types/agents/block_retrieve_response.py +63 -0
  26. letta_client/types/agents/file_list_response.py +3 -14
  27. letta_client/types/agents/{message_update_params.py → message_modify_params.py} +2 -2
  28. letta_client/types/agents/{message_update_response.py → message_modify_response.py} +2 -2
  29. letta_client/types/archive_list_params.py +3 -0
  30. letta_client/types/{archive_update_params.py → archive_modify_params.py} +2 -2
  31. letta_client/types/batches/__init__.py +0 -1
  32. letta_client/types/block_create_params.py +6 -3
  33. letta_client/types/block_create_response.py +63 -0
  34. letta_client/types/block_list_response.py +63 -0
  35. letta_client/types/{block_update_params.py → block_modify_params.py} +8 -5
  36. letta_client/types/block_modify_response.py +63 -0
  37. letta_client/types/block_retrieve_response.py +63 -0
  38. letta_client/types/create_block_param.py +6 -3
  39. letta_client/types/{folder_update_params.py → folder_modify_params.py} +2 -2
  40. letta_client/types/{group_update_params.py → group_modify_params.py} +2 -2
  41. letta_client/types/groups/__init__.py +2 -2
  42. letta_client/types/groups/{message_update_params.py → message_modify_params.py} +2 -2
  43. letta_client/types/groups/{message_update_response.py → message_modify_response.py} +2 -2
  44. letta_client/types/identities/__init__.py +1 -0
  45. letta_client/types/identities/block_list_response.py +63 -0
  46. letta_client/types/{identity_update_params.py → identity_modify_params.py} +2 -2
  47. letta_client/types/tool.py +106 -2
  48. letta_client/types/{tool_update_params.py → tool_modify_params.py} +2 -2
  49. {letta_client-1.0.0a8.dist-info → letta_client-1.0.0a10.dist-info}/METADATA +1 -1
  50. {letta_client-1.0.0a8.dist-info → letta_client-1.0.0a10.dist-info}/RECORD +52 -46
  51. letta_client/types/archive_list_response.py +0 -10
  52. letta_client/types/batches/message_list_response.py +0 -12
  53. {letta_client-1.0.0a8.dist-info → letta_client-1.0.0a10.dist-info}/WHEEL +0 -0
  54. {letta_client-1.0.0a8.dist-info → letta_client-1.0.0a10.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,63 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Dict, Optional
4
+
5
+ from .._models import BaseModel
6
+
7
+ __all__ = ["BlockModifyResponse"]
8
+
9
+
10
+ class BlockModifyResponse(BaseModel):
11
+ value: str
12
+ """Value of the block."""
13
+
14
+ id: Optional[str] = None
15
+ """The human-friendly ID of the Block"""
16
+
17
+ base_template_id: Optional[str] = None
18
+ """(Deprecated) The base template id of the block."""
19
+
20
+ created_by_id: Optional[str] = None
21
+ """The id of the user that made this Block."""
22
+
23
+ deployment_id: Optional[str] = None
24
+ """(Deprecated) The id of the deployment."""
25
+
26
+ description: Optional[str] = None
27
+ """Description of the block."""
28
+
29
+ entity_id: Optional[str] = None
30
+ """(Deprecated) The id of the entity within the template."""
31
+
32
+ hidden: Optional[bool] = None
33
+ """(Deprecated) If set to True, the block will be hidden."""
34
+
35
+ is_template: Optional[bool] = None
36
+ """Whether the block is a template (e.g. saved human/persona options)."""
37
+
38
+ label: Optional[str] = None
39
+ """Label of the block (e.g. 'human', 'persona') in the context window."""
40
+
41
+ last_updated_by_id: Optional[str] = None
42
+ """The id of the user that last updated this Block."""
43
+
44
+ limit: Optional[int] = None
45
+ """Character limit of the block."""
46
+
47
+ metadata: Optional[Dict[str, object]] = None
48
+ """Metadata of the block."""
49
+
50
+ preserve_on_migration: Optional[bool] = None
51
+ """(Deprecated) Preserve the block on template migration."""
52
+
53
+ project_id: Optional[str] = None
54
+ """The associated project id."""
55
+
56
+ read_only: Optional[bool] = None
57
+ """(Deprecated) Whether the agent has read-only access to the block."""
58
+
59
+ template_id: Optional[str] = None
60
+ """(Deprecated) The id of the template."""
61
+
62
+ template_name: Optional[str] = None
63
+ """(Deprecated) The name of the block template (if it is a template)."""
@@ -0,0 +1,63 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Dict, Optional
4
+
5
+ from .._models import BaseModel
6
+
7
+ __all__ = ["BlockRetrieveResponse"]
8
+
9
+
10
+ class BlockRetrieveResponse(BaseModel):
11
+ value: str
12
+ """Value of the block."""
13
+
14
+ id: Optional[str] = None
15
+ """The human-friendly ID of the Block"""
16
+
17
+ base_template_id: Optional[str] = None
18
+ """(Deprecated) The base template id of the block."""
19
+
20
+ created_by_id: Optional[str] = None
21
+ """The id of the user that made this Block."""
22
+
23
+ deployment_id: Optional[str] = None
24
+ """(Deprecated) The id of the deployment."""
25
+
26
+ description: Optional[str] = None
27
+ """Description of the block."""
28
+
29
+ entity_id: Optional[str] = None
30
+ """(Deprecated) The id of the entity within the template."""
31
+
32
+ hidden: Optional[bool] = None
33
+ """(Deprecated) If set to True, the block will be hidden."""
34
+
35
+ is_template: Optional[bool] = None
36
+ """Whether the block is a template (e.g. saved human/persona options)."""
37
+
38
+ label: Optional[str] = None
39
+ """Label of the block (e.g. 'human', 'persona') in the context window."""
40
+
41
+ last_updated_by_id: Optional[str] = None
42
+ """The id of the user that last updated this Block."""
43
+
44
+ limit: Optional[int] = None
45
+ """Character limit of the block."""
46
+
47
+ metadata: Optional[Dict[str, object]] = None
48
+ """Metadata of the block."""
49
+
50
+ preserve_on_migration: Optional[bool] = None
51
+ """(Deprecated) Preserve the block on template migration."""
52
+
53
+ project_id: Optional[str] = None
54
+ """The associated project id."""
55
+
56
+ read_only: Optional[bool] = None
57
+ """(Deprecated) Whether the agent has read-only access to the block."""
58
+
59
+ template_id: Optional[str] = None
60
+ """(Deprecated) The id of the template."""
61
+
62
+ template_name: Optional[str] = None
63
+ """(Deprecated) The name of the block template (if it is a template)."""
@@ -38,9 +38,6 @@ class CreateBlockParam(TypedDict, total=False):
38
38
  metadata: Optional[Dict[str, object]]
39
39
  """Metadata of the block."""
40
40
 
41
- name: Optional[str]
42
- """The id of the template."""
43
-
44
41
  preserve_on_migration: Optional[bool]
45
42
  """Preserve the block on template migration."""
46
43
 
@@ -49,3 +46,9 @@ class CreateBlockParam(TypedDict, total=False):
49
46
 
50
47
  read_only: bool
51
48
  """Whether the agent has read-only access to the block."""
49
+
50
+ template_id: Optional[str]
51
+ """The id of the template."""
52
+
53
+ template_name: Optional[str]
54
+ """Name of the block if it is a template."""
@@ -7,10 +7,10 @@ from typing_extensions import TypedDict
7
7
 
8
8
  from .embedding_config_param import EmbeddingConfigParam
9
9
 
10
- __all__ = ["FolderUpdateParams"]
10
+ __all__ = ["FolderModifyParams"]
11
11
 
12
12
 
13
- class FolderUpdateParams(TypedDict, total=False):
13
+ class FolderModifyParams(TypedDict, total=False):
14
14
  description: Optional[str]
15
15
  """The description of the source."""
16
16
 
@@ -9,7 +9,7 @@ from .._types import SequenceNotStr
9
9
  from .._utils import PropertyInfo
10
10
 
11
11
  __all__ = [
12
- "GroupUpdateParams",
12
+ "GroupModifyParams",
13
13
  "ManagerConfig",
14
14
  "ManagerConfigRoundRobinManagerUpdate",
15
15
  "ManagerConfigSupervisorManagerUpdate",
@@ -19,7 +19,7 @@ __all__ = [
19
19
  ]
20
20
 
21
21
 
22
- class GroupUpdateParams(TypedDict, total=False):
22
+ class GroupModifyParams(TypedDict, total=False):
23
23
  agent_ids: Optional[SequenceNotStr[str]]
24
24
 
25
25
  description: Optional[str]
@@ -4,6 +4,6 @@ from __future__ import annotations
4
4
 
5
5
  from .message_list_params import MessageListParams as MessageListParams
6
6
  from .message_send_params import MessageSendParams as MessageSendParams
7
+ from .message_modify_params import MessageModifyParams as MessageModifyParams
7
8
  from .message_stream_params import MessageStreamParams as MessageStreamParams
8
- from .message_update_params import MessageUpdateParams as MessageUpdateParams
9
- from .message_update_response import MessageUpdateResponse as MessageUpdateResponse
9
+ from .message_modify_response import MessageModifyResponse as MessageModifyResponse
@@ -9,7 +9,7 @@ from ..agents.letta_user_message_content_union_param import LettaUserMessageCont
9
9
  from ..agents.letta_assistant_message_content_union_param import LettaAssistantMessageContentUnionParam
10
10
 
11
11
  __all__ = [
12
- "MessageUpdateParams",
12
+ "MessageModifyParams",
13
13
  "UpdateSystemMessage",
14
14
  "UpdateUserMessage",
15
15
  "UpdateReasoningMessage",
@@ -65,6 +65,6 @@ class UpdateAssistantMessage(TypedDict, total=False):
65
65
  message_type: Literal["assistant_message"]
66
66
 
67
67
 
68
- MessageUpdateParams: TypeAlias = Union[
68
+ MessageModifyParams: TypeAlias = Union[
69
69
  UpdateSystemMessage, UpdateUserMessage, UpdateReasoningMessage, UpdateAssistantMessage
70
70
  ]
@@ -14,9 +14,9 @@ from ..agents.approval_request_message import ApprovalRequestMessage
14
14
  from ..agents.hidden_reasoning_message import HiddenReasoningMessage
15
15
  from ..agents.approval_response_message import ApprovalResponseMessage
16
16
 
17
- __all__ = ["MessageUpdateResponse"]
17
+ __all__ = ["MessageModifyResponse"]
18
18
 
19
- MessageUpdateResponse: TypeAlias = Annotated[
19
+ MessageModifyResponse: TypeAlias = Annotated[
20
20
  Union[
21
21
  SystemMessage,
22
22
  UserMessage,
@@ -4,4 +4,5 @@ from __future__ import annotations
4
4
 
5
5
  from .agent_list_params import AgentListParams as AgentListParams
6
6
  from .block_list_params import BlockListParams as BlockListParams
7
+ from .block_list_response import BlockListResponse as BlockListResponse
7
8
  from .property_upsert_params import PropertyUpsertParams as PropertyUpsertParams
@@ -0,0 +1,63 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Dict, Optional
4
+
5
+ from ..._models import BaseModel
6
+
7
+ __all__ = ["BlockListResponse"]
8
+
9
+
10
+ class BlockListResponse(BaseModel):
11
+ value: str
12
+ """Value of the block."""
13
+
14
+ id: Optional[str] = None
15
+ """The human-friendly ID of the Block"""
16
+
17
+ base_template_id: Optional[str] = None
18
+ """(Deprecated) The base template id of the block."""
19
+
20
+ created_by_id: Optional[str] = None
21
+ """The id of the user that made this Block."""
22
+
23
+ deployment_id: Optional[str] = None
24
+ """(Deprecated) The id of the deployment."""
25
+
26
+ description: Optional[str] = None
27
+ """Description of the block."""
28
+
29
+ entity_id: Optional[str] = None
30
+ """(Deprecated) The id of the entity within the template."""
31
+
32
+ hidden: Optional[bool] = None
33
+ """(Deprecated) If set to True, the block will be hidden."""
34
+
35
+ is_template: Optional[bool] = None
36
+ """Whether the block is a template (e.g. saved human/persona options)."""
37
+
38
+ label: Optional[str] = None
39
+ """Label of the block (e.g. 'human', 'persona') in the context window."""
40
+
41
+ last_updated_by_id: Optional[str] = None
42
+ """The id of the user that last updated this Block."""
43
+
44
+ limit: Optional[int] = None
45
+ """Character limit of the block."""
46
+
47
+ metadata: Optional[Dict[str, object]] = None
48
+ """Metadata of the block."""
49
+
50
+ preserve_on_migration: Optional[bool] = None
51
+ """(Deprecated) Preserve the block on template migration."""
52
+
53
+ project_id: Optional[str] = None
54
+ """The associated project id."""
55
+
56
+ read_only: Optional[bool] = None
57
+ """(Deprecated) Whether the agent has read-only access to the block."""
58
+
59
+ template_id: Optional[str] = None
60
+ """(Deprecated) The id of the template."""
61
+
62
+ template_name: Optional[str] = None
63
+ """(Deprecated) The name of the block template (if it is a template)."""
@@ -9,10 +9,10 @@ from .._types import SequenceNotStr
9
9
  from .identity_type import IdentityType
10
10
  from .identity_property_param import IdentityPropertyParam
11
11
 
12
- __all__ = ["IdentityUpdateParams"]
12
+ __all__ = ["IdentityModifyParams"]
13
13
 
14
14
 
15
- class IdentityUpdateParams(TypedDict, total=False):
15
+ class IdentityModifyParams(TypedDict, total=False):
16
16
  agent_ids: Optional[SequenceNotStr[str]]
17
17
  """The agent ids that are associated with the identity."""
18
18
 
@@ -1,15 +1,19 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  from typing import Dict, List, Optional
4
+ from abc import abstractmethod
5
+ from textwrap import dedent
6
+ import inspect
7
+ import typing
4
8
 
5
- from pydantic import Field as FieldInfo
9
+ from pydantic import Field as FieldInfo, Field, model_validator
6
10
 
7
11
  from .._models import BaseModel
8
12
  from .tool_type import ToolType
9
13
  from .npm_requirement import NpmRequirement
10
14
  from .pip_requirement import PipRequirement
11
15
 
12
- __all__ = ["Tool"]
16
+ __all__ = ["Tool", "BaseTool"]
13
17
 
14
18
 
15
19
  class Tool(BaseModel):
@@ -66,3 +70,103 @@ class Tool(BaseModel):
66
70
 
67
71
  tool_type: Optional[ToolType] = None
68
72
  """The type of the tool."""
73
+
74
+
75
+ class BaseTool(Tool):
76
+ name: Optional[str] = Field(default=None, description="The name of the function.")
77
+ args_schema: typing.Optional[typing.Type[BaseModel]] = Field(default=None, description="The schema for validating the tool's arguments.")
78
+
79
+ @abstractmethod
80
+ def run(self, *args: typing.Any, **kwargs: typing.Any) -> typing.Any:
81
+ """
82
+ Execute the tool with the provided arguments.
83
+
84
+ Parameters
85
+ ----------
86
+ self
87
+ The instance of the tool
88
+ *args
89
+ Positional arguments to pass to the tool.
90
+ **kwargs
91
+ Keyword arguments to pass to the tool.
92
+
93
+ Returns
94
+ -------
95
+ typing.Any
96
+ The result of executing the tool.
97
+ """
98
+ pass
99
+
100
+
101
+ @model_validator(mode="after")
102
+ def no_self_in_run_source(self) -> "BaseTool":
103
+ """
104
+ Validate that the provided implementation does not reference `self` in the
105
+ `run` method implementation.
106
+
107
+ This check is performed after the model is created, so `self` is guaranteed
108
+ to be set.
109
+
110
+ If `self` is found in the source code of the `run` method, a `ValueError` is
111
+ raised with a message pointing to the line and value of the offending code.
112
+ """
113
+ source_code = self.get_source_code()
114
+ if "self." in source_code:
115
+ raise_on_line, line_value = None, None
116
+ for i, line in enumerate(source_code.splitlines()):
117
+ if "self." in line:
118
+ raise_on_line, line_value = i+1, line
119
+ break;
120
+ raise ValueError(
121
+ f"Detected reference to 'self' in line {raise_on_line} of implementation, " +
122
+ f"which is not allowed:\n\n{line_value}\n\n" +
123
+ f"Please pass in the arguments directly to run() instead.")
124
+ return self
125
+
126
+
127
+ def get_source_code(self) -> str:
128
+ """
129
+ Get the source code of the `run` method, which will be executed in an agent step.
130
+
131
+ Returns
132
+ -------
133
+ str
134
+ The source code of the tool.
135
+ """
136
+ source_code = dedent(inspect.getsource(self.run))
137
+
138
+ # replace tool name
139
+ source_code = source_code.replace("def run", f"def {self.name}")
140
+
141
+ # remove self, handling several cases
142
+ source_code_lines = source_code.splitlines()
143
+ if "self" in source_code_lines[0]:
144
+ # def run(self, ...): or def run (self,): or def run(self):
145
+ source_code_lines[0] = source_code_lines[0].replace("self, ", "").replace("self,", "").replace("self", "")
146
+ else:
147
+ maybe_line_to_delete = None
148
+ for i, line in enumerate(source_code_lines):
149
+ if line.strip() == "self" or line.strip() == "self,":
150
+ # def run(
151
+ # self,
152
+ # ...
153
+ # ):
154
+ maybe_line_to_delete = i
155
+ break
156
+ elif line.strip().startswith("self"):
157
+ # def run(
158
+ # self, ...
159
+ # ):
160
+ source_code_lines[i] = line.replace("self, ", "").replace("self,", "").replace("self", "")
161
+ break
162
+ if maybe_line_to_delete is not None:
163
+ del source_code_lines[maybe_line_to_delete]
164
+ if maybe_line_to_delete == 1 and source_code_lines[0].strip()[-1] == "(" and source_code_lines[1].strip()[0] == ")":
165
+ # def run(
166
+ # self
167
+ # ):
168
+ source_code_lines[0] = source_code_lines[0].strip() + source_code_lines[1].strip()
169
+ del source_code_lines[1]
170
+
171
+ source_code = "\n".join(source_code_lines)
172
+ return source_code
@@ -10,10 +10,10 @@ from .._utils import PropertyInfo
10
10
  from .npm_requirement_param import NpmRequirementParam
11
11
  from .pip_requirement_param import PipRequirementParam
12
12
 
13
- __all__ = ["ToolUpdateParams"]
13
+ __all__ = ["ToolModifyParams"]
14
14
 
15
15
 
16
- class ToolUpdateParams(TypedDict, total=False):
16
+ class ToolModifyParams(TypedDict, total=False):
17
17
  args_json_schema: Optional[Dict[str, object]]
18
18
  """The args JSON schema of the function."""
19
19
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: letta-client
3
- Version: 1.0.0a8
3
+ Version: 1.0.0a10
4
4
  Summary: The official Python library for the letta API
5
5
  Project-URL: Homepage, https://github.com/letta-ai/letta-python
6
6
  Project-URL: Repository, https://github.com/letta-ai/letta-python