ChavinloSocialRise commited on
Commit
6550ffd
·
verified ·
1 Parent(s): 68db320

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py CHANGED
@@ -318,6 +318,44 @@ def attack_sus(message, max_tokens, temperature, top_p, available_pic_str):
318
  top_p=top_p,
319
  )
320
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  print("final sus prompt: ", sus_copy)
322
  return output.choices[0].message.content
323
 
 
318
  top_p=top_p,
319
  )
320
 
321
+ pic_list = re.findall(r'\[([^\]]+)\]', AVAILABLE_PICTURES)
322
+ pic_list.append("DEFAULT IMAGE")
323
+
324
+ valid_img = False
325
+ image_name = re.search(r'\[(.*?)\]', output.choices[0].message.content).group(1)
326
+ for x in pic_list:
327
+ if image_name == pic_list:
328
+ valid_img = True
329
+
330
+ if valid_img = False:
331
+ output2 = llm_client.chat.completions.create(
332
+ model="Orenguteng/Llama-3.1-8B-Lexi-Uncensored-V2",
333
+ messages=[
334
+ {
335
+ "role": "system",
336
+ "content": sus_copy
337
+ },
338
+ {
339
+ "role": "user",
340
+ "content": message
341
+ },
342
+ {
343
+ "role": "assistant",
344
+ "content": output.choices[0].message.content
345
+ },
346
+ {
347
+ "role": "user",
348
+ "content": "This is a system message. The image you selected to reply does not exists in the list. Please try again with a valid image name."
349
+ }
350
+ ],
351
+ max_tokens=max_tokens,
352
+ stream=False,
353
+ temperature=temperature,
354
+ top_p=top_p,
355
+ )
356
+
357
+ return output2.choices[0].message.content
358
+
359
  print("final sus prompt: ", sus_copy)
360
  return output.choices[0].message.content
361