-
Notifications
You must be signed in to change notification settings - Fork 145
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
langchain-google-vertexai: Update vision_models.py to allow kwargs usage #473
Conversation
Alternatively, instead of disabling the filtering out of non-default keys contained inside |
Thanks for your contribution! @efriis @baskaryan What is the general approach, should we be graceful to any argument in **kwargs that is not accepted by the underlying model, or should we fail? Maybe I'm overthinking here. |
Thank you very much for your feedback!
While reading at the code my thought was "it depends on what is the exact purpose of To give an idea of the amount of currently unhandled parameters, that are filtered out with current code version, the following are the parameters actually supported by
I think any solution allowing to use at least all parameters currently supported by methods defined inside _vision_models.py (also simply adding them to From the mantaining POV, adding all supported params to |
68ef342
to
0ec1efb
Compare
@TommasoPetrolito feel free to take a look how it works here, please:
maybe we could align the approach, wdyt? |
Update vision_models.py to allow kwargs usage. Remove filtering that was keeping only default keys values.
0ec1efb
to
c8cfbaa
Compare
Hello @lkuligin, thank you again for your feedback, it is not 100% clear to me what you mean here. Do you suggest to proceed on a code change approach involving checks on the supported parameters that imitates / is coherently aligned with the code as done here:
? Or you mean that we should discuss the approach a bit further here and align our views on the approach after a discussion? I can, for sure, change my code proposal inside vision_models.py to include a supported_params specific variable/property for each vision model (listing all supported parameters already handled by vertexai library vision models) in the same way as done here:
and implement coherently a check with filtering based on those variable/property instead of default_params, that would then be used only for the automatic filling-in of default values for those default_params key=value pairs, not to filter out params. What do you think? Thank you again. |
Checklist for PR Creation
PR Title: "langchain-google-vertexai: Update vision_models.py to allow kwargs usage"
PR Description and Relevant issues:
_prepare_params()
methods in order to avoid that keys not included in default parameters are filtered out systematicallychanged to:
messages[0].additional_kwargs
, insteadkwargs
coming from outer functions calls were not taken into account and have been added:changed to:
Relevant issues: It was not possible to use kwargs like
{"safety_filter_level": "block_few", "person_generation": "allow_all"}
fromlangchain-core
BaseChatModel
invoke()
method. They got filtered out and never reached the final image generation call.No specific dependencies required for this fix.
Add Tests and Docs:
Lint and Test:
PR Description
This PR addresses the impossibility to use additional kwargs with models classes' methods inside langchain_google_vertexai/vision_models.py. E.g.: It was not possible to pass parameters like
{"safety_filter_level": "block_few", "person_generation": "allow_all"}
to the image generation, these parameters used to get filtered out systematically.Relevant issues
Type
🐛 Bug Fix