Added support for multi-config api calls + added tests #307
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.
by @makeshn
Added initial support for multi_config api calls using the server API.
Changelog
nemoguardrails/rails/llm/config.py
_join_rails_configs
to combine two RailsConfig objects. Follows the logic of_join_config
method. We have two hard checks in this function - we require theaction_server_url
to be the same, we require that ifmodel_type
is the same across configs, then themodel_engine
andmodel attributes
must match._update_rails_config
function to handle combining config.rails - FactChecking, Input, Output, SensitiveDataDetection, Retrieval. For Input, Output and Retrieval rails, we append together the flows. For the others, we check if the attributes in the UpdatedRailsConfig is set/empty. If set, it overwrites the BaseRailsConfig attribute, if empty - we just retain the BaseRailsConfig.nemoguardrails/server/api.py
config_ids
field to RequestBody - List of strs._get_rails
function to operate on list of strs. We generate a cache key to be concatenation of configs passed. The configs are combined two at a time to get the full_llm_config.nemoguardrails/actions/action_dispatcher.py
Signed-off-by: Makesh Narsimhan Sreedhar makeshn@nvidia.com