letta-nightly 0.6.47.dev20250331104251__py3-none-any.whl → 0.6.48.dev20250401104228__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.
- letta/__init__.py +1 -1
- letta/llm_api/anthropic_client.py +18 -12
- letta/schemas/message.py +1 -1
- {letta_nightly-0.6.47.dev20250331104251.dist-info → letta_nightly-0.6.48.dev20250401104228.dist-info}/METADATA +1 -1
- {letta_nightly-0.6.47.dev20250331104251.dist-info → letta_nightly-0.6.48.dev20250401104228.dist-info}/RECORD +8 -8
- {letta_nightly-0.6.47.dev20250331104251.dist-info → letta_nightly-0.6.48.dev20250401104228.dist-info}/LICENSE +0 -0
- {letta_nightly-0.6.47.dev20250331104251.dist-info → letta_nightly-0.6.48.dev20250401104228.dist-info}/WHEEL +0 -0
- {letta_nightly-0.6.47.dev20250331104251.dist-info → letta_nightly-0.6.48.dev20250401104228.dist-info}/entry_points.txt +0 -0
letta/__init__.py
CHANGED
|
@@ -6,6 +6,7 @@ import anthropic
|
|
|
6
6
|
from anthropic.types import Message as AnthropicMessage
|
|
7
7
|
|
|
8
8
|
from letta.errors import (
|
|
9
|
+
ContextWindowExceededError,
|
|
9
10
|
ErrorCode,
|
|
10
11
|
LLMAuthenticationError,
|
|
11
12
|
LLMBadRequestError,
|
|
@@ -112,21 +113,19 @@ class AnthropicClient(LLMClientBase):
|
|
|
112
113
|
|
|
113
114
|
# Messages
|
|
114
115
|
inner_thoughts_xml_tag = "thinking"
|
|
116
|
+
|
|
117
|
+
# Move 'system' to the top level
|
|
118
|
+
if messages[0].role != "system":
|
|
119
|
+
raise RuntimeError(f"First message is not a system message, instead has role {messages[0].role}")
|
|
120
|
+
data["system"] = messages[0].content if isinstance(messages[0].content, str) else messages[0].content[0].text
|
|
115
121
|
data["messages"] = [
|
|
116
122
|
m.to_anthropic_dict(
|
|
117
123
|
inner_thoughts_xml_tag=inner_thoughts_xml_tag,
|
|
118
124
|
put_inner_thoughts_in_kwargs=bool(self.llm_config.put_inner_thoughts_in_kwargs),
|
|
119
125
|
)
|
|
120
|
-
for m in messages
|
|
126
|
+
for m in messages[1:]
|
|
121
127
|
]
|
|
122
128
|
|
|
123
|
-
# Move 'system' to the top level
|
|
124
|
-
if data["messages"][0]["role"] != "system":
|
|
125
|
-
raise RuntimeError(f'First message is not a system message, instead has role {data["messages"][0]["role"]}')
|
|
126
|
-
|
|
127
|
-
data["system"] = data["messages"][0]["content"]
|
|
128
|
-
data["messages"] = data["messages"][1:]
|
|
129
|
-
|
|
130
129
|
# Ensure first message is user
|
|
131
130
|
if data["messages"][0]["role"] != "user":
|
|
132
131
|
data["messages"] = [{"role": "user", "content": DUMMY_FIRST_USER_MESSAGE}] + data["messages"]
|
|
@@ -164,10 +163,17 @@ class AnthropicClient(LLMClientBase):
|
|
|
164
163
|
|
|
165
164
|
if isinstance(e, anthropic.BadRequestError):
|
|
166
165
|
logger.warning(f"[Anthropic] Bad request: {str(e)}")
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
if "prompt is too long" in str(e).lower():
|
|
167
|
+
# If the context window is too large, we expect to receive:
|
|
168
|
+
# 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'prompt is too long: 200758 tokens > 200000 maximum'}}
|
|
169
|
+
return ContextWindowExceededError(
|
|
170
|
+
message=f"Bad request to Anthropic (context window exceeded): {str(e)}",
|
|
171
|
+
)
|
|
172
|
+
else:
|
|
173
|
+
return LLMBadRequestError(
|
|
174
|
+
message=f"Bad request to Anthropic: {str(e)}",
|
|
175
|
+
code=ErrorCode.INTERNAL_SERVER_ERROR,
|
|
176
|
+
)
|
|
171
177
|
|
|
172
178
|
if isinstance(e, anthropic.AuthenticationError):
|
|
173
179
|
logger.warning(f"[Anthropic] Authentication error: {str(e)}")
|
letta/schemas/message.py
CHANGED
|
@@ -681,7 +681,7 @@ class Message(BaseMessage):
|
|
|
681
681
|
user_system_event = add_xml_tag(string=f"SYSTEM ALERT: {text_content}", xml_tag="event")
|
|
682
682
|
anthropic_message = {
|
|
683
683
|
"content": user_system_event,
|
|
684
|
-
"role": "
|
|
684
|
+
"role": "user",
|
|
685
685
|
}
|
|
686
686
|
|
|
687
687
|
elif self.role == "user":
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
letta/__init__.py,sha256=
|
|
1
|
+
letta/__init__.py,sha256=ybkzV0FTH0Df6VATwyLpOuBWuSFNNe_qpMjvCbLxcls,918
|
|
2
2
|
letta/__main__.py,sha256=6Hs2PV7EYc5Tid4g4OtcLXhqVHiNYTGzSBdoOnW2HXA,29
|
|
3
3
|
letta/agent.py,sha256=swKmDf1bR1hD8VAIEl74-VgiQym0IAPxL4u9F7pvtBQ,69450
|
|
4
4
|
letta/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -55,7 +55,7 @@ letta/interfaces/openai_chat_completions_streaming_interface.py,sha256=SfqVp7V7A
|
|
|
55
55
|
letta/interfaces/utils.py,sha256=c6jvO0dBYHh8DQnlN-B0qeNC64d3CSunhfqlFA4pJTY,278
|
|
56
56
|
letta/llm_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
57
|
letta/llm_api/anthropic.py,sha256=PRppmT-aZq3i2s-iLg6O4AgxfPcHU5TNVgzppY0DaUY,43652
|
|
58
|
-
letta/llm_api/anthropic_client.py,sha256=
|
|
58
|
+
letta/llm_api/anthropic_client.py,sha256=SmV2vnFAK06XalITaF2HVnWGlYNGV8Pd3WmOiiWCM3Q,19710
|
|
59
59
|
letta/llm_api/aws_bedrock.py,sha256=kAPpKPRe4ZUa6fkxFbo8xwQgq4fJf3QoZEAP1LOCfaw,4168
|
|
60
60
|
letta/llm_api/azure_openai.py,sha256=Y8R9vDmruJnCr_EfmPj_oangX8gJPpiyhTppD9T8SHE,5168
|
|
61
61
|
letta/llm_api/azure_openai_constants.py,sha256=ZaR2IasJThijG0uhLKJThrixdAxLPD2IojfeaJ-KQMQ,294
|
|
@@ -193,7 +193,7 @@ letta/schemas/letta_response.py,sha256=pq-SxXQy5yZo1-DiAwV2mMURlUvz1Uu7HHR_tB1hM
|
|
|
193
193
|
letta/schemas/llm_config.py,sha256=xEAfwigMc5MDY6hUtLRhsWW6iZPlPUezo-ZOZzWB8cs,5953
|
|
194
194
|
letta/schemas/llm_config_overrides.py,sha256=-oRglCTcajF6UAK3RAa0FLWVuKODPI1v403fDIWMAtA,1815
|
|
195
195
|
letta/schemas/memory.py,sha256=GOYDfPKzbWftUWO9Hv4KW7xAi1EIQmC8zpP7qvEkVHw,10245
|
|
196
|
-
letta/schemas/message.py,sha256=
|
|
196
|
+
letta/schemas/message.py,sha256=lEgJBnp3swrVbc0lDhm02ajrJmkScIOaBu7Om9Ipb94,45341
|
|
197
197
|
letta/schemas/openai/chat_completion_request.py,sha256=MtqUG7YsgsbJ7Rdauw-NOSpwNBgYjpx00xxrY8jOvmQ,4092
|
|
198
198
|
letta/schemas/openai/chat_completion_response.py,sha256=yoepGZkg5PIobGqvATJruPdV4odpIUDHWniodSQo3PY,4433
|
|
199
199
|
letta/schemas/openai/chat_completions.py,sha256=l0e9sT9boTD5VBU5YtJ0s7qUtCfFGB2K-gQLeEZ2LHU,3599
|
|
@@ -301,8 +301,8 @@ letta/supervisor_multi_agent.py,sha256=EwdfgznrwKkJZpxU-HO6iofR4PINCnGuWEbKamO3A
|
|
|
301
301
|
letta/system.py,sha256=dnOrS2FlRMwijQnOvfrky0Lg8wEw-FUq2zzfAJOUSKA,8477
|
|
302
302
|
letta/tracing.py,sha256=RstWXpfWVF77nmb_ISORVWd9IQw2Ky3de40k_S70yKI,8258
|
|
303
303
|
letta/utils.py,sha256=AdHrQ2OQ3V4XhJ1LtYwbLUO71j2IJY37cIUxXPgaaRY,32125
|
|
304
|
-
letta_nightly-0.6.
|
|
305
|
-
letta_nightly-0.6.
|
|
306
|
-
letta_nightly-0.6.
|
|
307
|
-
letta_nightly-0.6.
|
|
308
|
-
letta_nightly-0.6.
|
|
304
|
+
letta_nightly-0.6.48.dev20250401104228.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
|
|
305
|
+
letta_nightly-0.6.48.dev20250401104228.dist-info/METADATA,sha256=HLRE51jqrC5o6FNnW7rvGTTzsfQv_OxC1FfKCsqUHu4,22937
|
|
306
|
+
letta_nightly-0.6.48.dev20250401104228.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
307
|
+
letta_nightly-0.6.48.dev20250401104228.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
|
|
308
|
+
letta_nightly-0.6.48.dev20250401104228.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|