Skip to content

Commit b27b7fe

Browse files
committed
feat(search): adds exception for text exceeding embedding limit
Introduces InputTooLongError, a subclass of SyntaxQueryError, to handle cases where input text exceeds the MAX_EMBEDDING_CHAR_LENGTH limit during embedding preparation.
1 parent 82ca152 commit b27b7fe

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cl/search/exception.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from enum import Enum
22
from http import HTTPStatus
33

4+
from django.conf import settings
45
from elasticsearch.exceptions import SerializationError
56
from rest_framework.exceptions import APIException
67

@@ -68,3 +69,12 @@ class InvalidRelativeDateSyntax(SyntaxQueryError):
6869
"""The date entered has an invalid format."""
6970

7071
message = "The date entered has an invalid format."
72+
73+
74+
class InputTooLongError(SyntaxQueryError):
75+
"""The input text is too long to be processed for embedding."""
76+
77+
message = (
78+
"The input is too long to process. The maximum allowed is "
79+
f"{settings.MAX_EMBEDDING_CHAR_LENGTH} characters."
80+
)

0 commit comments

Comments
 (0)