Skip to content

Commit

Permalink
feat(issue summary) Receive optional possible cause scores (#84346)
Browse files Browse the repository at this point in the history
<!-- Describe your PR here. -->
schema from
[here](https://github.com/getsentry/seer/blob/696452da11113cec497029bfb92339d7660ead8d/src/seer/automation/summarize/models.py#L17-L28)
<!--

  Sentry employees and contractors can delete or ignore the following.

-->
  • Loading branch information
kddubey authored Jan 31, 2025
1 parent 5c7cc52 commit e37eb2e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/sentry/api/endpoints/group_ai_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@
from rest_framework.request import Request


class SummarizeIssueScores(BaseModel):
possible_cause_confidence: float
possible_cause_novelty: float


class SummarizeIssueResponse(BaseModel):
group_id: str
headline: str
whats_wrong: str | None = None
trace: str | None = None
possible_cause: str | None = None
scores: SummarizeIssueScores | None = None


@region_silo_endpoint
Expand Down
22 changes: 21 additions & 1 deletion tests/sentry/api/endpoints/test_group_ai_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

import orjson

from sentry.api.endpoints.group_ai_summary import GroupAiSummaryEndpoint, SummarizeIssueResponse
from sentry.api.endpoints.group_ai_summary import (
GroupAiSummaryEndpoint,
SummarizeIssueResponse,
SummarizeIssueScores,
)
from sentry.api.serializers.rest_framework.base import convert_dict_key_case, snake_to_camel_case
from sentry.testutils.cases import APITestCase, SnubaTestCase
from sentry.testutils.helpers.features import apply_feature_flag_on_cls
Expand Down Expand Up @@ -37,6 +41,10 @@ def test_ai_summary_get_endpoint_with_existing_summary(self, mock_call_seer):
"whats_wrong": "Existing whats wrong",
"trace": "Existing trace",
"possible_cause": "Existing possible cause",
"scores": {
"possible_cause_confidence": 0.9,
"possible_cause_novelty": 0.8,
},
}

# Set the cache with the existing summary
Expand Down Expand Up @@ -82,6 +90,10 @@ def test_ai_summary_get_endpoint_without_existing_summary(
whats_wrong="Test whats wrong",
trace="Test trace",
possible_cause="Test possible cause",
scores=SummarizeIssueScores(
possible_cause_confidence=0.0,
possible_cause_novelty=0.0,
),
)
mock_call_seer.return_value = mock_summary
mock_get_connected_issues.return_value = [self.group, self.group]
Expand Down Expand Up @@ -126,6 +138,10 @@ def test_ai_summary_call_seer(self, mock_get_event, mock_post):
"trace": "Test trace",
"possible_cause": "Test possible cause",
"headline": "Test headline",
"scores": {
"possible_cause_confidence": 0.9,
"possible_cause_novelty": 0.8,
},
}
mock_post.return_value = mock_response

Expand Down Expand Up @@ -230,6 +246,10 @@ def test_call_seer_payload(self):
"trace": "Test trace",
"possible_cause": "Test possible cause",
"headline": "Test headline",
"scores": {
"possible_cause_confidence": 0.9,
"possible_cause_novelty": 0.8,
},
}

self.client.post(self.url, format="json")
Expand Down

0 comments on commit e37eb2e

Please sign in to comment.