Make a copy of external data instead of mutating another object's attributes. (#11349)

Fix for a bug surfaced as part of #11339. `mypy` caught this since the
types didn't match up.
pull/11361/head
Predrag Gruevski 9 months ago committed by GitHub
parent 42d979efdd
commit 5d6b83d9cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -70,7 +70,10 @@ class BaseModeration:
elif isinstance(prompt, str):
return text
elif isinstance(prompt, ChatPromptValue):
messages = prompt.messages
# Copy the messages because we may need to mutate them.
# We don't want to mutate data we don't own.
messages = list(prompt.messages)
message = messages[self.chat_message_index]
if isinstance(message, HumanMessage):

Loading…
Cancel
Save