-
Notifications
You must be signed in to change notification settings - Fork 227
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
Feature: configurable plugins #711
Feature: configurable plugins #711
Conversation
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
* consitent api_key attribute name Signed-off-by: Jeffrey Martin <[email protected]>
RasaRestGenerator implementation was a copy of RestGenerator with some modified defaults. Lift defaults to class constants and override. This is a breaking change to Rasa as the implementation was still expecting the `rest` namespace in configuration files. Signed-off-by: Jeffrey Martin <[email protected]>
When a plugin provides `_supported_params` only the supported params should be applied from configuration files or cli options. Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
* cleaner plugin eval * add DEFAULT_PARAMS for instance values Signed-off-by: Jeffrey Martin <[email protected]>
* shift all configurable class variables into DEFAULT_PARAMS * inject all default params as instance attributes * provide exmaple for `_supported_params` in class definitions * propogate keys in the plugin yaml dictionalry as attributed on plugin instantiation * mechanism based on ENV_VAR class constant to obtain `api_key` during instantiation * remove plugin configuration methods in favor of `Configurable` * update buff configuration test Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
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.
Looking good. Few questions, many around precendence/parent class.
OK, I can definitely see that `uri` on its own is always ambiguous, we can
shift that other use to doc_uri. Leaving it as a class attribute
(immutable) seems like it might be enough signal re: not updating it?
…On Fri, May 31, 2024, 18:03 Jeffrey Martin ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In garak/generators/langchain_serve.py
<#711 (comment)>:
> + if self.uri is None:
+ self.uri = os.getenv("LANGCHAIN_SERVE_URI")
+ if not self._validate_uri(self.uri):
I see what you are referring to, at the class level uri is being reserved
in some plugins.
I land the other direction, I would say the uri attribute should not be
reserved for "references" and it would be more clear to define specific
documentation in an attribute with a lower probability for collision and
even possibly as a list, something like references, public_sources, of
maybe public_references. Maybe even use a constant like REFERENCES to
denote that the value is not expected to ever be manipulated in by an
instance.
—
Reply to this email directly, view it on GitHub
<#711 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA5YTS6CDCRJFJU6J4ZUWLZFCNL5AVCNFSM6AAAAABIR4IWXKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDAOJRGE4TONZQGQ>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
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.
Looks really good. Left a handful of comments throughout.
Thanks for all the feedback, I will work thru it all and post updated code soon. |
Signed-off-by: Jeffrey Martin <[email protected]>
* provides a more reabable and better guarded path parser * avoids mutation of received `path` argument * test plugin __init__ for config_root * remove unused values in `generators/__init__.py` * refactor method name typo Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
* more clear configurable `_instance_configured` * ensure `_supported_params` always exists for Configurable * test `_supported_params` is a list before attemping to search * additional tests of configurable behavior Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
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.
Looks good to me. Definitely some work to be done refactoring TAP and AutoDAN but that's a problem for me to get into next week.
EDIT: Looks like some tests are failing, so clearly I've missed something.
Signed-off-by: Jeffrey Martin <[email protected]>
Signed-off-by: Jeffrey Martin <[email protected]>
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.
LGTM.
* handle `org_id` from env variable in `_validate_env_var()` * pass params to parent `super().__init__()` for Pipeline Signed-off-by: Jeffrey Martin <[email protected]>
* add detector usage of `_validate_env_var()` * adjust `detector` load_plugins test to provide `api_key` * generalize package name if not key is not for `generator` config * defer validation to `Configurable` for more `Generators` Signed-off-by: Jeffrey Martin <[email protected]>
* Consolidates all `ENV_VAR` configuration as required at load of config * changes `buff` behavior to error when instantiated without required ENV_VAR * update load_plugin tests to mock `api_key` provided for all types Signed-off-by: Jeffrey Martin <[email protected]>
Once `_load_config()` is called either in `super().__init__()` or in the plugin constructor, only access values that have been passed in as `self.*` Signed-off-by: Jeffrey Martin <[email protected]>
Previous to config updates `self.name` was initialized then reset by call to `super().__init__()` using the original constructor values. This side-effect was relied upon for pipeline creation. * remove set of fullname from huggingface generators * allow config to set `deprefix_prompt` (_config.run.deprefix will still force) Signed-off-by: Jeffrey Martin <[email protected]>
Fix #589
Fix #595
Buckle up lots of adjustments to review. Many of the
generator/probe/detector/buff/harness
plugins are refactored in some way or another.The goal of this change is to offer configuration of instance variables on plugins on a per "type" basis.
Summary of changes:
Configurable
and accept a namedconfig_root
parameter that defaults to the global_config
_supported_params
in class definitionsapi_key
during instantiation_supported_params
only apply supported params from configuration files, a warning is logged for unknown itemsrasa.RasaRestGenerator
is implements an extension ofrest.RestGenerator
with embedded defaults and updated module config docs to increase code reusegarak.generators.load_generator()
and other generator loading code is removed in favor of_plugin.load_plugin()
accounting forDEFAULT_CLASS
Configurable
Configuration files apply in a hierarchal fashion and allow configuration of parameters not exposed in the class initializer.
Final values for configured attributes as instance variables are applied in with precedence to programatic input with a nuance that a constructor default value can be overwritten by a configuration file value if the provided value is the same as the default.
The changes introduce breaking changes to the expected structure of configuration wether provided as
yaml
orjson
.The primary breaking change is the expectation that configuration of a class will be nested inside configuration for all classes of a module holding more specific resolutions as the maintained values. This format change is currently left in a partially compatible state to provide time for consumers to update configuration formats.
Here is an example of a how configuration of the
rest.Generator
class is expected to change.Becomes:
If provided the previous format a warning is logged in
garak.log
about used of deprecated formatting.