You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: app/backend/error.py
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -9,10 +9,14 @@
9
9
"""
10
10
ERROR_MESSAGE_FILTER="""Your message contains content that was flagged by the OpenAI content filter."""
11
11
12
+
ERROR_MESSAGE_LENGTH="""Your message exceeded the context length limit for this OpenAI model. Please shorten your message or change your settings to retrieve fewer search results."""
"error": "Your message exceeded the context length limit for this OpenAI model. Please shorten your message or change your settings to retrieve fewer search results."
"error": "Your message exceeded the context length limit for this OpenAI model. Please shorten your message or change your settings to retrieve fewer search results."
Copy file name to clipboardExpand all lines: tests/test_app.py
+30Lines changed: 30 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,16 @@ def fake_response(http_code):
30
30
),
31
31
)
32
32
33
+
contextlength_response=BadRequestError(
34
+
message="This model's maximum context length is 4096 tokens. However, your messages resulted in 5069 tokens. Please reduce the length of the messages.",
35
+
body={
36
+
"message": "This model's maximum context length is 4096 tokens. However, your messages resulted in 5069 tokens. Please reduce the length of the messages.",
json={"messages": [{"content": "Super long message with lots of sources.", "role": "user"}]},
138
+
)
139
+
assertresponse.status_code==500
140
+
result=awaitresponse.get_json()
141
+
assert (
142
+
"Exception in /ask: This model's maximum context length is 4096 tokens. However, your messages resulted in 5069 tokens. Please reduce the length of the messages."
0 commit comments