zach commited on
Commit
982a304
·
1 Parent(s): 140521a

Improve error messages raised in validate_prompt_length util

Browse files
Files changed (1) hide show
  1. src/utils.py +4 -4
src/utils.py CHANGED
@@ -107,15 +107,15 @@ def validate_prompt_length(prompt: str, max_length: int, min_length: int) -> Non
107
  # Check if prompt is too short
108
  if prompt_length < min_length:
109
  raise ValueError(
110
- f'Error: prompt must be at least {min_length} character(s) long. '
111
- f'Received only {prompt_length}.'
112
  )
113
 
114
  # Check if prompt exceeds max length
115
  if prompt_length > max_length:
116
  raise ValueError(
117
- f'Error: the prompt exceeds the maximum allowed length of {max_length} characters. '
118
- f'Your prompt contains {prompt_length} characters.'
119
  )
120
 
121
  logger.debug(f'Prompt length validation passed for prompt: {truncate_text(stripped_prompt)}')
 
107
  # Check if prompt is too short
108
  if prompt_length < min_length:
109
  raise ValueError(
110
+ f'Your prompt is too short. Please enter at least {min_length} characters. '
111
+ f'(Current length: {prompt_length})'
112
  )
113
 
114
  # Check if prompt exceeds max length
115
  if prompt_length > max_length:
116
  raise ValueError(
117
+ f'Your prompt is too long. Please limit it to {max_length} characters. '
118
+ f'(Current length: {prompt_length})'
119
  )
120
 
121
  logger.debug(f'Prompt length validation passed for prompt: {truncate_text(stripped_prompt)}')