mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-24 00:18:24 +00:00
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.
This commit is contained in:
parent
42d979efdd
commit
5d6b83d9cf
@ -70,7 +70,10 @@ class BaseModeration:
|
|||||||
elif isinstance(prompt, str):
|
elif isinstance(prompt, str):
|
||||||
return text
|
return text
|
||||||
elif isinstance(prompt, ChatPromptValue):
|
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]
|
message = messages[self.chat_message_index]
|
||||||
|
|
||||||
if isinstance(message, HumanMessage):
|
if isinstance(message, HumanMessage):
|
||||||
|
Loading…
Reference in New Issue
Block a user