File size: 2,252 Bytes
b29139f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from typing import Dict, Any, Optional, List
from pydantic import BaseModel, Field
from typing import Literal

class ParsedComment(BaseModel):
    """
    Represents a single parsed comment from the LLM's review,
    intended for grouping by file/function.
    """
    message: str
    suggestion: Optional[str] = None

    def __repr__(self):
        return f"ParsedComment(msg='{self.message[:50]}...', has_suggestion={self.suggestion is not None})"

class ParsedReviewSection(BaseModel):
    """
    Represents a categorized section of the review, e.g., 'Potential Issues'.
    """
    title: str
    content: str

    def __repr__(self):
        return f"ParsedReviewSection(title='{self.title}', content='{self.content[:50]}...')"

class FileReviewComments(BaseModel):
    """
    Represents comments specific to a file, potentially grouped by function or general file comments.
    """
    file_path: str
    sections: Dict[str, List[ParsedComment]] = Field(default_factory=dict)

class LLMReviewOutput(BaseModel):
    """
    Structured data representing the comprehensive review output from the LLM.
    """
    overall_impression: Optional[str] = None
    file_reviews: List[FileReviewComments] = Field(default_factory=list)
    general_sections: List[ParsedReviewSection] = Field(default_factory=list)
    summary: Optional[str] = None
    approval_status: str = "Comment"

class PRReviewState(BaseModel):
    repo_name: str
    pr_id: int
    pr_title: Optional[str]
    code_diff: Optional[str]
    file_contents: Optional[Dict[str, str]]
    llm_markdown_review: Optional[str]
    parsed_llm_review_data: Optional[LLMReviewOutput] = None
    main_comment_body: Optional[str]
    review_status: Literal[
        "initiated",
        "code_fetched",
        "code_reviewed",
        "review_parsed",
        "initial_review_posted",
        "awaiting_human_approval",
        "review_submitted",
        "review_dismissed",
        "error"
    ]
    require_human_approval: bool
    human_approval_status: Optional[bool]
    human_feedback_message: Optional[str]
    original_review_id: Optional[int]
    original_review_url: Optional[str]
    final_review_id: Optional[int]
    final_review_url: Optional[str]
    last_error: Optional[str]