anyscale
#10001
input_length_error
Input too long: The number of tokens in the input exceeds the maximum allowed length of 4096 tokens. Please reduce the input size.
This error has been identified and solved.
Reason
The 400 status error you are encountering in the Anyscale API is due to the input exceeding the maximum allowed context length for the model. Here are the key points:
The error message indicates that the input resulted in 4469 tokens, but the model has a maximum context length of 4096 tokens.
This exceeds the limit set by the model, leading to a
400 Bad Request
error, specifically aPromptTooLongError
in this context.
Solution
To fix the 400 Bad Request
error due to the input exceeding the maximum allowed context length in the Anyscale API, you can take the following steps:
Ensure that the input prompt does not exceed the maximum context length of 4096 tokens. Here are some actions you can consider:
Shorten the input prompt: Reduce the length of the messages or completion to stay within the 4096-token limit.
Split the prompt: If necessary, split the input into multiple requests to avoid exceeding the token limit.
Optimize the input: Remove any unnecessary parts of the input to fit within the allowed token count.
Check for accumulated input: Ensure that the input is not continually accumulated, as this can cause the token count to exceed the limit over time.
Suggested Links
https://github.com/ray-project/ray/issues/31370
https://docs.anyscale.com/endpoints/text-generation/function-calling/
https://github.com/Significant-Gravitas/AutoGPT/issues/5529
https://docs.apigee.com/api-platform/troubleshoot/runtime/400-decompressionfailureatrequest
https://github.com/aallam/openai-kotlin/issues/301
https://forum.bubble.io/t/why-do-api-connector-requests-sometimes-return-a-400-error/321731
https://forum.bubble.io/t/how-to-catch-a-400-error-from-api-connector/27682
https://github.com/lm-sys/FastChat/issues/1749
https://community.klaviyo.com/developer-group-64/remove-email-from-list-gives-400-bad-request-error-with-error-message-error-nil-6671