letta-client 0.1.11__py3-none-any.whl → 0.1.14__py3-none-any.whl

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

Potentially problematic release.


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

letta_client/__init__.py CHANGED
@@ -127,7 +127,7 @@ from .types import (
127
127
  ValidationErrorLocItem,
128
128
  )
129
129
  from .errors import ConflictError, InternalServerError, NotFoundError, UnprocessableEntityError
130
- from . import agents, blocks, health, jobs, models, providers, runs, sources, tools
130
+ from . import agents, blocks, health, jobs, models, providers, runs, sources, tag, tools
131
131
  from .agents import (
132
132
  AgentsSearchRequestCombinator,
133
133
  AgentsSearchRequestSearchItem,
@@ -136,9 +136,11 @@ from .agents import (
136
136
  AgentsSearchRequestSearchItemOrderBy,
137
137
  AgentsSearchRequestSearchItemOrderByDirection,
138
138
  AgentsSearchRequestSearchItemOrderByValue,
139
+ AgentsSearchRequestSearchItemTags,
139
140
  AgentsSearchRequestSearchItemVersion,
140
141
  AgentsSearchRequestSearchItem_Name,
141
142
  AgentsSearchRequestSearchItem_OrderBy,
143
+ AgentsSearchRequestSearchItem_Tags,
142
144
  AgentsSearchRequestSearchItem_Version,
143
145
  CreateAgentRequestToolRulesItem,
144
146
  UpdateAgentToolRulesItem,
@@ -162,9 +164,11 @@ __all__ = [
162
164
  "AgentsSearchRequestSearchItemOrderBy",
163
165
  "AgentsSearchRequestSearchItemOrderByDirection",
164
166
  "AgentsSearchRequestSearchItemOrderByValue",
167
+ "AgentsSearchRequestSearchItemTags",
165
168
  "AgentsSearchRequestSearchItemVersion",
166
169
  "AgentsSearchRequestSearchItem_Name",
167
170
  "AgentsSearchRequestSearchItem_OrderBy",
171
+ "AgentsSearchRequestSearchItem_Tags",
168
172
  "AgentsSearchRequestSearchItem_Version",
169
173
  "AppAuthScheme",
170
174
  "AppAuthSchemeAuthMode",
@@ -301,5 +305,6 @@ __all__ = [
301
305
  "providers",
302
306
  "runs",
303
307
  "sources",
308
+ "tag",
304
309
  "tools",
305
310
  ]
@@ -8,9 +8,11 @@ from .types import (
8
8
  AgentsSearchRequestSearchItemOrderBy,
9
9
  AgentsSearchRequestSearchItemOrderByDirection,
10
10
  AgentsSearchRequestSearchItemOrderByValue,
11
+ AgentsSearchRequestSearchItemTags,
11
12
  AgentsSearchRequestSearchItemVersion,
12
13
  AgentsSearchRequestSearchItem_Name,
13
14
  AgentsSearchRequestSearchItem_OrderBy,
15
+ AgentsSearchRequestSearchItem_Tags,
14
16
  AgentsSearchRequestSearchItem_Version,
15
17
  CreateAgentRequestToolRulesItem,
16
18
  UpdateAgentToolRulesItem,
@@ -55,9 +57,11 @@ __all__ = [
55
57
  "AgentsSearchRequestSearchItemOrderBy",
56
58
  "AgentsSearchRequestSearchItemOrderByDirection",
57
59
  "AgentsSearchRequestSearchItemOrderByValue",
60
+ "AgentsSearchRequestSearchItemTags",
58
61
  "AgentsSearchRequestSearchItemVersion",
59
62
  "AgentsSearchRequestSearchItem_Name",
60
63
  "AgentsSearchRequestSearchItem_OrderBy",
64
+ "AgentsSearchRequestSearchItem_Tags",
61
65
  "AgentsSearchRequestSearchItem_Version",
62
66
  "CreateAgentRequestToolRulesItem",
63
67
  "LettaStreamingResponse",
@@ -144,8 +144,8 @@ class AgentsClient:
144
144
  def create(
145
145
  self,
146
146
  *,
147
- memory_blocks: typing.Sequence[CreateBlock],
148
147
  name: typing.Optional[str] = OMIT,
148
+ memory_blocks: typing.Optional[typing.Sequence[CreateBlock]] = OMIT,
149
149
  tools: typing.Optional[typing.Sequence[str]] = OMIT,
150
150
  tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
151
151
  source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
@@ -165,6 +165,7 @@ class AgentsClient:
165
165
  context_window_limit: typing.Optional[int] = OMIT,
166
166
  embedding_chunk_size: typing.Optional[int] = OMIT,
167
167
  from_template: typing.Optional[str] = OMIT,
168
+ template: typing.Optional[bool] = OMIT,
168
169
  project: typing.Optional[str] = OMIT,
169
170
  tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
170
171
  variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
@@ -175,12 +176,12 @@ class AgentsClient:
175
176
 
176
177
  Parameters
177
178
  ----------
178
- memory_blocks : typing.Sequence[CreateBlock]
179
- The blocks to create in the agent's in-context memory.
180
-
181
179
  name : typing.Optional[str]
182
180
  The name of the agent.
183
181
 
182
+ memory_blocks : typing.Optional[typing.Sequence[CreateBlock]]
183
+ The blocks to create in the agent's in-context memory.
184
+
184
185
  tools : typing.Optional[typing.Sequence[str]]
185
186
  The tools used by the agent.
186
187
 
@@ -238,6 +239,9 @@ class AgentsClient:
238
239
  from_template : typing.Optional[str]
239
240
  The template id used to configure the agent
240
241
 
242
+ template : typing.Optional[bool]
243
+ Whether the agent is a template
244
+
241
245
  project : typing.Optional[str]
242
246
  The project slug that the agent will be associated with.
243
247
 
@@ -257,19 +261,12 @@ class AgentsClient:
257
261
 
258
262
  Examples
259
263
  --------
260
- from letta_client import CreateBlock, Letta
264
+ from letta_client import Letta
261
265
 
262
266
  client = Letta(
263
267
  token="YOUR_TOKEN",
264
268
  )
265
- client.agents.create(
266
- memory_blocks=[
267
- CreateBlock(
268
- value="value",
269
- label="label",
270
- )
271
- ],
272
- )
269
+ client.agents.create()
273
270
  """
274
271
  _response = self._client_wrapper.httpx_client.request(
275
272
  "v1/agents/",
@@ -306,6 +303,7 @@ class AgentsClient:
306
303
  "context_window_limit": context_window_limit,
307
304
  "embedding_chunk_size": embedding_chunk_size,
308
305
  "from_template": from_template,
306
+ "template": template,
309
307
  "project": project,
310
308
  "tool_exec_environment_variables": tool_exec_environment_variables,
311
309
  "variables": variables,
@@ -838,8 +836,8 @@ class AsyncAgentsClient:
838
836
  async def create(
839
837
  self,
840
838
  *,
841
- memory_blocks: typing.Sequence[CreateBlock],
842
839
  name: typing.Optional[str] = OMIT,
840
+ memory_blocks: typing.Optional[typing.Sequence[CreateBlock]] = OMIT,
843
841
  tools: typing.Optional[typing.Sequence[str]] = OMIT,
844
842
  tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
845
843
  source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
@@ -859,6 +857,7 @@ class AsyncAgentsClient:
859
857
  context_window_limit: typing.Optional[int] = OMIT,
860
858
  embedding_chunk_size: typing.Optional[int] = OMIT,
861
859
  from_template: typing.Optional[str] = OMIT,
860
+ template: typing.Optional[bool] = OMIT,
862
861
  project: typing.Optional[str] = OMIT,
863
862
  tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
864
863
  variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
@@ -869,12 +868,12 @@ class AsyncAgentsClient:
869
868
 
870
869
  Parameters
871
870
  ----------
872
- memory_blocks : typing.Sequence[CreateBlock]
873
- The blocks to create in the agent's in-context memory.
874
-
875
871
  name : typing.Optional[str]
876
872
  The name of the agent.
877
873
 
874
+ memory_blocks : typing.Optional[typing.Sequence[CreateBlock]]
875
+ The blocks to create in the agent's in-context memory.
876
+
878
877
  tools : typing.Optional[typing.Sequence[str]]
879
878
  The tools used by the agent.
880
879
 
@@ -932,6 +931,9 @@ class AsyncAgentsClient:
932
931
  from_template : typing.Optional[str]
933
932
  The template id used to configure the agent
934
933
 
934
+ template : typing.Optional[bool]
935
+ Whether the agent is a template
936
+
935
937
  project : typing.Optional[str]
936
938
  The project slug that the agent will be associated with.
937
939
 
@@ -953,7 +955,7 @@ class AsyncAgentsClient:
953
955
  --------
954
956
  import asyncio
955
957
 
956
- from letta_client import AsyncLetta, CreateBlock
958
+ from letta_client import AsyncLetta
957
959
 
958
960
  client = AsyncLetta(
959
961
  token="YOUR_TOKEN",
@@ -961,14 +963,7 @@ class AsyncAgentsClient:
961
963
 
962
964
 
963
965
  async def main() -> None:
964
- await client.agents.create(
965
- memory_blocks=[
966
- CreateBlock(
967
- value="value",
968
- label="label",
969
- )
970
- ],
971
- )
966
+ await client.agents.create()
972
967
 
973
968
 
974
969
  asyncio.run(main())
@@ -1008,6 +1003,7 @@ class AsyncAgentsClient:
1008
1003
  "context_window_limit": context_window_limit,
1009
1004
  "embedding_chunk_size": embedding_chunk_size,
1010
1005
  "from_template": from_template,
1006
+ "template": template,
1011
1007
  "project": project,
1012
1008
  "tool_exec_environment_variables": tool_exec_environment_variables,
1013
1009
  "variables": variables,
@@ -5,6 +5,7 @@ from .agents_search_request_search_item import (
5
5
  AgentsSearchRequestSearchItem,
6
6
  AgentsSearchRequestSearchItem_Name,
7
7
  AgentsSearchRequestSearchItem_OrderBy,
8
+ AgentsSearchRequestSearchItem_Tags,
8
9
  AgentsSearchRequestSearchItem_Version,
9
10
  )
10
11
  from .agents_search_request_search_item_name import AgentsSearchRequestSearchItemName
@@ -12,6 +13,7 @@ from .agents_search_request_search_item_name_operator import AgentsSearchRequest
12
13
  from .agents_search_request_search_item_order_by import AgentsSearchRequestSearchItemOrderBy
13
14
  from .agents_search_request_search_item_order_by_direction import AgentsSearchRequestSearchItemOrderByDirection
14
15
  from .agents_search_request_search_item_order_by_value import AgentsSearchRequestSearchItemOrderByValue
16
+ from .agents_search_request_search_item_tags import AgentsSearchRequestSearchItemTags
15
17
  from .agents_search_request_search_item_version import AgentsSearchRequestSearchItemVersion
16
18
  from .create_agent_request_tool_rules_item import CreateAgentRequestToolRulesItem
17
19
  from .update_agent_tool_rules_item import UpdateAgentToolRulesItem
@@ -24,9 +26,11 @@ __all__ = [
24
26
  "AgentsSearchRequestSearchItemOrderBy",
25
27
  "AgentsSearchRequestSearchItemOrderByDirection",
26
28
  "AgentsSearchRequestSearchItemOrderByValue",
29
+ "AgentsSearchRequestSearchItemTags",
27
30
  "AgentsSearchRequestSearchItemVersion",
28
31
  "AgentsSearchRequestSearchItem_Name",
29
32
  "AgentsSearchRequestSearchItem_OrderBy",
33
+ "AgentsSearchRequestSearchItem_Tags",
30
34
  "AgentsSearchRequestSearchItem_Version",
31
35
  "CreateAgentRequestToolRulesItem",
32
36
  "UpdateAgentToolRulesItem",
@@ -41,6 +41,21 @@ class AgentsSearchRequestSearchItem_Name(UncheckedBaseModel):
41
41
  extra = pydantic.Extra.allow
42
42
 
43
43
 
44
+ class AgentsSearchRequestSearchItem_Tags(UncheckedBaseModel):
45
+ field: typing.Literal["tags"] = "tags"
46
+ operator: typing.Literal["contains"] = "contains"
47
+ value: typing.List[str]
48
+
49
+ if IS_PYDANTIC_V2:
50
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
51
+ else:
52
+
53
+ class Config:
54
+ frozen = True
55
+ smart_union = True
56
+ extra = pydantic.Extra.allow
57
+
58
+
44
59
  class AgentsSearchRequestSearchItem_OrderBy(UncheckedBaseModel):
45
60
  field: typing.Literal["order_by"] = "order_by"
46
61
  value: AgentsSearchRequestSearchItemOrderByValue
@@ -58,7 +73,10 @@ class AgentsSearchRequestSearchItem_OrderBy(UncheckedBaseModel):
58
73
 
59
74
  AgentsSearchRequestSearchItem = typing_extensions.Annotated[
60
75
  typing.Union[
61
- AgentsSearchRequestSearchItem_Version, AgentsSearchRequestSearchItem_Name, AgentsSearchRequestSearchItem_OrderBy
76
+ AgentsSearchRequestSearchItem_Version,
77
+ AgentsSearchRequestSearchItem_Name,
78
+ AgentsSearchRequestSearchItem_Tags,
79
+ AgentsSearchRequestSearchItem_OrderBy,
62
80
  ],
63
81
  UnionMetadata(discriminant="field"),
64
82
  ]
@@ -0,0 +1,20 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ...core.unchecked_base_model import UncheckedBaseModel
4
+ import typing
5
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
6
+ import pydantic
7
+
8
+
9
+ class AgentsSearchRequestSearchItemTags(UncheckedBaseModel):
10
+ operator: typing.Literal["contains"] = "contains"
11
+ value: typing.List[str]
12
+
13
+ if IS_PYDANTIC_V2:
14
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
15
+ else:
16
+
17
+ class Config:
18
+ frozen = True
19
+ smart_union = True
20
+ extra = pydantic.Extra.allow
@@ -0,0 +1,176 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from .environment import LettaEnvironment
5
+ import httpx
6
+ from .core.client_wrapper import SyncClientWrapper
7
+ from .tools.client import ToolsClient
8
+ from .sources.client import SourcesClient
9
+ from .agents.client import AgentsClient
10
+ from .models.client import ModelsClient
11
+ from .blocks.client import BlocksClient
12
+ from .jobs.client import JobsClient
13
+ from .health.client import HealthClient
14
+ from .providers.client import ProvidersClient
15
+ from .runs.client import RunsClient
16
+ from .tag.client import TagClient
17
+ from .core.client_wrapper import AsyncClientWrapper
18
+ from .tools.client import AsyncToolsClient
19
+ from .sources.client import AsyncSourcesClient
20
+ from .agents.client import AsyncAgentsClient
21
+ from .models.client import AsyncModelsClient
22
+ from .blocks.client import AsyncBlocksClient
23
+ from .jobs.client import AsyncJobsClient
24
+ from .health.client import AsyncHealthClient
25
+ from .providers.client import AsyncProvidersClient
26
+ from .runs.client import AsyncRunsClient
27
+ from .tag.client import AsyncTagClient
28
+
29
+
30
+ class LettaBase:
31
+ """
32
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
33
+
34
+ Parameters
35
+ ----------
36
+ base_url : typing.Optional[str]
37
+ The base url to use for requests from the client.
38
+
39
+ environment : LettaEnvironment
40
+ The environment to use for requests from the client. from .environment import LettaEnvironment
41
+
42
+
43
+
44
+ Defaults to LettaEnvironment.LETTA_CLOUD
45
+
46
+
47
+
48
+ token : typing.Optional[str]
49
+ timeout : typing.Optional[float]
50
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
51
+
52
+ follow_redirects : typing.Optional[bool]
53
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
54
+
55
+ httpx_client : typing.Optional[httpx.Client]
56
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
57
+
58
+ Examples
59
+ --------
60
+ from letta_client import Letta
61
+
62
+ client = Letta(
63
+ token="YOUR_TOKEN",
64
+ )
65
+ """
66
+
67
+ def __init__(
68
+ self,
69
+ *,
70
+ base_url: typing.Optional[str] = None,
71
+ environment: LettaEnvironment = LettaEnvironment.LETTA_CLOUD,
72
+ token: typing.Optional[str] = None,
73
+ timeout: typing.Optional[float] = None,
74
+ follow_redirects: typing.Optional[bool] = True,
75
+ httpx_client: typing.Optional[httpx.Client] = None,
76
+ ):
77
+ _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
78
+ self._client_wrapper = SyncClientWrapper(
79
+ base_url=_get_base_url(base_url=base_url, environment=environment),
80
+ token=token,
81
+ httpx_client=httpx_client
82
+ if httpx_client is not None
83
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
84
+ if follow_redirects is not None
85
+ else httpx.Client(timeout=_defaulted_timeout),
86
+ timeout=_defaulted_timeout,
87
+ )
88
+ self.tools = ToolsClient(client_wrapper=self._client_wrapper)
89
+ self.sources = SourcesClient(client_wrapper=self._client_wrapper)
90
+ self.agents = AgentsClient(client_wrapper=self._client_wrapper)
91
+ self.models = ModelsClient(client_wrapper=self._client_wrapper)
92
+ self.blocks = BlocksClient(client_wrapper=self._client_wrapper)
93
+ self.jobs = JobsClient(client_wrapper=self._client_wrapper)
94
+ self.health = HealthClient(client_wrapper=self._client_wrapper)
95
+ self.providers = ProvidersClient(client_wrapper=self._client_wrapper)
96
+ self.runs = RunsClient(client_wrapper=self._client_wrapper)
97
+ self.tag = TagClient(client_wrapper=self._client_wrapper)
98
+
99
+
100
+ class AsyncLettaBase:
101
+ """
102
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
103
+
104
+ Parameters
105
+ ----------
106
+ base_url : typing.Optional[str]
107
+ The base url to use for requests from the client.
108
+
109
+ environment : LettaEnvironment
110
+ The environment to use for requests from the client. from .environment import LettaEnvironment
111
+
112
+
113
+
114
+ Defaults to LettaEnvironment.LETTA_CLOUD
115
+
116
+
117
+
118
+ token : typing.Optional[str]
119
+ timeout : typing.Optional[float]
120
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
121
+
122
+ follow_redirects : typing.Optional[bool]
123
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
124
+
125
+ httpx_client : typing.Optional[httpx.AsyncClient]
126
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
127
+
128
+ Examples
129
+ --------
130
+ from letta_client import AsyncLetta
131
+
132
+ client = AsyncLetta(
133
+ token="YOUR_TOKEN",
134
+ )
135
+ """
136
+
137
+ def __init__(
138
+ self,
139
+ *,
140
+ base_url: typing.Optional[str] = None,
141
+ environment: LettaEnvironment = LettaEnvironment.LETTA_CLOUD,
142
+ token: typing.Optional[str] = None,
143
+ timeout: typing.Optional[float] = None,
144
+ follow_redirects: typing.Optional[bool] = True,
145
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
146
+ ):
147
+ _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
148
+ self._client_wrapper = AsyncClientWrapper(
149
+ base_url=_get_base_url(base_url=base_url, environment=environment),
150
+ token=token,
151
+ httpx_client=httpx_client
152
+ if httpx_client is not None
153
+ else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
154
+ if follow_redirects is not None
155
+ else httpx.AsyncClient(timeout=_defaulted_timeout),
156
+ timeout=_defaulted_timeout,
157
+ )
158
+ self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
159
+ self.sources = AsyncSourcesClient(client_wrapper=self._client_wrapper)
160
+ self.agents = AsyncAgentsClient(client_wrapper=self._client_wrapper)
161
+ self.models = AsyncModelsClient(client_wrapper=self._client_wrapper)
162
+ self.blocks = AsyncBlocksClient(client_wrapper=self._client_wrapper)
163
+ self.jobs = AsyncJobsClient(client_wrapper=self._client_wrapper)
164
+ self.health = AsyncHealthClient(client_wrapper=self._client_wrapper)
165
+ self.providers = AsyncProvidersClient(client_wrapper=self._client_wrapper)
166
+ self.runs = AsyncRunsClient(client_wrapper=self._client_wrapper)
167
+ self.tag = AsyncTagClient(client_wrapper=self._client_wrapper)
168
+
169
+
170
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: LettaEnvironment) -> str:
171
+ if base_url is not None:
172
+ return base_url
173
+ elif environment is not None:
174
+ return environment.value
175
+ else:
176
+ raise Exception("Please pass in either base_url or environment to construct the client")
letta_client/client.py CHANGED
@@ -1,172 +1,55 @@
1
- # This file was auto-generated by Fern from our API Definition.
2
-
1
+ from textwrap import dedent
2
+ import inspect
3
3
  import typing
4
- from .environment import LettaEnvironment
5
- import httpx
6
- from .core.client_wrapper import SyncClientWrapper
7
- from .tools.client import ToolsClient
8
- from .sources.client import SourcesClient
9
- from .agents.client import AgentsClient
10
- from .models.client import ModelsClient
11
- from .blocks.client import BlocksClient
12
- from .jobs.client import JobsClient
13
- from .health.client import HealthClient
14
- from .providers.client import ProvidersClient
15
- from .runs.client import RunsClient
16
- from .core.client_wrapper import AsyncClientWrapper
17
- from .tools.client import AsyncToolsClient
18
- from .sources.client import AsyncSourcesClient
19
- from .agents.client import AsyncAgentsClient
20
- from .models.client import AsyncModelsClient
21
- from .blocks.client import AsyncBlocksClient
22
- from .jobs.client import AsyncJobsClient
23
- from .health.client import AsyncHealthClient
24
- from .providers.client import AsyncProvidersClient
25
- from .runs.client import AsyncRunsClient
26
-
27
-
28
- class Letta:
29
- """
30
- Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
31
-
32
- Parameters
33
- ----------
34
- base_url : typing.Optional[str]
35
- The base url to use for requests from the client.
36
-
37
- environment : LettaEnvironment
38
- The environment to use for requests from the client. from .environment import LettaEnvironment
39
-
40
-
41
4
 
42
- Defaults to LettaEnvironment.LETTA_CLOUD
5
+ from .base_client import LettaBase, AsyncLettaBase
6
+ from .core.request_options import RequestOptions
7
+ from .tools.client import ToolsClient as ToolsClientBase
8
+ from .types.letta_schemas_tool_tool import LettaSchemasToolTool
43
9
 
44
10
 
11
+ # this is used as the default value for optional parameters
12
+ OMIT = typing.cast(typing.Any, ...)
45
13
 
46
- token : typing.Optional[str]
47
- timeout : typing.Optional[float]
48
- The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
49
14
 
50
- follow_redirects : typing.Optional[bool]
51
- Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
15
+ class Letta(LettaBase):
52
16
 
53
- httpx_client : typing.Optional[httpx.Client]
54
- The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
55
-
56
- Examples
57
- --------
58
- from letta_client import Letta
59
-
60
- client = Letta(
61
- token="YOUR_TOKEN",
62
- )
63
- """
64
-
65
- def __init__(
66
- self,
67
- *,
68
- base_url: typing.Optional[str] = None,
69
- environment: LettaEnvironment = LettaEnvironment.LETTA_CLOUD,
70
- token: typing.Optional[str] = None,
71
- timeout: typing.Optional[float] = None,
72
- follow_redirects: typing.Optional[bool] = True,
73
- httpx_client: typing.Optional[httpx.Client] = None,
74
- ):
75
- _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
76
- self._client_wrapper = SyncClientWrapper(
77
- base_url=_get_base_url(base_url=base_url, environment=environment),
78
- token=token,
79
- httpx_client=httpx_client
80
- if httpx_client is not None
81
- else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
82
- if follow_redirects is not None
83
- else httpx.Client(timeout=_defaulted_timeout),
84
- timeout=_defaulted_timeout,
85
- )
17
+ def __init__(self, *args, **kwargs):
18
+ super().__init__(*args, **kwargs)
86
19
  self.tools = ToolsClient(client_wrapper=self._client_wrapper)
87
- self.sources = SourcesClient(client_wrapper=self._client_wrapper)
88
- self.agents = AgentsClient(client_wrapper=self._client_wrapper)
89
- self.models = ModelsClient(client_wrapper=self._client_wrapper)
90
- self.blocks = BlocksClient(client_wrapper=self._client_wrapper)
91
- self.jobs = JobsClient(client_wrapper=self._client_wrapper)
92
- self.health = HealthClient(client_wrapper=self._client_wrapper)
93
- self.providers = ProvidersClient(client_wrapper=self._client_wrapper)
94
- self.runs = RunsClient(client_wrapper=self._client_wrapper)
95
20
 
96
21
 
97
- class AsyncLetta:
98
- """
99
- Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
22
+ class AsyncLetta(AsyncLettaBase):
100
23
 
101
- Parameters
102
- ----------
103
- base_url : typing.Optional[str]
104
- The base url to use for requests from the client.
105
-
106
- environment : LettaEnvironment
107
- The environment to use for requests from the client. from .environment import LettaEnvironment
108
-
109
-
110
-
111
- Defaults to LettaEnvironment.LETTA_CLOUD
112
-
113
-
114
-
115
- token : typing.Optional[str]
116
- timeout : typing.Optional[float]
117
- The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
118
-
119
- follow_redirects : typing.Optional[bool]
120
- Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
121
-
122
- httpx_client : typing.Optional[httpx.AsyncClient]
123
- The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
24
+ def __init__(self, *args, **kwargs):
25
+ super().__init__(*args, **kwargs)
26
+ self.tools = ToolsClient(client_wrapper=self._client_wrapper)
124
27
 
125
- Examples
126
- --------
127
- from letta_client import AsyncLetta
128
28
 
129
- client = AsyncLetta(
130
- token="YOUR_TOKEN",
131
- )
132
- """
29
+ class ToolsClient(ToolsClientBase):
133
30
 
134
- def __init__(
31
+ def create_from_function(
135
32
  self,
136
33
  *,
137
- base_url: typing.Optional[str] = None,
138
- environment: LettaEnvironment = LettaEnvironment.LETTA_CLOUD,
139
- token: typing.Optional[str] = None,
140
- timeout: typing.Optional[float] = None,
141
- follow_redirects: typing.Optional[bool] = True,
142
- httpx_client: typing.Optional[httpx.AsyncClient] = None,
143
- ):
144
- _defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
145
- self._client_wrapper = AsyncClientWrapper(
146
- base_url=_get_base_url(base_url=base_url, environment=environment),
147
- token=token,
148
- httpx_client=httpx_client
149
- if httpx_client is not None
150
- else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
151
- if follow_redirects is not None
152
- else httpx.AsyncClient(timeout=_defaulted_timeout),
153
- timeout=_defaulted_timeout,
34
+ function: typing.Callable,
35
+ name: typing.Optional[str] = OMIT,
36
+ description: typing.Optional[str] = OMIT,
37
+ tags: typing.Optional[typing.Sequence[str]] = OMIT,
38
+ source_type: typing.Optional[str] = OMIT,
39
+ json_schema: typing.Optional[
40
+ typing.Dict[str, typing.Optional[typing.Any]]
41
+ ] = OMIT,
42
+ return_char_limit: typing.Optional[int] = OMIT,
43
+ request_options: typing.Optional[RequestOptions] = None,
44
+ ) -> LettaSchemasToolTool:
45
+ source_code = dedent(inspect.getsource(function))
46
+ return self.create(
47
+ source_code=source_code,
48
+ name=name,
49
+ description=description,
50
+ tags=tags,
51
+ source_type=source_type,
52
+ json_schema=json_schema,
53
+ return_char_limit=return_char_limit,
54
+ request_options=request_options,
154
55
  )
155
- self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
156
- self.sources = AsyncSourcesClient(client_wrapper=self._client_wrapper)
157
- self.agents = AsyncAgentsClient(client_wrapper=self._client_wrapper)
158
- self.models = AsyncModelsClient(client_wrapper=self._client_wrapper)
159
- self.blocks = AsyncBlocksClient(client_wrapper=self._client_wrapper)
160
- self.jobs = AsyncJobsClient(client_wrapper=self._client_wrapper)
161
- self.health = AsyncHealthClient(client_wrapper=self._client_wrapper)
162
- self.providers = AsyncProvidersClient(client_wrapper=self._client_wrapper)
163
- self.runs = AsyncRunsClient(client_wrapper=self._client_wrapper)
164
-
165
-
166
- def _get_base_url(*, base_url: typing.Optional[str] = None, environment: LettaEnvironment) -> str:
167
- if base_url is not None:
168
- return base_url
169
- elif environment is not None:
170
- return environment.value
171
- else:
172
- raise Exception("Please pass in either base_url or environment to construct the client")
@@ -16,7 +16,7 @@ class BaseClientWrapper:
16
16
  headers: typing.Dict[str, str] = {
17
17
  "X-Fern-Language": "Python",
18
18
  "X-Fern-SDK-Name": "letta-client",
19
- "X-Fern-SDK-Version": "0.1.11",
19
+ "X-Fern-SDK-Version": "0.1.14",
20
20
  }
21
21
  if self.token is not None:
22
22
  headers["Authorization"] = f"Bearer {self.token}"
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
@@ -0,0 +1,169 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.client_wrapper import SyncClientWrapper
4
+ import typing
5
+ from ..core.request_options import RequestOptions
6
+ from ..core.unchecked_base_model import construct_type
7
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
8
+ from ..types.http_validation_error import HttpValidationError
9
+ from json.decoder import JSONDecodeError
10
+ from ..core.api_error import ApiError
11
+ from ..core.client_wrapper import AsyncClientWrapper
12
+
13
+
14
+ class TagClient:
15
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
16
+ self._client_wrapper = client_wrapper
17
+
18
+ def list_tags(
19
+ self,
20
+ *,
21
+ cursor: typing.Optional[str] = None,
22
+ limit: typing.Optional[int] = None,
23
+ query_text: typing.Optional[str] = None,
24
+ request_options: typing.Optional[RequestOptions] = None,
25
+ ) -> typing.List[str]:
26
+ """
27
+ Get a list of all tags in the database
28
+
29
+ Parameters
30
+ ----------
31
+ cursor : typing.Optional[str]
32
+
33
+ limit : typing.Optional[int]
34
+
35
+ query_text : typing.Optional[str]
36
+
37
+ request_options : typing.Optional[RequestOptions]
38
+ Request-specific configuration.
39
+
40
+ Returns
41
+ -------
42
+ typing.List[str]
43
+ Successful Response
44
+
45
+ Examples
46
+ --------
47
+ from letta_client import Letta
48
+
49
+ client = Letta(
50
+ token="YOUR_TOKEN",
51
+ )
52
+ client.tag.list_tags()
53
+ """
54
+ _response = self._client_wrapper.httpx_client.request(
55
+ "v1/tags/",
56
+ method="GET",
57
+ params={
58
+ "cursor": cursor,
59
+ "limit": limit,
60
+ "query_text": query_text,
61
+ },
62
+ request_options=request_options,
63
+ )
64
+ try:
65
+ if 200 <= _response.status_code < 300:
66
+ return typing.cast(
67
+ typing.List[str],
68
+ construct_type(
69
+ type_=typing.List[str], # type: ignore
70
+ object_=_response.json(),
71
+ ),
72
+ )
73
+ if _response.status_code == 422:
74
+ raise UnprocessableEntityError(
75
+ typing.cast(
76
+ HttpValidationError,
77
+ construct_type(
78
+ type_=HttpValidationError, # type: ignore
79
+ object_=_response.json(),
80
+ ),
81
+ )
82
+ )
83
+ _response_json = _response.json()
84
+ except JSONDecodeError:
85
+ raise ApiError(status_code=_response.status_code, body=_response.text)
86
+ raise ApiError(status_code=_response.status_code, body=_response_json)
87
+
88
+
89
+ class AsyncTagClient:
90
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
91
+ self._client_wrapper = client_wrapper
92
+
93
+ async def list_tags(
94
+ self,
95
+ *,
96
+ cursor: typing.Optional[str] = None,
97
+ limit: typing.Optional[int] = None,
98
+ query_text: typing.Optional[str] = None,
99
+ request_options: typing.Optional[RequestOptions] = None,
100
+ ) -> typing.List[str]:
101
+ """
102
+ Get a list of all tags in the database
103
+
104
+ Parameters
105
+ ----------
106
+ cursor : typing.Optional[str]
107
+
108
+ limit : typing.Optional[int]
109
+
110
+ query_text : typing.Optional[str]
111
+
112
+ request_options : typing.Optional[RequestOptions]
113
+ Request-specific configuration.
114
+
115
+ Returns
116
+ -------
117
+ typing.List[str]
118
+ Successful Response
119
+
120
+ Examples
121
+ --------
122
+ import asyncio
123
+
124
+ from letta_client import AsyncLetta
125
+
126
+ client = AsyncLetta(
127
+ token="YOUR_TOKEN",
128
+ )
129
+
130
+
131
+ async def main() -> None:
132
+ await client.tag.list_tags()
133
+
134
+
135
+ asyncio.run(main())
136
+ """
137
+ _response = await self._client_wrapper.httpx_client.request(
138
+ "v1/tags/",
139
+ method="GET",
140
+ params={
141
+ "cursor": cursor,
142
+ "limit": limit,
143
+ "query_text": query_text,
144
+ },
145
+ request_options=request_options,
146
+ )
147
+ try:
148
+ if 200 <= _response.status_code < 300:
149
+ return typing.cast(
150
+ typing.List[str],
151
+ construct_type(
152
+ type_=typing.List[str], # type: ignore
153
+ object_=_response.json(),
154
+ ),
155
+ )
156
+ if _response.status_code == 422:
157
+ raise UnprocessableEntityError(
158
+ typing.cast(
159
+ HttpValidationError,
160
+ construct_type(
161
+ type_=HttpValidationError, # type: ignore
162
+ object_=_response.json(),
163
+ ),
164
+ )
165
+ )
166
+ _response_json = _response.json()
167
+ except JSONDecodeError:
168
+ raise ApiError(status_code=_response.status_code, body=_response.text)
169
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: letta-client
3
- Version: 0.1.11
3
+ Version: 0.1.14
4
4
  Summary:
5
5
  Requires-Python: >=3.8,<4.0
6
6
  Classifier: Intended Audience :: Developers
@@ -1,8 +1,8 @@
1
- letta_client/__init__.py,sha256=T0u1lJaSA6ApQUOFx5wM0Avb3-eKU2EaILq6lbgvxeQ,8506
2
- letta_client/agents/__init__.py,sha256=sAErDvvZvXcBy-XJxaSDkMyKKUNzA5uGh3tmWIR5ODc,3074
1
+ letta_client/__init__.py,sha256=jdTY31_FAPmI9tE4WRI6ypAL7R5kyLilXmfLtJtVPqA,8684
2
+ letta_client/agents/__init__.py,sha256=D_1CWRp_6mF3CUCE-6Jx8QAZVldpgrC_uK_UTLExVDI,3236
3
3
  letta_client/agents/archival_memory/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
4
4
  letta_client/agents/archival_memory/client.py,sha256=8A4GM52LAmZK7v2XJzfWR_PK99E_xcXTYhZMPsK7Uvc,18889
5
- letta_client/agents/client.py,sha256=0-kldkdnp6dulewB5Ae4pbcCL_MiMQBnLtKSgcQTO6A,53706
5
+ letta_client/agents/client.py,sha256=FeXldhkuVr0KDb-hEuQhbq-2BvOMnPC_vit6yIP82nI,53740
6
6
  letta_client/agents/context/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
7
7
  letta_client/agents/context/client.py,sha256=s9dQA3yJo8KVSinnZz0Mv0GWs0tEqoSH5HgdTTD_klc,4781
8
8
  letta_client/agents/core_memory/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
@@ -27,23 +27,25 @@ letta_client/agents/templates/types/__init__.py,sha256=n6TG69a7_CByZmnRbsApvXiH9
27
27
  letta_client/agents/templates/types/templates_migrate_response.py,sha256=7N4JtAaiao-LrNdi72K7XB01uXJVkczaKYIJIMf0QYs,577
28
28
  letta_client/agents/tools/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
29
29
  letta_client/agents/tools/client.py,sha256=c90wAW7q7S8NE_ZZNo55FB5LmtcnPs-mjA1kJ7MRvvA,12852
30
- letta_client/agents/types/__init__.py,sha256=EU-iiIbYdLqamAEYerwvSBrg4q3gKYxKYAnc2TmYZME,1664
30
+ letta_client/agents/types/__init__.py,sha256=q0Zi5FO9IWVN318qJhEZlUrKzx4kgygfFw9fwmFMujo,1873
31
31
  letta_client/agents/types/agents_search_request_combinator.py,sha256=7ZvVX3QILYpXAsKw3l7rQxwwleNekGP73GbNVboCaCA,166
32
- letta_client/agents/types/agents_search_request_search_item.py,sha256=bjdUuqZQ1b6Q1tjSc092fjlNx2MO2rcDUkP1Uj0Xl-4,2318
32
+ letta_client/agents/types/agents_search_request_search_item.py,sha256=ialUuCAyvTsLFzaUfVWTW9q45Sti4MSzZj_ayxXeTSA,2862
33
33
  letta_client/agents/types/agents_search_request_search_item_name.py,sha256=CITFiKq5TtyVKb9CwzRDAACl-HxqOqTOGQLAbcUFXjw,740
34
34
  letta_client/agents/types/agents_search_request_search_item_name_operator.py,sha256=Vw5IieCX8pbMGxDvsTzOiaqP9Zws8BpzQcn7QsPNHdI,190
35
35
  letta_client/agents/types/agents_search_request_search_item_order_by.py,sha256=2mUspR1ifvuTbeJzbbW7ted0IWGsbGxJGDSZzdQWEOs,899
36
36
  letta_client/agents/types/agents_search_request_search_item_order_by_direction.py,sha256=WDYbLnLuJIpM9gMSlwNUtRmckaCGqWXii_N-3uTBeNg,184
37
37
  letta_client/agents/types/agents_search_request_search_item_order_by_value.py,sha256=KmJ3WGea7c_yZMVSShZIfTcYrJ2a7qYV0-31nikSMcE,193
38
+ letta_client/agents/types/agents_search_request_search_item_tags.py,sha256=kZOgsK1eUGdHaulx8MxxtB0X6gzidTLbyMQWc5fhOPo,648
38
39
  letta_client/agents/types/agents_search_request_search_item_version.py,sha256=hipwPCnixAAq5UfhmcAyIcG9Ut1xGhVnP6lYRG1bBsw,584
39
40
  letta_client/agents/types/create_agent_request_tool_rules_item.py,sha256=xSYFbxIAA6k-pZfVsCaTByE8nXRIqyKnfOm_IEjKfEM,415
40
41
  letta_client/agents/types/update_agent_tool_rules_item.py,sha256=5pYbFgeqxmXUHUTZpEWlZ7ODc1G6CpFGWljz_iBpWVA,408
42
+ letta_client/base_client.py,sha256=OapnOZBD94aLQa5uoPCbNIR4zDg55DVI5zBe-wWHYfs,7419
41
43
  letta_client/blocks/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
42
44
  letta_client/blocks/client.py,sha256=-4_DMOmUdzPxCqmOYJv3O9Yrf3ZG-gpzyciTe9qbI7k,32517
43
- letta_client/client.py,sha256=WSYCCgvSON4veHp6xSz_4ex5bpKzL5ifp7g0ft1ZDmU,7201
45
+ letta_client/client.py,sha256=Hi4LXwglMFc-IKUbhM4a7-Bew0Xzf2q5EtO5ziq-yro,1729
44
46
  letta_client/core/__init__.py,sha256=OKbX2aCZXgHCDUsCouqv-OiX32xA6eFFCKIUH9M5Vzk,1591
45
47
  letta_client/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
46
- letta_client/core/client_wrapper.py,sha256=oDaC73_QhHPe4fNOX1KBJJhHF3La9ZkebwasEgPHwDw,1997
48
+ letta_client/core/client_wrapper.py,sha256=UXzK6xyTKG5xsAxhh0GmagqOfdrYVdH3KfrgC00KCwQ,1997
47
49
  letta_client/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
48
50
  letta_client/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
49
51
  letta_client/core/http_client.py,sha256=siUQ6UV0ARZALlxubqWSSAAPC9B4VW8y6MGlHStfaeo,19552
@@ -77,6 +79,8 @@ letta_client/sources/files/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roe
77
79
  letta_client/sources/files/client.py,sha256=K7YdVxWOu4lkv5-cuMZMkTcl9Fr92Q5U2liXYFUqZ4I,13297
78
80
  letta_client/sources/passages/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
79
81
  letta_client/sources/passages/client.py,sha256=n0QVtLC0W1X6_SjhiEGSl9oZexocnsLZYeYRAqV2BCk,4767
82
+ letta_client/tag/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
83
+ letta_client/tag/client.py,sha256=zAy0hjEOVNZV3QAd9iiVuapAXQNCi0wKvZ_wvqj0TmI,5191
80
84
  letta_client/tools/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
81
85
  letta_client/tools/client.py,sha256=dh8uX3tNFbKjgvd2TUwP0KTj4THksnFxnZmEit7tOY4,58734
82
86
  letta_client/types/__init__.py,sha256=0swb0p3HYf3pucfNX4_oJ51oIXXwxhkTIbtkQdW40cI,10356
@@ -199,6 +203,6 @@ letta_client/types/user_update.py,sha256=0Bl1OjO7bfmlpsGQ36dSh6DH1UB_wJOTNewS0wD
199
203
  letta_client/types/validation_error.py,sha256=ACDS7wL5nQbS8ymFhWljwbBJmbugNa8bs2O5xEZC3u4,680
200
204
  letta_client/types/validation_error_loc_item.py,sha256=LAtjCHIllWRBFXvAZ5QZpp7CPXjdtN9EB7HrLVo6EP0,128
201
205
  letta_client/version.py,sha256=bttKLbIhO3UonCYQlqs600zzbQgfhCCMjeXR9WRzid4,79
202
- letta_client-0.1.11.dist-info/METADATA,sha256=mKN0tKMPvNMS8hXGVLmiD2CV3g9rU42nhCNH4nKT_7Y,4929
203
- letta_client-0.1.11.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
204
- letta_client-0.1.11.dist-info/RECORD,,
206
+ letta_client-0.1.14.dist-info/METADATA,sha256=nN2i4nSVBxEhnje9_WKKlH8rXCzlgSFmrjSmEbg62nE,4929
207
+ letta_client-0.1.14.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
208
+ letta_client-0.1.14.dist-info/RECORD,,