Spaces:
Sleeping
Sleeping
Commit
·
a2c9251
1
Parent(s):
f2308a4
Changes
Browse files
app.py
CHANGED
@@ -77,6 +77,7 @@ Now, please output the following as a JSON object:
|
|
77 |
return 'unsafe'
|
78 |
|
79 |
async def add_to_dataset(safe_text,unsafe_text,conv_prefix, response,llama_resp,collinear_resp):
|
|
|
80 |
dataset = load_dataset("collinear-ai/collinear-guard-demo")
|
81 |
new_row = {'safe_text':safe_text,
|
82 |
'unsafe_text':unsafe_text,
|
@@ -105,7 +106,6 @@ def process_inputs(category,safe_text,unsafe_text,conv_prefix, response_content)
|
|
105 |
conv_prefix = json.loads(conv_prefix)
|
106 |
output = classify_prompt(category,safe_text,unsafe_text,conv_prefix, response)
|
107 |
llama_output = llama_guard_classify(conv_prefix, response)
|
108 |
-
add_to_dataset(safe_text,unsafe_text,conv_prefix,response_content,llama_output,output)
|
109 |
return output,llama_output
|
110 |
|
111 |
|
@@ -169,8 +169,8 @@ with gr.Blocks() as demo:
|
|
169 |
submit = gr.Button("Submit")
|
170 |
|
171 |
with gr.Row():
|
172 |
-
collinear_output = gr.Textbox(label="Collinear Guard Output")
|
173 |
-
llama_output = gr.Textbox(label="LLaMA-Guard 3 Output")
|
174 |
|
175 |
category.change(
|
176 |
fn=update_texts,
|
@@ -181,6 +181,10 @@ with gr.Blocks() as demo:
|
|
181 |
fn=process_inputs,
|
182 |
inputs=[category,safe_text, unsafe_text, conv_prefix, response],
|
183 |
outputs=[collinear_output,llama_output]
|
|
|
|
|
|
|
|
|
184 |
)
|
185 |
|
186 |
demo.launch()
|
|
|
77 |
return 'unsafe'
|
78 |
|
79 |
async def add_to_dataset(safe_text,unsafe_text,conv_prefix, response,llama_resp,collinear_resp):
|
80 |
+
conv_prefix = json.loads(conv_prefix)
|
81 |
dataset = load_dataset("collinear-ai/collinear-guard-demo")
|
82 |
new_row = {'safe_text':safe_text,
|
83 |
'unsafe_text':unsafe_text,
|
|
|
106 |
conv_prefix = json.loads(conv_prefix)
|
107 |
output = classify_prompt(category,safe_text,unsafe_text,conv_prefix, response)
|
108 |
llama_output = llama_guard_classify(conv_prefix, response)
|
|
|
109 |
return output,llama_output
|
110 |
|
111 |
|
|
|
169 |
submit = gr.Button("Submit")
|
170 |
|
171 |
with gr.Row():
|
172 |
+
collinear_output = gr.Textbox(label="Collinear Guard(~3B) Output")
|
173 |
+
llama_output = gr.Textbox(label="LLaMA-Guard 3 (8B) Output")
|
174 |
|
175 |
category.change(
|
176 |
fn=update_texts,
|
|
|
181 |
fn=process_inputs,
|
182 |
inputs=[category,safe_text, unsafe_text, conv_prefix, response],
|
183 |
outputs=[collinear_output,llama_output]
|
184 |
+
).then(
|
185 |
+
fn=add_to_dataset,
|
186 |
+
inputs=[safe_text, unsafe_text, conv_prefix, response, llama_output, collinear_output],
|
187 |
+
outputs=[]
|
188 |
)
|
189 |
|
190 |
demo.launch()
|