tanveeshsingh commited on
Commit
0d56e5d
·
1 Parent(s): a42f4f2
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -50,11 +50,11 @@ def classify_prompt(category,conv_prefix, response):
50
  # return 'non refusal' if category=='refusal' else 'unsafe'
51
  return 'a'
52
 
53
- async def add_to_dataset(safe_text,unsafe_text,conv_prefix, response,llama_resp,collinear_resp):
54
  conv_prefix = json.loads(conv_prefix)
55
  dataset = load_dataset("collinear-ai/collinear-guard-demo")
56
- new_row = {'safe_text':safe_text,
57
- 'unsafe_text':unsafe_text,
58
  'conv_prefix':conv_prefix,
59
  'response':response,
60
  'llama_resp':{"output":llama_resp},
@@ -76,6 +76,7 @@ async def add_to_dataset(safe_text,unsafe_text,conv_prefix, response,llama_resp,
76
 
77
 
78
  def process_inputs(category,conv_prefix, response_content):
 
79
  response = {"role": "assistant", "content": response_content}
80
  conv_prefix = json.loads(conv_prefix)
81
  output = classify_prompt(category,conv_prefix, response)
@@ -148,7 +149,7 @@ with gr.Blocks() as demo:
148
  outputs=[collinear_output,llama_output]
149
  ).then(
150
  fn=add_to_dataset,
151
- inputs=["", "", conv_prefix, response, llama_output, collinear_output],
152
  outputs=[]
153
  )
154
 
 
50
  # return 'non refusal' if category=='refusal' else 'unsafe'
51
  return 'a'
52
 
53
+ async def add_to_dataset(conv_prefix, response,llama_resp,collinear_resp):
54
  conv_prefix = json.loads(conv_prefix)
55
  dataset = load_dataset("collinear-ai/collinear-guard-demo")
56
+ new_row = {'safe_text':"",
57
+ 'unsafe_text':"",
58
  'conv_prefix':conv_prefix,
59
  'response':response,
60
  'llama_resp':{"output":llama_resp},
 
76
 
77
 
78
  def process_inputs(category,conv_prefix, response_content):
79
+ print('process inputs')
80
  response = {"role": "assistant", "content": response_content}
81
  conv_prefix = json.loads(conv_prefix)
82
  output = classify_prompt(category,conv_prefix, response)
 
149
  outputs=[collinear_output,llama_output]
150
  ).then(
151
  fn=add_to_dataset,
152
+ inputs=[conv_prefix, response, llama_output, collinear_output],
153
  outputs=[]
154
  )
155