Skip to content

How to use rate limit in add_routes #683

Answered by eyurtsev
kientv asked this question in Q&A
Discussion options

You must be logged in to vote

Easiest way is to prepend a runnable lambda to your runnable. That runnable lambda should be a passthrough that implements a rate limiting algorithm. The easiest way to do this is using a token bucket algorithm. We haven't built in support into the framework for this yet. In the meanwhile you can adapt the code here: https://github.com/langchain-ai/langchain-benchmarks/blob/main/langchain_benchmarks/rate_limiting.py#L90

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kientv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants