Feature: configuration based rest proxy support#1073
Merged
jmartin-tech merged 3 commits intoNVIDIA:mainfrom Jan 16, 2025
Merged
Feature: configuration based rest proxy support#1073jmartin-tech merged 3 commits intoNVIDIA:mainfrom
jmartin-tech merged 3 commits intoNVIDIA:mainfrom
Conversation
validates the `proxies` value if provided is a `dict` and passed on to the requests call
jmartin-tech
commented
Jan 13, 2025
Collaborator
Author
|
Note that this PR also suggest additional possible sensitive configuration details that may deserve warnings similar to #1049, the format for proxy endpoints can accept a basic auth proxy in a format like |
leondz
approved these changes
Jan 16, 2025
Collaborator
leondz
left a comment
There was a problem hiding this comment.
few minor points in comments, lgtm
| _config.plugins.generators["rest"]["RestGenerator"]["proxies"] = test_proxies | ||
| with pytest.raises(GarakException) as exc_info: | ||
| _plugins.load_plugin("generators.rest.RestGenerator", config_root=_config) | ||
| assert "not in the required format" in str(exc_info.value) |
| ) | ||
| generator._call_model("Who is Enabran Tain's son?") | ||
| mock_http_function.assert_called_once() | ||
| assert mock_http_function.call_args_list[0].kwargs["proxies"] == test_proxies |
Collaborator
There was a problem hiding this comment.
i guess maybe this isn't the strongest possible test we can do (we could check mock proxy logs), but validation shows that the code works (by tailing proxy logs)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds configuration based support for
proxiesto therest.RestGenerator.This extracts the proxy capability from @au70ma70n's PR #878
Verification
example rest_config.json, add any required configuration for your rest endpoint found here:
{ "rest": { "RestGenerator": { "uri": "http://my_internal_llm_endpoint", "proxies": { "http": "http://localhost:8080", "https": "https://localhost:8443", } } } }garak -m rest -G rest_config.json -p lmrchttpproxy.In theory this capability is possible to drive via environment variables as noted in the
requestslibrary docs, this PR enables a configuration based method for when environment variables are not available for the user to set, or instance ifgarakwere to be wrapped in an executor service.