Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,46 +21,40 @@ load_dotenv()
|
|
| 21 |
# ---------------------------------------------------------------------------
|
| 22 |
# MODULE 3 — Pre-processing Module
|
| 23 |
# ---------------------------------------------------------------------------
|
| 24 |
-
def
|
| 25 |
-
prompt = f"""
|
| 26 |
-
#
|
| 27 |
-
You are
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
{description.strip()}
|
| 37 |
-
**Python Code:**
|
| 38 |
-
```python
|
| 39 |
-
{code.strip()}
|
| 40 |
```
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 44 |
3. Determine whether the code fulfils ALL requirements stated in the description.
|
| 45 |
-
4. Estimate
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
- <issue 1, or "None" if code fully matches the description>
|
| 60 |
-
- <issue 2>
|
| 61 |
...
|
| 62 |
-
|
| 63 |
-
<start_of_turn>model
|
| 64 |
"""
|
| 65 |
return prompt
|
| 66 |
|
|
|
|
| 21 |
# ---------------------------------------------------------------------------
|
| 22 |
# MODULE 3 — Pre-processing Module
|
| 23 |
# ---------------------------------------------------------------------------
|
| 24 |
+
def pre_processing(description, code):
|
| 25 |
+
prompt = f"""
|
| 26 |
+
#ROLE
|
| 27 |
+
You are a Python code reviewer. Your goal is to determine if the provided Python code strictly complies with the requirements mentioned by the user.
|
| 28 |
+
|
| 29 |
+
#CONTEXT
|
| 30 |
+
Developers may create code that does not entirely meet the specified requirements. You will examine the relationship between a natural-language description and a Python code sample and create a structured evaluation report.
|
| 31 |
+
|
| 32 |
+
#INPUT DATA
|
| 33 |
+
Description: {description}
|
| 34 |
+
Code: ```python
|
| 35 |
+
{code}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
```
|
| 37 |
+
|
| 38 |
+
#TASK
|
| 39 |
+
1. Carefully read the requirements description.
|
| 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 the accuracy in percentages to assess how accurately the code matches the description.
|
| 43 |
+
5. List specific requirements that are either absent or incorrectly applied.
|
| 44 |
+
6. Base your evaluation solely on static code analysis and logical reasoning.
|
| 45 |
+
|
| 46 |
+
#CONSTRAINTS
|
| 47 |
+
1. Do not execute the code.
|
| 48 |
+
2. The output must be in the specified format.
|
| 49 |
+
3. The output should be clear and concise.
|
| 50 |
+
|
| 51 |
+
#OUTPUT FORMAT (to be strictly followed without any changes)
|
| 52 |
+
Result: either "Pass" or "Fail" (Pass if the code is functional and matches the description, Fail if it has bugs or doesn't match).
|
| 53 |
+
Accuracy: an integer from 0 to 100 representing how well the code matches the description and is bug-free.
|
| 54 |
+
Review: a short prose explanation of the result (e.g. "Code correctly handles all described requirements including edge cases.").
|
| 55 |
+
Issues: The value should be a single string containing a numbered list. For each item, include the severity (Error, Warning, or Info) followed by a dash and description of the issue (e.g. "Missing type hints on function signature"). List each issue on a new line starting with a number. Use newline characters (\n) to separate each line.
|
|
|
|
|
|
|
| 56 |
...
|
| 57 |
+
|
|
|
|
| 58 |
"""
|
| 59 |
return prompt
|
| 60 |
|