letta-nightly 0.5.4.dev20241203104336__py3-none-any.whl → 0.5.4.dev20241204014655__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-nightly might be problematic. Click here for more details.

letta/client/client.py CHANGED
@@ -434,6 +434,7 @@ class RESTClient(AbstractClient):
434
434
  debug: bool = False,
435
435
  default_llm_config: Optional[LLMConfig] = None,
436
436
  default_embedding_config: Optional[EmbeddingConfig] = None,
437
+ headers: Optional[Dict] = None,
437
438
  ):
438
439
  """
439
440
  Initializes a new instance of Client class.
@@ -442,12 +443,16 @@ class RESTClient(AbstractClient):
442
443
  auto_save (bool): Whether to automatically save changes.
443
444
  user_id (str): The user ID.
444
445
  debug (bool): Whether to print debug information.
445
- default
446
+ default_llm_config (Optional[LLMConfig]): The default LLM configuration.
447
+ default_embedding_config (Optional[EmbeddingConfig]): The default embedding configuration.
448
+ headers (Optional[Dict]): The additional headers for the REST API.
446
449
  """
447
450
  super().__init__(debug=debug)
448
451
  self.base_url = base_url
449
452
  self.api_prefix = api_prefix
450
453
  self.headers = {"accept": "application/json", "authorization": f"Bearer {token}"}
454
+ if headers:
455
+ self.headers.update(headers)
451
456
  self._default_llm_config = default_llm_config
452
457
  self._default_embedding_config = default_embedding_config
453
458
 
letta/schemas/tool.py CHANGED
@@ -209,7 +209,7 @@ class ToolRun(LettaBase):
209
209
 
210
210
 
211
211
  class ToolRunFromSource(LettaBase):
212
+ source_code: str = Field(..., description="The source code of the function.")
212
213
  args: str = Field(..., description="The arguments to pass to the tool (as stringified JSON).")
213
- name: Optional[str] = Field(..., description="The name of the tool to run.")
214
- source_code: str = Field(None, description="The source code of the function.")
214
+ name: Optional[str] = Field(None, description="The name of the tool to run.")
215
215
  source_type: Optional[str] = Field(None, description="The type of the source code.")
@@ -37,7 +37,10 @@ def get_source(
37
37
  """
38
38
  actor = server.get_user_or_default(user_id=user_id)
39
39
 
40
- return server.source_manager.get_source_by_id(source_id=source_id, actor=actor)
40
+ source = server.source_manager.get_source_by_id(source_id=source_id, actor=actor)
41
+ if not source:
42
+ raise HTTPException(status_code=404, detail=f"Source with id={source_id} not found.")
43
+ return source
41
44
 
42
45
 
43
46
  @router.get("/name/{source_name}", response_model=str, operation_id="get_source_id_by_name")
@@ -52,6 +55,8 @@ def get_source_id_by_name(
52
55
  actor = server.get_user_or_default(user_id=user_id)
53
56
 
54
57
  source = server.source_manager.get_source_by_name(source_name=source_name, actor=actor)
58
+ if not source:
59
+ raise HTTPException(status_code=404, detail=f"Source with name={source_name} not found.")
55
60
  return source.id
56
61
 
57
62
 
@@ -94,6 +99,8 @@ def update_source(
94
99
  Update the name or documentation of an existing data source.
95
100
  """
96
101
  actor = server.get_user_or_default(user_id=user_id)
102
+ if not server.source_manager.get_source_by_id(source_id=source_id, actor=actor):
103
+ raise HTTPException(status_code=404, detail=f"Source with id={source_id} does not exist.")
97
104
  return server.source_manager.update_source(source_id=source_id, source_update=source, actor=actor)
98
105
 
99
106
 
@@ -186,13 +186,27 @@ def run_tool_from_source(
186
186
  """
187
187
  actor = server.get_user_or_default(user_id=user_id)
188
188
 
189
- return server.run_tool_from_source(
190
- tool_source=request.source_code,
191
- tool_source_type=request.source_type,
192
- tool_args=request.args,
193
- tool_name=request.name,
194
- user_id=actor.id,
195
- )
189
+ try:
190
+ return server.run_tool_from_source(
191
+ tool_source=request.source_code,
192
+ tool_source_type=request.source_type,
193
+ tool_args=request.args,
194
+ tool_name=request.name,
195
+ user_id=actor.id,
196
+ )
197
+ except LettaToolCreateError as e:
198
+ # HTTP 400 == Bad Request
199
+ print(f"Error occurred during tool creation: {e}")
200
+ # print the full stack trace
201
+ import traceback
202
+
203
+ print(traceback.format_exc())
204
+ raise HTTPException(status_code=400, detail=str(e))
205
+
206
+ except Exception as e:
207
+ # Catch other unexpected errors and raise an internal server error
208
+ print(f"Unexpected error occurred: {e}")
209
+ raise HTTPException(status_code=500, detail=f"An unexpected error occurred: {str(e)}")
196
210
 
197
211
 
198
212
  # Specific routes for Composio
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: letta-nightly
3
- Version: 0.5.4.dev20241203104336
3
+ Version: 0.5.4.dev20241204014655
4
4
  Summary: Create LLM agents with long-term memory and custom tools
5
5
  License: Apache License
6
6
  Author: Letta Team
@@ -13,7 +13,7 @@ letta/cli/cli.py,sha256=ALM82ZwsOxQLGiWkoLCr563Rt4Jdv25v4lcU-ThEYWw,16853
13
13
  letta/cli/cli_config.py,sha256=tB0Wgz3O9j6KiCsU1HWfsKmhNM9RqLsAxzxEDFQFGnM,8565
14
14
  letta/cli/cli_load.py,sha256=x4L8s15GwIW13xrhKYFWHo_y-IVGtoPDHWWKcHDRP10,4587
15
15
  letta/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- letta/client/client.py,sha256=u6sJDEU2Em0o79YI8fT8dOCtTI6JD5s1MZsMYgMbUdk,123559
16
+ letta/client/client.py,sha256=uUEpADbWwm7bhwv2mA4kllyDC6MpnfRKd8CLpP8kEt0,123907
17
17
  letta/client/streaming.py,sha256=Hh5pjlyrdCuO2V75ZCxSSOCPd3BmHdKFGaIUJC6fBp0,4775
18
18
  letta/client/utils.py,sha256=OJlAKWrldc4I6M1WpcTWNtPJ4wfxlzlZqWLfCozkFtI,2872
19
19
  letta/config.py,sha256=AF4XY6grcu87OLjrWXh1ufnyKWsCL0qER-_9jQCAlU0,18947
@@ -156,7 +156,7 @@ letta/schemas/organization.py,sha256=d2oN3IK2HeruEHKXwIzCbJ3Fxdi_BEe9JZ8J9aDbHwQ
156
156
  letta/schemas/passage.py,sha256=eYQMxD_XjHAi72jmqcGBU4wM4VZtSU0XK8uhQxxN3Ug,3563
157
157
  letta/schemas/sandbox_config.py,sha256=LC0hnB3TbFJmY7lXqVsseJkqTbxry0xmBB0bwI8Y7Rc,4769
158
158
  letta/schemas/source.py,sha256=B1VbaDJV-EGPv1nQXwCx_RAzeAJd50UqP_1m1cIRT8c,2854
159
- letta/schemas/tool.py,sha256=V8eTe2I1P9khanOJQYICmT0Fo_rMY599neGVW4Wn2Cw,9715
159
+ letta/schemas/tool.py,sha256=d88nXm9sH6xOH0d6DKiPehRFVUA5TsfkBBzOP7wmIY8,9715
160
160
  letta/schemas/tool_rule.py,sha256=pLt-BzgFSrlVO6ipY4kygyvfoM0BWA-XdqhGxso9aKs,1192
161
161
  letta/schemas/usage.py,sha256=lvn1ooHwLEdv6gwQpw5PBUbcwn_gwdT6HA-fCiix6sY,817
162
162
  letta/schemas/user.py,sha256=V32Tgl6oqB3KznkxUz12y7agkQicjzW7VocSpj78i6Q,1526
@@ -185,8 +185,8 @@ letta/server/rest_api/routers/v1/jobs.py,sha256=a-j0v-5A0un0pVCOHpfeWnzpOWkVDQO6
185
185
  letta/server/rest_api/routers/v1/llms.py,sha256=TcyvSx6MEM3je5F4DysL7ligmssL_pFlJaaO4uL95VY,877
186
186
  letta/server/rest_api/routers/v1/organizations.py,sha256=tyqVzXTpMtk3sKxI3Iz4aS6RhbGEbXDzFBB_CpW18v4,2080
187
187
  letta/server/rest_api/routers/v1/sandbox_configs.py,sha256=4tkTH8z9vpuBiGzxrS_wxkFdznnWZx-U-9F08czHMP8,5004
188
- letta/server/rest_api/routers/v1/sources.py,sha256=5Cs2YTSooh_WNT2C18PsdKzkyr4ZvaHt5Xjubyz0yJw,9196
189
- letta/server/rest_api/routers/v1/tools.py,sha256=jxw4DEM2OycGDOH4rVWMNQqtBqBJhXQruOpIYsVVyEk,8977
188
+ letta/server/rest_api/routers/v1/sources.py,sha256=HUbcBENk4RZDzxvP9tRANiWLX60nOkMdUCZ48jFGfk8,9630
189
+ letta/server/rest_api/routers/v1/tools.py,sha256=TP16cpuTF2HYLFZVmabExw9gziB-PtkExtWVkjxrRes,9553
190
190
  letta/server/rest_api/routers/v1/users.py,sha256=M1wEr2IyHzuRwINYxLXTkrbAH3osLe_cWjzrWrzR1aw,3729
191
191
  letta/server/rest_api/static_files.py,sha256=NG8sN4Z5EJ8JVQdj19tkFa9iQ1kBPTab9f_CUxd_u4Q,3143
192
192
  letta/server/rest_api/utils.py,sha256=6c5a_-ZFTlwZ1IuzpRQtqxSG1eD56nNhKhWlrdgBYWk,3103
@@ -220,8 +220,8 @@ letta/streaming_interface.py,sha256=_FPUWy58j50evHcpXyd7zB1wWqeCc71NCFeWh_TBvnw,
220
220
  letta/streaming_utils.py,sha256=329fsvj1ZN0r0LpQtmMPZ2vSxkDBIUUwvGHZFkjm2I8,11745
221
221
  letta/system.py,sha256=buKYPqG5n2x41hVmWpu6JUpyd7vTWED9Km2_M7dLrvk,6960
222
222
  letta/utils.py,sha256=iELiiJhSnijGDmwyk_T4NBJIqFUnEw_Flv9ZpSBUPFA,32136
223
- letta_nightly-0.5.4.dev20241203104336.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
224
- letta_nightly-0.5.4.dev20241203104336.dist-info/METADATA,sha256=TLAqq1J7qA4wMmkrsK-u1P1ryMPcgolT0ho-je8B7UQ,11505
225
- letta_nightly-0.5.4.dev20241203104336.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
226
- letta_nightly-0.5.4.dev20241203104336.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
227
- letta_nightly-0.5.4.dev20241203104336.dist-info/RECORD,,
223
+ letta_nightly-0.5.4.dev20241204014655.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
224
+ letta_nightly-0.5.4.dev20241204014655.dist-info/METADATA,sha256=72tFcDP8fTbbnLkZAyJFS3YNHkpSXkps4VGSWJ91Xlo,11505
225
+ letta_nightly-0.5.4.dev20241204014655.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
226
+ letta_nightly-0.5.4.dev20241204014655.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
227
+ letta_nightly-0.5.4.dev20241204014655.dist-info/RECORD,,