From 7956da93a822b65c2c2b2ed2ecb2e8a07aca3bc9 Mon Sep 17 00:00:00 2001 From: jnjpng Date: Mon, 5 May 2025 17:07:38 -0700 Subject: [PATCH] fix: skip warning logs for valid event types for anthropic (#2014) Co-authored-by: Jin Peng --- letta/llm_api/anthropic.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/letta/llm_api/anthropic.py b/letta/llm_api/anthropic.py index 08e70d06..6a2a6e55 100644 --- a/letta/llm_api/anthropic.py +++ b/letta/llm_api/anthropic.py @@ -115,6 +115,8 @@ MODEL_LIST = [ DUMMY_FIRST_USER_MESSAGE = "User initializing bootup sequence." +VALID_EVENT_TYPES = {"content_block_stop", "message_stop"} + def antropic_get_model_context_window(url: str, api_key: Union[str, None], model: str) -> int: for model_dict in anthropic_get_model_list(url=url, api_key=api_key): @@ -596,7 +598,8 @@ def convert_anthropic_stream_event_to_chatcompletion( redacted_reasoning_content = event.content_block.data else: warnings.warn("Unexpected content start type: " + str(type(event.content_block))) - + elif event.type in VALID_EVENT_TYPES: + pass else: warnings.warn("Unexpected event type: " + event.type)