letta-nightly 0.5.1.dev20241101104122__py3-none-any.whl → 0.5.1.dev20241103104102__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 +10 -0
- letta/constants.py +0 -1
- letta/orm/sqlalchemy_base.py +10 -1
- letta/server/rest_api/app.py +4 -0
- letta/server/rest_api/routers/v1/agents.py +1 -1
- letta/server/rest_api/routers/v1/tools.py +12 -0
- letta/server/server.py +1 -1
- letta/services/tool_manager.py +35 -20
- {letta_nightly-0.5.1.dev20241101104122.dist-info → letta_nightly-0.5.1.dev20241103104102.dist-info}/METADATA +1 -1
- {letta_nightly-0.5.1.dev20241101104122.dist-info → letta_nightly-0.5.1.dev20241103104102.dist-info}/RECORD +13 -13
- {letta_nightly-0.5.1.dev20241101104122.dist-info → letta_nightly-0.5.1.dev20241103104102.dist-info}/LICENSE +0 -0
- {letta_nightly-0.5.1.dev20241101104122.dist-info → letta_nightly-0.5.1.dev20241103104102.dist-info}/WHEEL +0 -0
- {letta_nightly-0.5.1.dev20241101104122.dist-info → letta_nightly-0.5.1.dev20241103104102.dist-info}/entry_points.txt +0 -0
letta/client/client.py
CHANGED
|
@@ -225,6 +225,9 @@ class AbstractClient(object):
|
|
|
225
225
|
def get_tool_id(self, name: str) -> Optional[str]:
|
|
226
226
|
raise NotImplementedError
|
|
227
227
|
|
|
228
|
+
def add_base_tools(self) -> List[Tool]:
|
|
229
|
+
raise NotImplementedError
|
|
230
|
+
|
|
228
231
|
def load_data(self, connector: DataConnector, source_name: str):
|
|
229
232
|
raise NotImplementedError
|
|
230
233
|
|
|
@@ -1271,6 +1274,13 @@ class RESTClient(AbstractClient):
|
|
|
1271
1274
|
raise ValueError(f"Failed to get tool: {response.text}")
|
|
1272
1275
|
return response.json()
|
|
1273
1276
|
|
|
1277
|
+
def add_base_tools(self) -> List[Tool]:
|
|
1278
|
+
response = requests.post(f"{self.base_url}/{self.api_prefix}/tools/add-base-tools/", headers=self.headers)
|
|
1279
|
+
if response.status_code != 200:
|
|
1280
|
+
raise ValueError(f"Failed to add base tools: {response.text}")
|
|
1281
|
+
|
|
1282
|
+
return [Tool(**tool) for tool in response.json()]
|
|
1283
|
+
|
|
1274
1284
|
def create_tool(
|
|
1275
1285
|
self,
|
|
1276
1286
|
func: Callable,
|
letta/constants.py
CHANGED
letta/orm/sqlalchemy_base.py
CHANGED
|
@@ -107,23 +107,32 @@ class SqlalchemyBase(CommonSqlalchemyMetaMixins, Base):
|
|
|
107
107
|
"""
|
|
108
108
|
# Start the query
|
|
109
109
|
query = select(cls)
|
|
110
|
+
# Collect query conditions for better error reporting
|
|
111
|
+
query_conditions = []
|
|
110
112
|
|
|
111
113
|
# If an identifier is provided, add it to the query conditions
|
|
112
114
|
if identifier is not None:
|
|
113
115
|
identifier = cls.get_uid_from_identifier(identifier)
|
|
114
116
|
query = query.where(cls._id == identifier)
|
|
117
|
+
query_conditions.append(f"id='{identifier}'")
|
|
115
118
|
|
|
116
119
|
if kwargs:
|
|
117
120
|
query = query.filter_by(**kwargs)
|
|
121
|
+
query_conditions.append(", ".join(f"{key}='{value}'" for key, value in kwargs.items()))
|
|
118
122
|
|
|
119
123
|
if actor:
|
|
120
124
|
query = cls.apply_access_predicate(query, actor, access)
|
|
125
|
+
query_conditions.append(f"access level in {access} for actor='{actor}'")
|
|
121
126
|
|
|
122
127
|
if hasattr(cls, "is_deleted"):
|
|
123
128
|
query = query.where(cls.is_deleted == False)
|
|
129
|
+
query_conditions.append("is_deleted=False")
|
|
124
130
|
if found := db_session.execute(query).scalar():
|
|
125
131
|
return found
|
|
126
|
-
|
|
132
|
+
|
|
133
|
+
# Construct a detailed error message based on query conditions
|
|
134
|
+
conditions_str = ", ".join(query_conditions) if query_conditions else "no specific conditions"
|
|
135
|
+
raise NoResultFound(f"{cls.__name__} not found with {conditions_str}")
|
|
127
136
|
|
|
128
137
|
def create(self, db_session: "Session", actor: Optional["User"] = None) -> Type["SqlalchemyBase"]:
|
|
129
138
|
if actor:
|
letta/server/rest_api/app.py
CHANGED
|
@@ -9,6 +9,7 @@ from fastapi import FastAPI
|
|
|
9
9
|
from starlette.middleware.cors import CORSMiddleware
|
|
10
10
|
|
|
11
11
|
from letta.constants import ADMIN_PREFIX, API_PREFIX, OPENAI_API_PREFIX
|
|
12
|
+
from letta.schemas.letta_response import LettaResponse
|
|
12
13
|
from letta.server.constants import REST_DEFAULT_PORT
|
|
13
14
|
|
|
14
15
|
# NOTE(charles): these are extra routes that are not part of v1 but we still need to mount to pass tests
|
|
@@ -128,6 +129,9 @@ def create_application() -> "FastAPI":
|
|
|
128
129
|
openai_docs["info"]["title"] = "OpenAI Assistants API"
|
|
129
130
|
letta_docs["paths"] = {k: v for k, v in letta_docs["paths"].items() if not k.startswith("/openai")}
|
|
130
131
|
letta_docs["info"]["title"] = "Letta API"
|
|
132
|
+
letta_docs["components"]["schemas"]["LettaResponse"] = {
|
|
133
|
+
"properties": LettaResponse.model_json_schema(ref_template="#/components/schemas/LettaResponse/properties/{model}")["$defs"]
|
|
134
|
+
}
|
|
131
135
|
|
|
132
136
|
# Split the API docs into Letta API, and OpenAI Assistants compatible API
|
|
133
137
|
for name, docs in [
|
|
@@ -366,7 +366,7 @@ def update_message(
|
|
|
366
366
|
200: {
|
|
367
367
|
"description": "Successful response",
|
|
368
368
|
"content": {
|
|
369
|
-
"application/json": {"
|
|
369
|
+
"application/json": {"$ref": "#/components/schemas/LettaResponse"}, # Use model_json_schema() instead of model directly
|
|
370
370
|
"text/event-stream": {"description": "Server-Sent Events stream"},
|
|
371
371
|
},
|
|
372
372
|
}
|
|
@@ -104,3 +104,15 @@ def update_tool(
|
|
|
104
104
|
"""
|
|
105
105
|
actor = server.get_user_or_default(user_id=user_id)
|
|
106
106
|
return server.tool_manager.update_tool_by_id(tool_id, actor.id, request)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@router.post("/add-base-tools", response_model=List[Tool], operation_id="add_base_tools")
|
|
110
|
+
def add_base_tools(
|
|
111
|
+
server: SyncServer = Depends(get_letta_server),
|
|
112
|
+
user_id: Optional[str] = Header(None, alias="user_id"), # Extract user_id from header, default to None if not present
|
|
113
|
+
):
|
|
114
|
+
"""
|
|
115
|
+
Add base tools
|
|
116
|
+
"""
|
|
117
|
+
actor = server.get_user_or_default(user_id=user_id)
|
|
118
|
+
return server.tool_manager.add_base_tools(actor=actor)
|
letta/server/server.py
CHANGED
|
@@ -254,7 +254,7 @@ class SyncServer(Server):
|
|
|
254
254
|
self.default_org = self.organization_manager.create_default_organization()
|
|
255
255
|
self.default_user = self.user_manager.create_default_user()
|
|
256
256
|
self.add_default_blocks(self.default_user.id)
|
|
257
|
-
self.tool_manager.
|
|
257
|
+
self.tool_manager.add_base_tools(actor=self.default_user)
|
|
258
258
|
|
|
259
259
|
# If there is a default org/user
|
|
260
260
|
# This logic may have to change in the future
|
letta/services/tool_manager.py
CHANGED
|
@@ -18,6 +18,14 @@ from letta.utils import enforce_types
|
|
|
18
18
|
class ToolManager:
|
|
19
19
|
"""Manager class to handle business logic related to Tools."""
|
|
20
20
|
|
|
21
|
+
BASE_TOOL_NAMES = [
|
|
22
|
+
"send_message",
|
|
23
|
+
"conversation_search",
|
|
24
|
+
"conversation_search_date",
|
|
25
|
+
"archival_memory_insert",
|
|
26
|
+
"archival_memory_search",
|
|
27
|
+
]
|
|
28
|
+
|
|
21
29
|
def __init__(self):
|
|
22
30
|
# Fetching the db_context similarly as in OrganizationManager
|
|
23
31
|
from letta.server.server import db_context
|
|
@@ -137,8 +145,9 @@ class ToolManager:
|
|
|
137
145
|
raise ValueError(f"Tool with id {tool_id} not found.")
|
|
138
146
|
|
|
139
147
|
@enforce_types
|
|
140
|
-
def
|
|
141
|
-
"""Add default tools in
|
|
148
|
+
def add_base_tools(self, actor: PydanticUser) -> List[PydanticTool]:
|
|
149
|
+
"""Add default tools in base.py"""
|
|
150
|
+
module_name = "base"
|
|
142
151
|
full_module_name = f"letta.functions.function_sets.{module_name}"
|
|
143
152
|
try:
|
|
144
153
|
module = importlib.import_module(full_module_name)
|
|
@@ -155,22 +164,28 @@ class ToolManager:
|
|
|
155
164
|
warnings.warn(err)
|
|
156
165
|
|
|
157
166
|
# create tool in db
|
|
167
|
+
tools = []
|
|
158
168
|
for name, schema in functions_to_schema.items():
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
if name in self.BASE_TOOL_NAMES:
|
|
170
|
+
# print([str(inspect.getsource(line)) for line in schema["imports"]])
|
|
171
|
+
source_code = inspect.getsource(schema["python_function"])
|
|
172
|
+
tags = [module_name]
|
|
173
|
+
if module_name == "base":
|
|
174
|
+
tags.append("letta-base")
|
|
175
|
+
|
|
176
|
+
# create to tool
|
|
177
|
+
tools.append(
|
|
178
|
+
self.create_or_update_tool(
|
|
179
|
+
ToolCreate(
|
|
180
|
+
name=name,
|
|
181
|
+
tags=tags,
|
|
182
|
+
source_type="python",
|
|
183
|
+
module=schema["module"],
|
|
184
|
+
source_code=source_code,
|
|
185
|
+
json_schema=schema["json_schema"],
|
|
186
|
+
),
|
|
187
|
+
actor=actor,
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
return tools
|
|
@@ -13,11 +13,11 @@ letta/cli/cli.py,sha256=i6wFBaX8-WwZ6nl_T0FFptfozlnYEBM7RcShwBl-qfw,16106
|
|
|
13
13
|
letta/cli/cli_config.py,sha256=ynsezKawQ0l95rymlv-AJ3QjbqiyaXZyuzsDfBYwMwg,8537
|
|
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=
|
|
16
|
+
letta/client/client.py,sha256=H3BfhxEAW852mFsC6i5HXm50IkfU2I1dlS7KL1DNZvw,95824
|
|
17
17
|
letta/client/streaming.py,sha256=Hh5pjlyrdCuO2V75ZCxSSOCPd3BmHdKFGaIUJC6fBp0,4775
|
|
18
18
|
letta/client/utils.py,sha256=OJlAKWrldc4I6M1WpcTWNtPJ4wfxlzlZqWLfCozkFtI,2872
|
|
19
19
|
letta/config.py,sha256=eK-ip06ELHNYriInkgfidDvJxQ2tD1u49I-VLXB87nE,18929
|
|
20
|
-
letta/constants.py,sha256=
|
|
20
|
+
letta/constants.py,sha256=y0xZ9dxN4i0mBO5dFSakFPvWfLXlJPi2l5d8S5vv7cY,6487
|
|
21
21
|
letta/credentials.py,sha256=D9mlcPsdDWlIIXQQD8wSPE9M_QvsRrb0p3LB5i9OF5Q,5806
|
|
22
22
|
letta/data_sources/connectors.py,sha256=qO81ASB6V-vDPthfHYtZiyqcQDQPTT0NuD8hVwC6xI0,9907
|
|
23
23
|
letta/data_sources/connectors_helper.py,sha256=2TQjCt74fCgT5sw1AP8PalDEk06jPBbhrPG4HVr-WLs,3371
|
|
@@ -96,7 +96,7 @@ letta/orm/enums.py,sha256=KfHcFt_fR6GUmSlmfsa-TetvmuRxGESNve8MStRYW64,145
|
|
|
96
96
|
letta/orm/errors.py,sha256=somsGtotFlb3SDM6tKdZ5TDGwEEP3ppx47ICAvNMnkg,225
|
|
97
97
|
letta/orm/mixins.py,sha256=hZJFYnmSGklryuAOypvVhMgXyU7pgatGEun-p-2f_Fc,2457
|
|
98
98
|
letta/orm/organization.py,sha256=ccE0ShFWqWPdtXiCRkZCSeIERbtwU-a7AF99N3S6IRM,1468
|
|
99
|
-
letta/orm/sqlalchemy_base.py,sha256=
|
|
99
|
+
letta/orm/sqlalchemy_base.py,sha256=BPnegSQxW0SVnvje4H2441COBHfO30Tkwi2vG-9gwjY,8288
|
|
100
100
|
letta/orm/tool.py,sha256=4cYKSoogfpH4O0wruIqU8vzEGgiCOL3gQfG5doSqpDw,2089
|
|
101
101
|
letta/orm/user.py,sha256=69FU1rSXhlRJMaAUPYebxgFPn8UCQRU8TYUkjXLrALQ,1136
|
|
102
102
|
letta/persistence_manager.py,sha256=LlLgEDpSafCPAiyKmuq0NvVAnfBkZo6TWbGIKYQjQBs,5200
|
|
@@ -154,7 +154,7 @@ letta/schemas/user.py,sha256=toiA53UKB1hpH6k2xHyQNKVeDUoSB3RmLfxSwmKPAz4,1523
|
|
|
154
154
|
letta/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
155
155
|
letta/server/constants.py,sha256=yAdGbLkzlOU_dLTx0lKDmAnj0ZgRXCEaIcPJWO69eaE,92
|
|
156
156
|
letta/server/rest_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
157
|
-
letta/server/rest_api/app.py,sha256=
|
|
157
|
+
letta/server/rest_api/app.py,sha256=Iw6oVf3Lh8GEuKTMoEW57Wn21_iMbNps6Iz_DSd4qaU,6549
|
|
158
158
|
letta/server/rest_api/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
159
159
|
letta/server/rest_api/auth/index.py,sha256=fQBGyVylGSRfEMLQ17cZzrHd5Y1xiVylvPqH5Rl-lXQ,1378
|
|
160
160
|
letta/server/rest_api/auth_token.py,sha256=725EFEIiNj4dh70hrSd94UysmFD8vcJLrTRfNHkzxDo,774
|
|
@@ -168,18 +168,18 @@ letta/server/rest_api/routers/openai/assistants/threads.py,sha256=WXVGBaBvSNPB7Z
|
|
|
168
168
|
letta/server/rest_api/routers/openai/chat_completions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
169
169
|
letta/server/rest_api/routers/openai/chat_completions/chat_completions.py,sha256=-uye6cm4SnoQGwxhr1N1FrSXOlnO2Hvbfj6k8JSc45k,4918
|
|
170
170
|
letta/server/rest_api/routers/v1/__init__.py,sha256=sqlVZa-u9DJwdRsp0_8YUGrac9DHguIB4wETlEDRylA,666
|
|
171
|
-
letta/server/rest_api/routers/v1/agents.py,sha256=
|
|
171
|
+
letta/server/rest_api/routers/v1/agents.py,sha256=Dg_ZpQRVDP5vCOEiND7SWhnpGcraE5Qb4VZEdZhXprk,25509
|
|
172
172
|
letta/server/rest_api/routers/v1/blocks.py,sha256=0WekE_yBD2U3jYgPxI0DCFjACWavCAlvm_Ybw5SZBnw,2583
|
|
173
173
|
letta/server/rest_api/routers/v1/health.py,sha256=pKCuVESlVOhGIb4VC4K-H82eZqfghmT6kvj2iOkkKuc,401
|
|
174
174
|
letta/server/rest_api/routers/v1/jobs.py,sha256=a-j0v-5A0un0pVCOHpfeWnzpOWkVDQO6ti42k_qAlZY,2272
|
|
175
175
|
letta/server/rest_api/routers/v1/llms.py,sha256=TcyvSx6MEM3je5F4DysL7ligmssL_pFlJaaO4uL95VY,877
|
|
176
176
|
letta/server/rest_api/routers/v1/organizations.py,sha256=hCuni52aM1Gfmuu_BeodXAvTkfrvexEo_wZf8UtyaAM,2034
|
|
177
177
|
letta/server/rest_api/routers/v1/sources.py,sha256=eY_pk9jRL2Y9yIZdsTjH6EuKsfH1neaTU15MKNL0dvw,8749
|
|
178
|
-
letta/server/rest_api/routers/v1/tools.py,sha256=
|
|
178
|
+
letta/server/rest_api/routers/v1/tools.py,sha256=AYJP1dGqFLVZkWaypPi7TP7r53Vfz2Ejf_kWxmLl6IQ,4234
|
|
179
179
|
letta/server/rest_api/routers/v1/users.py,sha256=bxQ-YdevjDqmgNDfbSPAG_4KEVvPNBHD_-Lp1MdeMec,3374
|
|
180
180
|
letta/server/rest_api/static_files.py,sha256=NG8sN4Z5EJ8JVQdj19tkFa9iQ1kBPTab9f_CUxd_u4Q,3143
|
|
181
181
|
letta/server/rest_api/utils.py,sha256=GdHYCzXtbM5VCAYDPR0z5gnNZpRhwPld2BGZV7xT6cU,2924
|
|
182
|
-
letta/server/server.py,sha256=
|
|
182
|
+
letta/server/server.py,sha256=LxRrLkjosuxpAcL7mhKVY4dpZwH1QpNgWIo1tAJDkrs,78511
|
|
183
183
|
letta/server/startup.sh,sha256=Atyf4hL5XLpC4aA3esEyOeNWfemlgXlgpeKB59fDFvw,334
|
|
184
184
|
letta/server/static_files/assets/index-3ab03d5b.css,sha256=OrA9W4iKJ5h2Wlr7GwdAT4wow0CM8hVit1yOxEL49Qw,54295
|
|
185
185
|
letta/server/static_files/assets/index-9fa459a2.js,sha256=j2oMcDJO9dWJaH5e-tsflbVpWK20gLWpZKJk4-Kuy6A,1815592
|
|
@@ -194,15 +194,15 @@ letta/server/ws_api/protocol.py,sha256=M_-gM5iuDBwa1cuN2IGNCG5GxMJwU2d3XW93XALv9
|
|
|
194
194
|
letta/server/ws_api/server.py,sha256=C2Kv48PCwl46DQFb0ZP30s86KJLQ6dZk2AhWQEZn9pY,6004
|
|
195
195
|
letta/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
196
196
|
letta/services/organization_manager.py,sha256=wW4wOmKaqhHC7oTGWU38OO-dFtmRI0JVmq_k8gI1b0A,3658
|
|
197
|
-
letta/services/tool_manager.py,sha256=
|
|
197
|
+
letta/services/tool_manager.py,sha256=5hZLcrMVgBHGbbWdAoNYtRplrCJYlQOEr5NFGatGd-Q,8439
|
|
198
198
|
letta/services/user_manager.py,sha256=5wjmnhLoxsc9FCKD0IPotfV24i_iCqmifOkhIBvshtc,4404
|
|
199
199
|
letta/settings.py,sha256=yiYNmnYKj_BdTm0cBEIvQKYGU-lCmFntqsyVfRUy3_k,3411
|
|
200
200
|
letta/streaming_interface.py,sha256=_FPUWy58j50evHcpXyd7zB1wWqeCc71NCFeWh_TBvnw,15736
|
|
201
201
|
letta/streaming_utils.py,sha256=329fsvj1ZN0r0LpQtmMPZ2vSxkDBIUUwvGHZFkjm2I8,11745
|
|
202
202
|
letta/system.py,sha256=buKYPqG5n2x41hVmWpu6JUpyd7vTWED9Km2_M7dLrvk,6960
|
|
203
203
|
letta/utils.py,sha256=SXLEYhyp3gHyIjrxNIKNZZ5ittKo3KOj6zxgC_Trex0,31012
|
|
204
|
-
letta_nightly-0.5.1.
|
|
205
|
-
letta_nightly-0.5.1.
|
|
206
|
-
letta_nightly-0.5.1.
|
|
207
|
-
letta_nightly-0.5.1.
|
|
208
|
-
letta_nightly-0.5.1.
|
|
204
|
+
letta_nightly-0.5.1.dev20241103104102.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
|
|
205
|
+
letta_nightly-0.5.1.dev20241103104102.dist-info/METADATA,sha256=aVITwiq4ePInIMaR1LK_tTGWr-ivmsd4jFULoc0Vp9Y,10660
|
|
206
|
+
letta_nightly-0.5.1.dev20241103104102.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
207
|
+
letta_nightly-0.5.1.dev20241103104102.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
|
|
208
|
+
letta_nightly-0.5.1.dev20241103104102.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|