-
Notifications
You must be signed in to change notification settings - Fork 88
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
Anthropic streaming response does not get logged #672
Comments
I think what's happening is that anthropic streaming response is wrapped again to anthropic MessageStream class, overwriting the stream_cls that logfire sets up.
Here raw_stream is correctly the type of LogfireInstrumentedStream but the response becomes MessageStream type because of this line. Not sure how to fix or circumvent this issue. |
I'm just going to monkey-patch it for now
|
Hi @qria, thanks for the report. Your diagnosis and overall solution were spot on, I couldn't see another way from within logfire. So I did start a branch with my own version of this patching: https://github.com/pydantic/logfire/compare/alex/anthropic-streaming But then I decided it would be better to fix the underlying issue in the anthropic SDK, so I opened the PR linked above. After that gets released, upgrading should fix the problem automatically. However, the maintainer who merged it said:
which is funny because actually your patch is very much relying on it - you will need to remove it to not get an error. Closing because I don't think there's more to do here. |
Description
Logfire does not log anthropic streaming response.
This is the resulting dashboard when I stream both openai and anthropic:
Anthropic streaming request gets logged but response does not.
Simple reproduction here: https://github.com/qria/logfire-bug-reproduction
Python, Logfire & OS Versions, related packages (not required)
The text was updated successfully, but these errors were encountered: