Skip to content

feat(feedback): API endpoint for AI feedback summary #93134

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

Merged
merged 27 commits into from
Jun 12, 2025

Conversation

vishnupsatish
Copy link
Member

@vishnupsatish vishnupsatish commented Jun 9, 2025

Linear ticket: https://linear.app/getsentry/issue/REPLAY-292/api-endpoint-to-generate-summary-for-feedbacks

With tests

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 9, 2025
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 93.98148% with 13 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/sentry/feedback/usecases/feedback_summaries.py 69.56% 7 Missing ⚠️
...try/api/endpoints/organization_feedback_summary.py 88.46% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #93134      +/-   ##
==========================================
- Coverage   88.00%   87.95%   -0.05%     
==========================================
  Files       10260    10300      +40     
  Lines      591960   592519     +559     
  Branches    22978    22789     -189     
==========================================
+ Hits       520939   521138     +199     
- Misses      70531    70951     +420     
+ Partials      490      430      -60     

Comment on lines 191 to 195
# is this a bad use of patch?
@patch(
"sentry.api.endpoints.organization_feedback_summary.MAX_FEEDBACKS_TO_SUMMARIZE_CHARS",
1000,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Bad use of patch?

@vishnupsatish vishnupsatish marked this pull request as ready for review June 9, 2025 18:44
@vishnupsatish vishnupsatish requested review from a team as code owners June 9, 2025 18:44
@vishnupsatish vishnupsatish changed the title feat(feedback): API endpoint for AI summary of feedbacks feat(feedback): API endpoint for AI feedback summary Jun 9, 2025
@vishnupsatish
Copy link
Member Author

vishnupsatish commented Jun 10, 2025

are we waiting for a review on this from someone else?

@michellewzhang michellewzhang requested a review from cmanallen June 10, 2025 21:25
@michellewzhang
Copy link
Member

are we waiting for a review on this from someone else?

let's get @cmanallen to look at it

@vishnupsatish
Copy link
Member Author

Some tests in test_create_feedback are failing because the patch that was applied in test_organization_feedback_summary.py for some reason seem to not be cleaned up properly, so the monkeypatch that's applied in test_create_feedback doesn't work and it still uses the summary generation response.

Comment on lines +10 to +25
def make_input_prompt(
feedbacks,
):
feedbacks_string = "\n".join(f"- {msg}" for msg in feedbacks)
return f"""Task:
Instructions: You are an AI assistant that analyzes customer feedback.
Create a summary based on the user feedbacks that is at most three sentences, and complete the sentence "Users say...". Be concise, but specific in the summary.

User Feedbacks:

{feedbacks_string}

Output Format:

Summary: <1-3 sentence summary>
"""
Copy link
Member

Choose a reason for hiding this comment

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

Be aware. The AI team wants everything prompt related in Seer. I think its low risk to leave this here for now. But a future refactor should be considered where you proxy Seer.

"""


SUMMARY_REGEX = re.compile(r"Summary:\s*(.*)", re.DOTALL)
Copy link
Member

Choose a reason for hiding this comment

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

This is fine for now. But we can get structured output. There's many examples in Seer. Here's one I recently wrote: https://github.com/getsentry/seer/pull/2741/files#diff-798e03ed205a63e1198b21d0837bef5af0862f83704afafb084d68cff456ee4eR220-R251

@vishnupsatish
Copy link
Member Author

Updated this PR based on the reviews, currently waiting for tests to pass, is there anything else we need to do for this?

@vishnupsatish vishnupsatish merged commit 50c438b into master Jun 12, 2025
61 checks passed
@vishnupsatish vishnupsatish deleted the vishnupsatish/uf-summary-api-endpoint branch June 12, 2025 16:51
Copy link

sentry-io bot commented Jun 17, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ ValueError: Failed to parse AI feedback summary response /api/0/organizations/{organization_id_or_slug}/... View Issue

Did you find this useful? React with a 👍 or 👎

andrewshie-sentry pushed a commit that referenced this pull request Jun 19, 2025
Linear ticket:
https://linear.app/getsentry/issue/REPLAY-292/api-endpoint-to-generate-summary-for-feedbacks

With tests
- Includes changes from #92932
(adding the `feedbacksummaries` usecase)
- Q: Should the feature flag be added in this PR?
- Todo: add the `feedbacksummaries` usecase with its respective model in
getsentry options
--
- PR to add feedbacksummaries LLM usecase:
getsentry/getsentry#17647
- PRs to add feature flag:
#93162 and
getsentry/sentry-options-automator#4115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants