Skip to content

Commit 51c4d6e

Browse files
author
User
committed
fix: diff changed to request body to binary and pro is enabled now
1 parent b6b8031 commit 51c4d6e

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

app/api/v1/review.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
@router.post("/diff", response_model=ReviewResponse, status_code=status.HTTP_200_OK)
99
async def review_diff(
10-
request: ReviewRequest
10+
file: UploadFile = File(...)
1111
) -> ReviewResponse:
1212
"""
13-
Accepts a diff as a string and returns review comments.
13+
Accepts a diff file and returns review comments.
1414
"""
15-
review_json = await review_diff_with_gemini(request.diff)
15+
diff = (await file.read()).decode("utf-8")
16+
review_json = await review_diff_with_gemini(diff)
1617
try:
1718
comments = [ReviewComment(**c) for c in review_json.get("comments", [])]
1819
except Exception as e:

app/integrations/gemini.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def sync_call():
3333
"* comment: A short, clear explanation of the issue or suggestion.\n"
3434
"* suggestion: strictly only code snippet (no explanation or wrapping)\n"
3535
"* confidence: A number (0–100) showing how sure you are about your comment.\n"
36-
"* filePath: The path of the changed file (from the +++ line in the diff).\n\n"
36+
"* filePath: The path of the changed file (from the +++ line in the diff).\n"
37+
"* language: The programming language of the file (e.g., 'python', 'javascript').\n\n"
3738
"---\n\n"
3839
"### Example Output\n\n"
3940
"{\n \"comments\": [\n {\n \"id\": \"1\",\n \"type\": \"issue\",\n \"severity\": \"high\",\n \"line\": 428,\n \"code\": \"$response = json_decode( $this->httpPost('salemansalesreturns/updateSaleReturnStatus'), true );\",\n \"comment\": \"This code is forwarding a request but seems to skip access control checks. That might let unauthenticated users trigger it.\",\n \"suggestion\": \"if (!is_authorized_user()) {\\n return new CakeResponse(array('body' => json_encode(['Result' => false, 'Reason' => 'Unauthorized'])));\\n}\",\n \"confidence\": 95,\n \"filePath\": \"app/Controller/SalesreturnsController.php\"\n },\n {\n \"id\": \"2\",\n \"type\": \"suggestion\",\n \"severity\": \"low\",\n \"line\": 422,\n \"code\": \"public function updateSaleReturnStatus( $responsetype = 'json' )\",\n \"comment\": \"The 'responsetype' parameter is not used in the function. It can be removed to simplify the code.\",\n \"suggestion\": \"public function updateSaleReturnStatus()\",\n \"confidence\": 90,\n \"filePath\": \"app/Controller/SalesreturnsController.php\"\n }\n ]\n}\n\n"
@@ -42,7 +43,7 @@ def sync_call():
4243
f"{diff}\n"
4344
)
4445
response = client.models.generate_content(
45-
model="gemini-2.5-flash",
46+
model="gemini-2.5-pro",
4647
contents=prompt
4748
)
4849
text = response.text.strip()

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ typing_extensions==4.14.0
3535
urllib3==2.5.0
3636
uvicorn==0.34.3
3737
websockets==15.0.1
38+
python-multipart==0.0.9

0 commit comments

Comments
 (0)