Spaces:
Running
Running
Anupriya
commited on
Commit
·
83edd7c
1
Parent(s):
34771bf
writing
Browse files- writting.py +18 -29
writting.py
CHANGED
|
@@ -109,35 +109,24 @@ def validate_response():
|
|
| 109 |
return jsonify({"error": "Both 'topic' and 'response' fields are required."}), 400
|
| 110 |
|
| 111 |
# Define the prompt for GPT to evaluate the response
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
"What is good:\n"
|
| 131 |
-
"- <two short points>\n"
|
| 132 |
-
"Needs fixing:\n"
|
| 133 |
-
"- <two short points>\n"
|
| 134 |
-
"Example fix:\n"
|
| 135 |
-
"- <rewrite one short sentence>\n"
|
| 136 |
-
"Score: <number>/10\n"
|
| 137 |
-
"Rules: Do not use angle brackets in the output. "
|
| 138 |
-
f"Topic: {topic}\n"
|
| 139 |
-
f"Student response: {response_text}"
|
| 140 |
-
)
|
| 141 |
|
| 142 |
messages = [
|
| 143 |
{"role": "system", "content": "You are a helpful writing teacher."},
|
|
|
|
| 109 |
return jsonify({"error": "Both 'topic' and 'response' fields are required."}), 400
|
| 110 |
|
| 111 |
# Define the prompt for GPT to evaluate the response
|
| 112 |
+
validation_prompt = (
|
| 113 |
+
f"You are a strict writing teacher. "
|
| 114 |
+
f"Score: <number>/10\n\n"
|
| 115 |
+
f"Check the student's response for grammar, spelling, punctuation, and sentence structure. "
|
| 116 |
+
f"Give feedback in simple, clear English that a 10-year-old can understand. "
|
| 117 |
+
f"Keep the feedback neat and easy to read. "
|
| 118 |
+
f"Use this exact format:\n\n"
|
| 119 |
+
f"What is good:\n"
|
| 120 |
+
f"- <two short points about strengths>\n"
|
| 121 |
+
f"Needs fixing:\n"
|
| 122 |
+
f"- <two short points about mistakes>\n"
|
| 123 |
+
f"How to improve:\n"
|
| 124 |
+
f"- <one short, clear tip or rewrite>\n"
|
| 125 |
+
|
| 126 |
+
f"Topic: '{topic}'. Response: '{response_text}'."
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
messages = [
|
| 132 |
{"role": "system", "content": "You are a helpful writing teacher."},
|