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
Hey there, @kunalhexus! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this together while we wait for a human maintainer.
The issue you're encountering with the UpstashRatelimitHandler not stopping the chain when a rate limit is exceeded might be due to how the error is being handled in the streaming context. The UpstashRatelimitError should be thrown when the rate limit is reached, but it seems like the error is not being caught properly in your try-catch block.
Here are a few suggestions to address this:
Ensure Proper Error Propagation: Make sure that the UpstashRatelimitError is being propagated correctly from the handler. The error should be thrown and not just logged. Verify that the handler is correctly integrated with the streamEvents method.
Check Error Handling in Streaming: The streamEvents method might handle errors differently compared to synchronous methods. Ensure that the error is not being swallowed by the streaming mechanism. You might need to handle the error within the stream processing logic itself.
Debugging: Add additional logging inside the streamEvents method to see if the error is being caught at any point before your try-catch block. This can help identify where the error handling might be failing.
Review Documentation and Tests: Check if there are any specific examples or test cases in the Langchain codebase that demonstrate handling UpstashRatelimitError in a streaming context. This might provide insights into the correct implementation.
If these steps do not resolve the issue, you might need to look into the implementation details of streamEvents and how it interacts with the callback mechanism to ensure that errors are handled as expected.
Checklist
Issue with current documentation:
I am following the instructions on this link for setting up rate limiting with upstash.
I am using
chain.streamEvents
for streaming, passing the rate limit handler to callbacks.On server side, I am able to see the rate limit error, but the chain still continues to run and return the correct response.
Doing something like below is not catching the exception
Idea or request for content:
Looking for correct way to use rate limiter with langchain
The text was updated successfully, but these errors were encountered: