-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Router] Add custom callbacks service #264
base: main
Are you sure you want to change the base?
Conversation
74c5c0b
to
ccd8bdf
Compare
Thanks for this great PR! @1Yanik3 We will take a look soon. |
I think such logical modifications should be reflected in a technical document (e.g., in project docs) associated with the mutated component - in this case the router. It might make sense to begin writing technical architecture docs, and make updating them mandatory in logic changing PRs. |
ccd8bdf
to
bb1d46c
Compare
@vMaroon Thank you for the suggestion, you raise a very good point. I've added docs relating to how to use this feature to I think starting full technical architecture docs is a bit out of scope for this PR though, but I agree that long term those would make sense. |
Can you fix the failing check? Thanks! |
a37c2fb
to
87d07b0
Compare
Signed-off-by: Yanik Ammann <[email protected]>
87d07b0
to
1e9c192
Compare
Sorry for the delay, I forgot to ping you earlier. I've fixed the issues and all test are now passing locally so we should be good to go. |
This PR adds a way to call custom callbacks at two points in the code base, allowing the router to be used in places where custom business logic is required. The implementation is inspired by litellm's callback system.
The first point is right after a request comes in, where you can validate the request and return a response overwrite, which will return that response to the user and end the request. This can be used for api-key validation.
The second point is after a request has finished completely. This is achieved using background tasks, so it's non-blocking and can be used for logging.
More locations and callbacks can of course be added later, I suggest starting with only these two for now.
The way you define these points is by implementing an abstract class in a file and passing that file with:
And this is a reference implementation of how you can hook into the endpoints.
I'm open for improvement suggestions if you have any.
CLOSES #186
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
-s
when doinggit commit
[Bugfix]
,[Feat]
, and[CI]
.Detailed Checklist (Click to Expand)
Thank you for your contribution to production-stack! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]
for bug fixes.[CI/Build]
for build or continuous integration improvements.[Doc]
for documentation fixes and improvements.[Feat]
for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).[Router]
for changes to thevllm_router
(e.g., routing algorithm, router observability, etc.).[Misc]
for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
pre-commit
to format your code. SeeREADME.md
for installation.DCO and Signed-off-by
When contributing changes to this project, you must agree to the DCO. Commits must include a
Signed-off-by:
header which certifies agreement with the terms of the DCO.Using
-s
withgit commit
will automatically add this header.What to Expect for the Reviews
We aim to address all PRs in a timely manner. If no one reviews your PR within 5 days, please @-mention one of YuhanLiu11
, Shaoting-Feng or ApostaC.