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

🤖 Refactor and Cleanup of Root Cause Models #1639

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions src/seer/automation/autofix/components/root_cause/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,13 @@ class RootCauseRelevantContext(BaseModel):
description: str
snippet: Optional[RootCauseRelevantCodeSnippet]


class RootCauseAnalysisRelevantContext(BaseModel):
snippets: list[RootCauseRelevantContext]


class UnitTestSnippetPrompt(BaseModel):
file_path: str
code_snippet: str
description: str

@field_validator("code_snippet")
@classmethod
def clean_code_snippet(cls, v: str) -> str:
return remove_code_backticks(v)


class UnitTestSnippet(BaseModel):
file_path: str
snippet: str
description: str


class RootCauseAnalysisItem(BaseModel):
id: int = -1
title: str
description: str
# unit_test: UnitTestSnippet | None = None
# reproduction: str | None = None
code_context: Optional[list[RootCauseRelevantContext]] = None

def to_markdown_string(self) -> str:
Expand All @@ -91,25 +70,13 @@ def to_markdown_string(self) -> str:
class RootCauseAnalysisItemPrompt(BaseModel):
title: str
description: str
# reproduction_instructions: str | None = None
# unit_test: UnitTestSnippetPrompt | None = None
relevant_code: Optional[RootCauseAnalysisRelevantContext]

@classmethod
def from_model(cls, model: RootCauseAnalysisItem):
return cls(
title=model.title,
description=model.description,
# reproduction_instructions=model.reproduction,
# unit_test=(
# UnitTestSnippetPrompt(
# file_path=model.unit_test.file_path,
# code_snippet=model.unit_test.snippet,
# description=model.unit_test.description,
# )
# if model.unit_test
# else None
# ),
relevant_code=(
RootCauseAnalysisRelevantContext(
snippets=[
Expand All @@ -131,16 +98,6 @@ def to_model(self):
return RootCauseAnalysisItem.model_validate(
{
**self.model_dump(),
# "reproduction": self.reproduction_instructions,
# "unit_test": (
# {
# "file_path": self.unit_test.file_path,
# "snippet": self.unit_test.code_snippet,
# "description": self.unit_test.description,
# }
# if self.unit_test
# else None
# ),
"code_context": (
self.relevant_code.model_dump()["snippets"] if self.relevant_code else None
),
Expand Down
Loading