-
Notifications
You must be signed in to change notification settings - Fork 500
Add gateway-plugin support to generate image and video #1603
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
Conversation
Summary of ChangesHello @varungup90, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces comprehensive support for image and video generation functionalities within the existing gateway plugin. It updates external and internal routing configurations to accommodate new API endpoints, implements path rewriting for these requests, and refactors the response and request body processing to handle the specific requirements of image and video generation models. The changes aim to seamlessly integrate these new capabilities into the gateway's request flow. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds support for image and video generation endpoints to the gateway. The changes include adding new routes in the gateway configuration, rewriting paths in the gateway plugin, and handling the new request types.
My review has identified a critical issue in pkg/plugins/gateway/gateway_req_body.go where a path is unconditionally rewritten, which will break existing functionality. I've also noted a significant change in the gateway's path matching that could have unintended side effects and should be carefully considered. Additionally, there are a few opportunities for refactoring to improve code maintainability and future-proofing the design for video generation parameters. Please review the detailed comments.
| name: original_route | ||
| match: | ||
| prefix: "/v1" | ||
| prefix: "/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the prefix match from /v1 to / is a significant change that broadens the scope of this route considerably. It now matches all paths for requests that include a routing-strategy header. This could have unintended side effects on other routes that might not be intended to be handled by the original_destination_cluster. Please add a comment explaining why this change is necessary or consider if a more specific set of path prefixes could be used to avoid accidentally capturing unintended traffic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the new added api endpoints all comes with v1. what's the reason to change from /v1 to /?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User requests are for /v1/image/generations and /v1/video/generations, but for xDit engine requests path are modified to /generate and /generatevideo respectively.
@happyandslow is trying to work with xdit team, if they can also use open ai protocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@happyandslow did you create any issues or talk to any person? any estimated DDL?
| case "/v1/image/generations", "/v1/video/generations": | ||
| imageGenerationObj := openai.ImageGenerateParams{} | ||
| if err := json.Unmarshal(requestBody, &imageGenerationObj); err != nil { | ||
| klog.ErrorS(err, "error to unmarshal image generations object", "requestID", requestID, "requestBody", string(requestBody)) | ||
| errRes = buildErrorResponse(envoyTypePb.StatusCode_BadRequest, "error processing request body", HeaderErrorRequestBodyProcessing, "true") | ||
| return | ||
| } | ||
| model = imageGenerationObj.Model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the same openai.ImageGenerateParams struct for both /v1/image/generations and /v1/video/generations might be limiting if the video generation API has different parameters than the image generation one. For example, video generation might involve parameters like duration or frames per second, which are not present in ImageGenerateParams. If the APIs are expected to diverge, consider defining a separate struct for video generation to improve type safety and clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right now, open ai does not have /v1/video/generations API, hence re-using the /v1/image/generations for now.
| { | ||
| Path: &gatewayv1.HTTPPathMatch{ | ||
| Type: ptr.To(gatewayv1.PathMatchPathPrefix), | ||
| Value: ptr.To("/generatevideo"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the api sepc on the engine side now? is it finalized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1595 we can have the discussion in this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @happyandslow
| code := envoyTypePb.StatusCode_InternalServerError | ||
| if res.Code >= 100 && res.Code < 600 { | ||
| code = envoyTypePb.StatusCode(res.Code) | ||
| if isLanguageRequest(routerCtx.ReqPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any else logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is no else right now, if request is off type image or video, then ignore response processing and return response to user.
Once we add more features for example support for async request then there will be else case.
Signed-off-by: varungupta <[email protected]>
Signed-off-by: varungupta <[email protected]>
3b1c99e to
773ef6e
Compare
|
overall LGTM |
Pull Request Description
Samples
Related Issues
Resolves: #[Insert issue number(s)]
Important: Before submitting, please complete the description above and review the checklist below.
Contribution Guidelines (Expand for Details)
We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:
Pull Request Title Format
Your PR title should start with one of these prefixes to indicate the nature of the change:
[Bug]: Corrections to existing functionality[CI]: Changes to build process or CI pipeline[Docs]: Updates or additions to documentation[API]: Modifications to aibrix's API or interface[CLI]: Changes or additions to the Command Line Interface[Misc]: For changes not covered above (use sparingly)Note: For changes spanning multiple categories, use multiple prefixes in order of importance.
Submission Checklist
By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.