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

Improve handling of errors from Anthropic #2225

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

anth-volk
Copy link
Collaborator

@anth-volk anth-volk commented Feb 27, 2025

Fixes #2223.

This PR simplifies our approach to interacting with Claude, improves error handling, allows Claude to determine streaming chunk size (potentially making streaming faster), and improves code quality.

Following merging of this, accompanying changes to front end are also required. However, these API changes are not breaking, meaning they can be handled separately.

#2223 was caused by an "overloaded" error from Anthropic. Currently, we handle this by just indicating an error, but in this case, it's very much not our fault. This code (as well as the accompanying front-end changes) aims to highlight that the cause is, in fact, Claude.

Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 97.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 75.84%. Comparing base (c347b6e) to head (6c92457).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
policyengine_api/services/ai_analysis_service.py 95.23% 0 Missing and 1 partial ⚠️
tests/unit/services/test_ai_analysis_service.py 96.77% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2225      +/-   ##
==========================================
+ Coverage   75.39%   75.84%   +0.44%     
==========================================
  Files          81       83       +2     
  Lines        3130     3192      +62     
  Branches      344      348       +4     
==========================================
+ Hits         2360     2421      +61     
  Misses        702      702              
- Partials       68       69       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@anth-volk anth-volk marked this pull request as ready for review February 27, 2025 23:33
@anth-volk anth-volk requested a review from MaxGhenis February 27, 2025 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AI policy reform summary fails
1 participant