letta-client 0.1.10__py3-none-any.whl → 0.1.13__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,7 +165,8 @@ 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
- project_id: typing.Optional[str] = OMIT,
168
+ template: typing.Optional[bool] = OMIT,
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,
171
172
  request_options: typing.Optional[RequestOptions] = None,
@@ -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,8 +239,11 @@ class AgentsClient:
238
239
  from_template : typing.Optional[str]
239
240
  The template id used to configure the agent
240
241
 
241
- project_id : typing.Optional[str]
242
- The project id that the agent will be associated with.
242
+ template : typing.Optional[bool]
243
+ Whether the agent is a template
244
+
245
+ project : typing.Optional[str]
246
+ The project slug that the agent will be associated with.
243
247
 
244
248
  tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
245
249
  The environment variables for tool execution specific to this agent.
@@ -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,7 +303,8 @@ class AgentsClient:
306
303
  "context_window_limit": context_window_limit,
307
304
  "embedding_chunk_size": embedding_chunk_size,
308
305
  "from_template": from_template,
309
- "project_id": project_id,
306
+ "template": template,
307
+ "project": project,
310
308
  "tool_exec_environment_variables": tool_exec_environment_variables,
311
309
  "variables": variables,
312
310
  },
@@ -592,6 +590,74 @@ class AgentsClient:
592
590
  raise ApiError(status_code=_response.status_code, body=_response.text)
593
591
  raise ApiError(status_code=_response.status_code, body=_response_json)
594
592
 
593
+ def reset_messages(
594
+ self,
595
+ agent_id: str,
596
+ *,
597
+ add_default_initial_messages: typing.Optional[bool] = None,
598
+ request_options: typing.Optional[RequestOptions] = None,
599
+ ) -> AgentState:
600
+ """
601
+ Resets the messages for an agent
602
+
603
+ Parameters
604
+ ----------
605
+ agent_id : str
606
+
607
+ add_default_initial_messages : typing.Optional[bool]
608
+ If true, adds the default initial messages after resetting.
609
+
610
+ request_options : typing.Optional[RequestOptions]
611
+ Request-specific configuration.
612
+
613
+ Returns
614
+ -------
615
+ AgentState
616
+ Successful Response
617
+
618
+ Examples
619
+ --------
620
+ from letta_client import Letta
621
+
622
+ client = Letta(
623
+ token="YOUR_TOKEN",
624
+ )
625
+ client.agents.reset_messages(
626
+ agent_id="agent_id",
627
+ )
628
+ """
629
+ _response = self._client_wrapper.httpx_client.request(
630
+ f"v1/agents/{jsonable_encoder(agent_id)}/reset-messages",
631
+ method="PATCH",
632
+ params={
633
+ "add_default_initial_messages": add_default_initial_messages,
634
+ },
635
+ request_options=request_options,
636
+ )
637
+ try:
638
+ if 200 <= _response.status_code < 300:
639
+ return typing.cast(
640
+ AgentState,
641
+ construct_type(
642
+ type_=AgentState, # type: ignore
643
+ object_=_response.json(),
644
+ ),
645
+ )
646
+ if _response.status_code == 422:
647
+ raise UnprocessableEntityError(
648
+ typing.cast(
649
+ HttpValidationError,
650
+ construct_type(
651
+ type_=HttpValidationError, # type: ignore
652
+ object_=_response.json(),
653
+ ),
654
+ )
655
+ )
656
+ _response_json = _response.json()
657
+ except JSONDecodeError:
658
+ raise ApiError(status_code=_response.status_code, body=_response.text)
659
+ raise ApiError(status_code=_response.status_code, body=_response_json)
660
+
595
661
  def search(
596
662
  self,
597
663
  *,
@@ -770,8 +836,8 @@ class AsyncAgentsClient:
770
836
  async def create(
771
837
  self,
772
838
  *,
773
- memory_blocks: typing.Sequence[CreateBlock],
774
839
  name: typing.Optional[str] = OMIT,
840
+ memory_blocks: typing.Optional[typing.Sequence[CreateBlock]] = OMIT,
775
841
  tools: typing.Optional[typing.Sequence[str]] = OMIT,
776
842
  tool_ids: typing.Optional[typing.Sequence[str]] = OMIT,
777
843
  source_ids: typing.Optional[typing.Sequence[str]] = OMIT,
@@ -791,7 +857,8 @@ class AsyncAgentsClient:
791
857
  context_window_limit: typing.Optional[int] = OMIT,
792
858
  embedding_chunk_size: typing.Optional[int] = OMIT,
793
859
  from_template: typing.Optional[str] = OMIT,
794
- project_id: typing.Optional[str] = OMIT,
860
+ template: typing.Optional[bool] = OMIT,
861
+ project: typing.Optional[str] = OMIT,
795
862
  tool_exec_environment_variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
796
863
  variables: typing.Optional[typing.Dict[str, typing.Optional[str]]] = OMIT,
797
864
  request_options: typing.Optional[RequestOptions] = None,
@@ -801,12 +868,12 @@ class AsyncAgentsClient:
801
868
 
802
869
  Parameters
803
870
  ----------
804
- memory_blocks : typing.Sequence[CreateBlock]
805
- The blocks to create in the agent's in-context memory.
806
-
807
871
  name : typing.Optional[str]
808
872
  The name of the agent.
809
873
 
874
+ memory_blocks : typing.Optional[typing.Sequence[CreateBlock]]
875
+ The blocks to create in the agent's in-context memory.
876
+
810
877
  tools : typing.Optional[typing.Sequence[str]]
811
878
  The tools used by the agent.
812
879
 
@@ -864,8 +931,11 @@ class AsyncAgentsClient:
864
931
  from_template : typing.Optional[str]
865
932
  The template id used to configure the agent
866
933
 
867
- project_id : typing.Optional[str]
868
- The project id that the agent will be associated with.
934
+ template : typing.Optional[bool]
935
+ Whether the agent is a template
936
+
937
+ project : typing.Optional[str]
938
+ The project slug that the agent will be associated with.
869
939
 
870
940
  tool_exec_environment_variables : typing.Optional[typing.Dict[str, typing.Optional[str]]]
871
941
  The environment variables for tool execution specific to this agent.
@@ -885,7 +955,7 @@ class AsyncAgentsClient:
885
955
  --------
886
956
  import asyncio
887
957
 
888
- from letta_client import AsyncLetta, CreateBlock
958
+ from letta_client import AsyncLetta
889
959
 
890
960
  client = AsyncLetta(
891
961
  token="YOUR_TOKEN",
@@ -893,14 +963,7 @@ class AsyncAgentsClient:
893
963
 
894
964
 
895
965
  async def main() -> None:
896
- await client.agents.create(
897
- memory_blocks=[
898
- CreateBlock(
899
- value="value",
900
- label="label",
901
- )
902
- ],
903
- )
966
+ await client.agents.create()
904
967
 
905
968
 
906
969
  asyncio.run(main())
@@ -940,7 +1003,8 @@ class AsyncAgentsClient:
940
1003
  "context_window_limit": context_window_limit,
941
1004
  "embedding_chunk_size": embedding_chunk_size,
942
1005
  "from_template": from_template,
943
- "project_id": project_id,
1006
+ "template": template,
1007
+ "project": project,
944
1008
  "tool_exec_environment_variables": tool_exec_environment_variables,
945
1009
  "variables": variables,
946
1010
  },
@@ -1250,6 +1314,82 @@ class AsyncAgentsClient:
1250
1314
  raise ApiError(status_code=_response.status_code, body=_response.text)
1251
1315
  raise ApiError(status_code=_response.status_code, body=_response_json)
1252
1316
 
1317
+ async def reset_messages(
1318
+ self,
1319
+ agent_id: str,
1320
+ *,
1321
+ add_default_initial_messages: typing.Optional[bool] = None,
1322
+ request_options: typing.Optional[RequestOptions] = None,
1323
+ ) -> AgentState:
1324
+ """
1325
+ Resets the messages for an agent
1326
+
1327
+ Parameters
1328
+ ----------
1329
+ agent_id : str
1330
+
1331
+ add_default_initial_messages : typing.Optional[bool]
1332
+ If true, adds the default initial messages after resetting.
1333
+
1334
+ request_options : typing.Optional[RequestOptions]
1335
+ Request-specific configuration.
1336
+
1337
+ Returns
1338
+ -------
1339
+ AgentState
1340
+ Successful Response
1341
+
1342
+ Examples
1343
+ --------
1344
+ import asyncio
1345
+
1346
+ from letta_client import AsyncLetta
1347
+
1348
+ client = AsyncLetta(
1349
+ token="YOUR_TOKEN",
1350
+ )
1351
+
1352
+
1353
+ async def main() -> None:
1354
+ await client.agents.reset_messages(
1355
+ agent_id="agent_id",
1356
+ )
1357
+
1358
+
1359
+ asyncio.run(main())
1360
+ """
1361
+ _response = await self._client_wrapper.httpx_client.request(
1362
+ f"v1/agents/{jsonable_encoder(agent_id)}/reset-messages",
1363
+ method="PATCH",
1364
+ params={
1365
+ "add_default_initial_messages": add_default_initial_messages,
1366
+ },
1367
+ request_options=request_options,
1368
+ )
1369
+ try:
1370
+ if 200 <= _response.status_code < 300:
1371
+ return typing.cast(
1372
+ AgentState,
1373
+ construct_type(
1374
+ type_=AgentState, # type: ignore
1375
+ object_=_response.json(),
1376
+ ),
1377
+ )
1378
+ if _response.status_code == 422:
1379
+ raise UnprocessableEntityError(
1380
+ typing.cast(
1381
+ HttpValidationError,
1382
+ construct_type(
1383
+ type_=HttpValidationError, # type: ignore
1384
+ object_=_response.json(),
1385
+ ),
1386
+ )
1387
+ )
1388
+ _response_json = _response.json()
1389
+ except JSONDecodeError:
1390
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1391
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1392
+
1253
1393
  async def search(
1254
1394
  self,
1255
1395
  *,
@@ -213,7 +213,7 @@ class TemplatesClient:
213
213
  self,
214
214
  agent_id: str,
215
215
  *,
216
- project_id: typing.Optional[str] = OMIT,
216
+ project: typing.Optional[str] = OMIT,
217
217
  request_options: typing.Optional[RequestOptions] = None,
218
218
  ) -> None:
219
219
  """
@@ -225,7 +225,7 @@ class TemplatesClient:
225
225
  ----------
226
226
  agent_id : str
227
227
 
228
- project_id : typing.Optional[str]
228
+ project : typing.Optional[str]
229
229
 
230
230
  request_options : typing.Optional[RequestOptions]
231
231
  Request-specific configuration.
@@ -249,7 +249,7 @@ class TemplatesClient:
249
249
  f"v1/agents/{jsonable_encoder(agent_id)}/template",
250
250
  method="POST",
251
251
  json={
252
- "project_id": project_id,
252
+ "project": project,
253
253
  },
254
254
  headers={
255
255
  "content-type": "application/json",
@@ -497,7 +497,7 @@ class AsyncTemplatesClient:
497
497
  self,
498
498
  agent_id: str,
499
499
  *,
500
- project_id: typing.Optional[str] = OMIT,
500
+ project: typing.Optional[str] = OMIT,
501
501
  request_options: typing.Optional[RequestOptions] = None,
502
502
  ) -> None:
503
503
  """
@@ -509,7 +509,7 @@ class AsyncTemplatesClient:
509
509
  ----------
510
510
  agent_id : str
511
511
 
512
- project_id : typing.Optional[str]
512
+ project : typing.Optional[str]
513
513
 
514
514
  request_options : typing.Optional[RequestOptions]
515
515
  Request-specific configuration.
@@ -541,7 +541,7 @@ class AsyncTemplatesClient:
541
541
  f"v1/agents/{jsonable_encoder(agent_id)}/template",
542
542
  method="POST",
543
543
  json={
544
- "project_id": project_id,
544
+ "project": project,
545
545
  },
546
546
  headers={
547
547
  "content-type": "application/json",
@@ -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