-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
feat(instrumentation): new spans for llms #13565
Conversation
@@ -253,3 +254,19 @@ async def astream_complete( | |||
print(response.text, end="", flush=True) | |||
``` | |||
""" | |||
|
|||
def __init_subclass__(cls, **kwargs) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohhhh this is nice!
Up to now, I've been resorting to decorating the subclasses individually. If I'm reading this correctly, then this new hook allows for "decorating" these methods with span automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, all subclasses will have these methods decorated automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add a docstring to this method to explain what's happening in here for future devs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -209,6 +209,19 @@ def dummy_wrapper(_self: Any, *args: Any, **kwargs: Any) -> Any: | |||
if not is_wrapped: | |||
f.__wrapped__ = True # type: ignore | |||
|
|||
for attr in ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a comment for what this is doing? I actually don't quite get what is happening here haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, @RogerHYang -- thanks!
Before
After
Code