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

core[patch]: On Chain Start Fix for Chain Class #26593

Merged
merged 17 commits into from
Sep 23, 2024

Conversation

keenborder786
Copy link
Contributor

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Sep 17, 2024
Copy link

vercel bot commented Sep 17, 2024

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Sep 23, 2024 7:27pm

@keenborder786
Copy link
Contributor Author

@eyurtsev please review

@dosubot dosubot bot added langchain Related to the langchain package 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Sep 17, 2024
Copy link
Collaborator

@eyurtsev eyurtsev left a comment

Choose a reason for hiding this comment

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

HI @keenborder786 thanks for the PR! this is not the correct fix. We removed the serialization representation on purpose. The tracer itself should be fixed to deal with no representation being passed.

@eyurtsev eyurtsev self-assigned this Sep 17, 2024
@eyurtsev
Copy link
Collaborator

Here's some context:
#26270
#26576

@eyurtsev
Copy link
Collaborator

@keenborder786 we'll also need a unit test to be added for the PR to be merged

@keenborder786
Copy link
Contributor Author

@eyurtsev okay understood, let me do it.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Sep 19, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Sep 20, 2024
@keenborder786
Copy link
Contributor Author

@eyurtsev review please

@keenborder786
Copy link
Contributor Author

@eyurtsev I have implemented the changes

@eyurtsev eyurtsev changed the title [Langchain]: On Chain Start Fix for Chain Class Langchain[patch]: On Chain Start Fix for Chain Class Sep 23, 2024
@eyurtsev eyurtsev changed the title Langchain[patch]: On Chain Start Fix for Chain Class core[patch]: On Chain Start Fix for Chain Class Sep 23, 2024
run_manager = callback_manager.on_chain_start(
None,
inputs,
run_id,
class_name=self.name,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a big decision!

on_chain_start here is an event dispatcher. By updating the information sent here the code sets the shape of dispatched on chain start events.

i.e., we should probably not be including class_name and lc_id in here, instead everything can be placed in the name logic if any additional attributes are needed

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm going to remove these additions since they're not necessary or desirable

@@ -32,8 +32,14 @@ def on_chain_start(
inputs (Dict[str, Any]): The inputs to the chain.
**kwargs (Any): Additional keyword arguments.
"""
class_name = serialized.get("name", serialized.get("id", ["<unknown>"])[-1])
print(f"\n\n\033[1m> Entering new {class_name} chain...\033[0m") # noqa: T201
if "name" in kwargs:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can fetch the name from kwargs here if present and otherwise fallback to serialized representation

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Sep 23, 2024
@@ -0,0 +1,44 @@
from typing import Any, Dict, List, Optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

awesome thank you for including the unit test

@eyurtsev eyurtsev enabled auto-merge (squash) September 23, 2024 19:27
@eyurtsev
Copy link
Collaborator

Should resolve: #26773

@eyurtsev eyurtsev merged commit 154a5ff into langchain-ai:master Sep 23, 2024
98 checks passed
@slyin87
Copy link

slyin87 commented Sep 24, 2024

@eyurtsev sorry to ask, so which version should I use to have this fix in place? How do I figure out based on this PR?

Sheepsta300 pushed a commit to Sheepsta300/langchain that referenced this pull request Oct 1, 2024
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 langchain Related to the langchain package lgtm PR looks good. Use to confirm that a PR is ready for merging. size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants