aiverify-foundation / moonshot-data

Contains all assets to run with Moonshot Library (Connectors, Datasets and Metrics)
Apache License 2.0
11 stars 9 forks source link

added optional param for run_attack_module in cli #54

Closed imda-kelvinkok closed 2 months ago

imda-kelvinkok commented 2 months ago

This PR is to add optional parameters for users to use in their attack modules. The optional parameters will be entered by the user in the CLI in the form of a dictionary, which the attack modules can take in (i.e. users may want to decide how many iterations the attack module should run before stopping, so the dictionary can have a field like "max_no_of_iteration" which the attack module will read in)

How to test:

  1. Start cli: python -m moonshot cli interactive
  2. Create a new session: new_session -h and copy the help sample codes to create a new session with a new runner (change the connector endpoint to one you can access with your API key)
  3. Inside the session, enter run_attack_module sample_attack_module "test prompt" -o "{'max_number_of_iteration': 1, 'my_optional_param': 'hello world'}"
  4. The attack module should run without any error