(instruction=None,
instructions_path=None,
adv_prompt=None,
adv_prompts_path=None,
n_instructions=None,
model='gpt-3.5-turbo',
combo='benign+adv',
chat_hparams='temperature=0,n=1,max_tokens=128,top_p=0.0',
checking="key_words",
sleep=10,
verbose=False,
output_file='api_models_log.json',
add_system_prompt=False)
| 188 | |
| 189 | @scriptify |
| 190 | def main(instruction=None, |
| 191 | instructions_path=None, |
| 192 | adv_prompt=None, |
| 193 | adv_prompts_path=None, |
| 194 | n_instructions=None, |
| 195 | model='gpt-3.5-turbo', |
| 196 | combo='benign+adv', |
| 197 | chat_hparams='temperature=0,n=1,max_tokens=128,top_p=0.0', |
| 198 | checking="key_words", |
| 199 | sleep=10, |
| 200 | verbose=False, |
| 201 | output_file='api_models_log.json', |
| 202 | add_system_prompt=False): |
| 203 | |
| 204 | input_args = locals() |
| 205 | |
| 206 | print(input_args) |
| 207 | |
| 208 | if instruction is None and instructions_path is None: |
| 209 | raise ValueError(f"question and questions_path can not be None at same time.") |
| 210 | |
| 211 | if adv_prompt is None and adv_prompts_path is None: |
| 212 | raise ValueError(f"adv_prompt and adv_prompts_path can not be None at same time.") |
| 213 | |
| 214 | if isinstance(n_instructions, int): |
| 215 | instructions = load_prompts(instruction, instructions_path)[:n_instructions] |
| 216 | elif isinstance(n_instructions, str): |
| 217 | start, end = n_instructions.split(":", 2) |
| 218 | start = int(start) |
| 219 | end = int(end) |
| 220 | instructions = load_prompts(instruction, instructions_path)[start:end] |
| 221 | |
| 222 | if len(instructions) < 1: |
| 223 | raise ValueError("Found 0 instruction.") |
| 224 | else: |
| 225 | print(f"Find {len(instructions)} instructions. ") |
| 226 | |
| 227 | adv_prompts = load_prompts(adv_prompt, adv_prompts_path) |
| 228 | if len(adv_prompts) < 1: |
| 229 | raise ValueError("Found 0 adversarial prompt.") |
| 230 | else: |
| 231 | print(f"Find {len(adv_prompts)} adversarial prompts. ") |
| 232 | |
| 233 | configs = {} |
| 234 | for config_string in chat_hparams.split(','): |
| 235 | key, value = config_string.split('=', 2) |
| 236 | if '.' in value: |
| 237 | configs[key] = float(value) |
| 238 | elif value == 'false': |
| 239 | configs[key] = False |
| 240 | elif value == 'true': |
| 241 | configs[key] = True |
| 242 | elif value.startswith('"') and value.endswith('"'): |
| 243 | configs[key] = value |
| 244 | else: |
| 245 | configs[key] = int(value) |
| 246 | |
| 247 | chatbot, configs = load_chatbot(model_name=model, |
nothing calls this directly
no test coverage detected