Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonOutputFunctionParser: Fix mutation in place bug #8758

Merged
merged 4 commits into from
Aug 7, 2023

Conversation

eyurtsev
Copy link
Collaborator

@eyurtsev eyurtsev commented Aug 4, 2023

Fixes mutation in place in the JsonOutputFunctionParser. This causes issues
when trying to re-use the original AI message.

@vercel
Copy link

vercel bot commented Aug 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2023 5:24pm

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Aug 4, 2023
@@ -25,8 +25,8 @@ def parse_result(self, result: List[Generation]) -> Any:
)
message = generation.message
try:
func_call = message.additional_kwargs["function_call"]
except ValueError as exc:
func_call = message.additional_kwargs["function_call"].copy()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be deep copied to be safe?

Copy link
Collaborator Author

@eyurtsev eyurtsev Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either works i favor shallow copies to keep things light weight though I think it hardly matters in this case as it's a tiny dict so deep copy works

@eyurtsev eyurtsev merged commit f616aee into master Aug 7, 2023
22 checks passed
@eyurtsev eyurtsev deleted the eugene/fix_mutation_in_place branch August 7, 2023 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants