Skip to content

Add support for async calls in Anthropic and OpenAI integration #3497

New issue

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

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

Already on GitHub? # to your account

Merged
merged 34 commits into from
Oct 17, 2024

Conversation

vetyy
Copy link
Contributor

@vetyy vetyy commented Sep 4, 2024

This code should help resolve this issue: #3496


Thank you for contributing to sentry-python! Please add tests to validate your changes, and lint your code using tox -e linters.

Running the test suite on your PR might require maintainer approval. The AWS Lambda tests additionally require a maintainer to add a special label, and they will fail until this label is added.

@antonpirker
Copy link
Member

Thanks for the contribution @vetyy ! I have it on my list and will take a look next week

Copy link

codecov bot commented Sep 6, 2024

Codecov Report

Attention: Patch coverage is 81.60535% with 55 lines in your changes missing coverage. Please review.

Project coverage is 84.29%. Comparing base (891afee) to head (67e0cd5).
Report is 1 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/integrations/openai.py 78.77% 20 Missing and 18 partials ⚠️
sentry_sdk/integrations/anthropic.py 85.83% 10 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3497      +/-   ##
==========================================
- Coverage   84.32%   84.29%   -0.03%     
==========================================
  Files         133      133              
  Lines       14068    14226     +158     
  Branches     2380     2398      +18     
==========================================
+ Hits        11863    11992     +129     
- Misses       1471     1489      +18     
- Partials      734      745      +11     
Files with missing lines Coverage Δ
sentry_sdk/integrations/anthropic.py 85.11% <85.83%> (+2.08%) ⬆️
sentry_sdk/integrations/openai.py 81.71% <78.77%> (+3.00%) ⬆️

... and 4 files with indirect coverage changes

@antonpirker
Copy link
Member

Hey @vetyy !
I have reproduced the problem you are describing with async messages in Anthropic. I will have a deeper look at this PR on Monday and will try to bring it over the finish line.

@antonpirker antonpirker self-assigned this Oct 11, 2024
@antonpirker
Copy link
Member

Ok, I have merged this now with out current master and fixed some merge conflicts.

Tomorrow I will try to clean it up a bit.

Could you have a look at the failing Anthropic test @vetyy?

@antonpirker antonpirker changed the title Add support for async calls in Anthropic, OpenAI integrations Add support for async calls in Anthropic and OpenAI integration Oct 15, 2024
@antonpirker
Copy link
Member

Ok, Anthropic sis good with the last commit.

I will look at the OpenAI code now.

@antonpirker antonpirker added the Trigger: tests using secrets PR code is safe; run CI label Oct 16, 2024
@github-actions github-actions bot removed the Trigger: tests using secrets PR code is safe; run CI label Oct 16, 2024
@antonpirker antonpirker added the Trigger: tests using secrets PR code is safe; run CI label Oct 16, 2024
@github-actions github-actions bot removed the Trigger: tests using secrets PR code is safe; run CI label Oct 16, 2024
@antonpirker antonpirker added the Trigger: tests using secrets PR code is safe; run CI label Oct 16, 2024
@github-actions github-actions bot removed the Trigger: tests using secrets PR code is safe; run CI label Oct 16, 2024
@antonpirker antonpirker added the Trigger: tests using secrets PR code is safe; run CI label Oct 16, 2024
Copy link
Member

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

I have now refactored it a bit, tested it locally with example projects and added missing tests. Ready for merging!

@github-actions github-actions bot removed the Trigger: tests using secrets PR code is safe; run CI label Oct 17, 2024
@antonpirker antonpirker added the Trigger: tests using secrets PR code is safe; run CI label Oct 17, 2024
@antonpirker antonpirker enabled auto-merge (squash) October 17, 2024 07:49
@antonpirker antonpirker merged commit 9ae5820 into getsentry:master Oct 17, 2024
136 of 139 checks passed
@antonpirker
Copy link
Member

@vetyy your fix has been released in this version: https://pypi.org/project/sentry-sdk/2.17.0/

@vetyy vetyy deleted the async-llm branch October 17, 2024 09:30
@vetyy
Copy link
Contributor Author

vetyy commented Oct 17, 2024

@vetyy your fix has been released in this version: https://pypi.org/project/sentry-sdk/2.17.0/

❤️ thank you, much appreciated!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Trigger: tests using secrets PR code is safe; run CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants