From 86fe7a9af175ad7d9e51b1cf26d714cec3f623b0 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 9 Mar 2024 18:42:01 -0800 Subject: [PATCH] fix(anthropic.py): deep copy messages before popping system prompt --- litellm/llms/anthropic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litellm/llms/anthropic.py b/litellm/llms/anthropic.py index 5e0887901..becbcc328 100644 --- a/litellm/llms/anthropic.py +++ b/litellm/llms/anthropic.py @@ -1,7 +1,7 @@ import os, types import json from enum import Enum -import requests +import requests, copy import time, uuid from typing import Callable, Optional from litellm.utils import ModelResponse, Usage, map_finish_reason @@ -117,6 +117,7 @@ def completion( ): headers = validate_environment(api_key, headers) _is_function_call = False + messages = copy.deepcopy(messages) if model in custom_prompt_dict: # check if the model has a registered custom prompt model_prompt_details = custom_prompt_dict[model]