ziyan14 commited on
Commit
12c635e
·
verified ·
1 Parent(s): 76154d1

Update app.py

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