Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,50 +11,53 @@ import re
|
|
| 11 |
import ast
|
| 12 |
import time
|
| 13 |
from collections import deque
|
| 14 |
-
from dotenv import load_dotenv
|
| 15 |
import gradio as gr
|
| 16 |
from google import genai
|
| 17 |
|
| 18 |
-
load_dotenv()
|
| 19 |
-
|
| 20 |
|
| 21 |
# ---------------------------------------------------------------------------
|
| 22 |
# MODULE 3 — Pre-processing Module
|
| 23 |
# ---------------------------------------------------------------------------
|
| 24 |
-
def
|
| 25 |
-
|
| 26 |
-
#ROLE
|
| 27 |
-
You are
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
```
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
2. Examine each line of the Python code.
|
| 41 |
3. Determine whether the code fulfils ALL requirements stated in the description.
|
| 42 |
-
4. Estimate
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
...
|
| 57 |
-
|
|
|
|
| 58 |
"""
|
| 59 |
return prompt
|
| 60 |
|
|
|
|
| 11 |
import ast
|
| 12 |
import time
|
| 13 |
from collections import deque
|
|
|
|
| 14 |
import gradio as gr
|
| 15 |
from google import genai
|
| 16 |
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# ---------------------------------------------------------------------------
|
| 19 |
# MODULE 3 — Pre-processing Module
|
| 20 |
# ---------------------------------------------------------------------------
|
| 21 |
+
def build_prompt(description: str, code: str) -> str:
|
| 22 |
+
prompt = f"""<start_of_turn>user
|
| 23 |
+
### ROLE
|
| 24 |
+
You are an expert Python code reviewer. Your sole task is to determine whether the
|
| 25 |
+
provided Python code correctly implements the behaviour described in the user's
|
| 26 |
+
requirements description.
|
| 27 |
+
### CONTEXT
|
| 28 |
+
Developers sometimes write code that does not fully satisfy the requirements they
|
| 29 |
+
were given. You will analyse the semantic relationship between a natural-language
|
| 30 |
+
description and a Python code snippet, then produce a structured evaluation report.
|
| 31 |
+
### INPUT DATA
|
| 32 |
+
**Requirements Description:**
|
| 33 |
+
{description.strip()}
|
| 34 |
+
**Python Code:**
|
| 35 |
+
```python
|
| 36 |
+
{code.strip()}
|
| 37 |
```
|
| 38 |
+
### TASK
|
| 39 |
+
1. Read the requirements description carefully.
|
| 40 |
+
2. Analyse the Python code line by line.
|
|
|
|
| 41 |
3. Determine whether the code fulfils ALL requirements stated in the description.
|
| 42 |
+
4. Estimate an accuracy percentage (0–100) reflecting how completely the code
|
| 43 |
+
matches the description.
|
| 44 |
+
5. List any specific requirements that are missing or incorrectly implemented.
|
| 45 |
+
### CONSTRAINTS
|
| 46 |
+
- Do NOT execute the code.
|
| 47 |
+
- Base your evaluation solely on static code analysis and logical reasoning.
|
| 48 |
+
- Keep feedback concise, clear, and actionable.
|
| 49 |
+
- Your response MUST follow the output format exactly.
|
| 50 |
+
### OUTPUT FORMAT
|
| 51 |
+
Respond only with the following structure — no extra text before or after:
|
| 52 |
+
RESULT: <PASS or FAIL>
|
| 53 |
+
ACCURACY: <integer 0-100>%
|
| 54 |
+
SUMMARY: <one sentence overall assessment>
|
| 55 |
+
ISSUES:
|
| 56 |
+
- <issue 1, or "None" if code fully matches the description>
|
| 57 |
+
- <issue 2>
|
| 58 |
...
|
| 59 |
+
<end_of_turn>
|
| 60 |
+
<start_of_turn>model
|
| 61 |
"""
|
| 62 |
return prompt
|
| 63 |
|