Skip to content

Commit 1e2f0ef

Browse files
committed
Revert "Bugfix: removed length limit on submissions"
This reverts commit 72f56e6.
1 parent 72f56e6 commit 1e2f0ef

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/math_tutor.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _load_environment(self, env_path: str):
3333
def get_num_tokens(self):
3434
return self.tokens_processed, self.tokens_emitted
3535

36-
def process_input(self, submission: str, exemplary_solution: str, temperature: float = 0.0, model: str = None) -> str:
36+
def process_input(self, submission: str, exemplary_solution: str, temperature: float = 0.0, model: str = None) -> Tuple[str, str]:
3737
"""
3838
process_input takes a submission (question and associated answer) and an exemplary solution (can be "No exemplary solution provided") and returns feedback and assessed correctness.
3939
:param question: The question to be answered.
@@ -65,6 +65,9 @@ def process_input(self, submission: str, exemplary_solution: str, temperature: f
6565
raise ValueError(f"Submissions that are provided without an exemplary answer must be formatted as a question and answer separated by 'Answer:'.")
6666
except ValueError:
6767
raise ValueError(f"Submissions that are provided without an exemplary answer must be formatted as a question and answer separated by 'Answer:'.")
68+
# Check submission length
69+
if len(submission) > 5000:
70+
return "I apologize, but your submission is too long. Please limit your submission to 5000 characters or less.", "incorrect"
6871

6972
# Call OpenAI moderation endpoint
7073
moderation_response = self.client.moderations.create(input=submission)

0 commit comments

Comments
 (0)