samidh commited on
Commit
c5ab1ee
·
verified ·
1 Parent(s): fc1fd63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -15
app.py CHANGED
@@ -96,34 +96,39 @@ def predict(content, policy):
96
  else:
97
  return f'VIOLATING ({decoded_output[-1]})'
98
 
99
- # Create Gradio interface
100
- iface = gr.Interface(
101
- fn=predict,
102
- inputs=[gr.Textbox(label="Content", lines=2, value=DEFAULT_CONTENT),
103
- gr.Textbox(label="Policy", lines=10, value=DEFAULT_POLICY)],
104
- outputs="label",
105
- title="CoPE Alpha Preview",
106
- description="See if the given content violates your given policy.",
107
- article="""
 
 
 
 
108
  ## About CoPE
109
 
110
- CoPE (the COntent Policy Evaluation engine) is a small language model capable of accurate content policy labeling. This is a *preview* of our alpha release and is strictly for *research* purposes. This should *NOT* be used for any production use cases.
111
 
112
- ### How to Use
113
 
114
  1. Enter your content in the "Content" box.
115
  2. Specify your policy in the "Policy" box.
116
  3. Click "Submit" to see the results.
117
 
118
- *Note*: Inference times are *very slow* (30-45 seconds) since this is built on dev infra and not yet optimized for live systems. Please be patient while testing!
119
 
120
- ### Feedback
121
 
122
  - [Give us feedback](https://example.com) to help us improve
123
  - Read our FAQ to learn more about CoPE
124
  - Join our mailing list to keep in touch
125
- """
126
- )
 
127
 
128
  # Launch the app
129
  iface.launch()
 
96
  else:
97
  return f'VIOLATING ({decoded_output[-1]})'
98
 
99
+
100
+ with gr.Blocks() as iface:
101
+ gr.Markdown("# CoPE Alpha Preview")
102
+ gr.Markdown("See if the given content violates your given policy.")
103
+
104
+ with gr.Row():
105
+ content_input = gr.Textbox(label="Content", lines=2, value=DEFAULT_CONTENT)
106
+ policy_input = gr.Textbox(label="Policy", lines=10, value=DEFAULT_POLICY)
107
+
108
+ submit_btn = gr.Button("Submit")
109
+ output = gr.Label(label="Label")
110
+
111
+ gr.Markdown("""
112
  ## About CoPE
113
 
114
+ CoPE (the COntent Policy Evaluation engine) is a small language model capable of accurate content policy labeling. This is a **preview** of our alpha release and is strictly for **research** purposes. This should **NOT** be used for any production use cases.
115
 
116
+ ## How to Use
117
 
118
  1. Enter your content in the "Content" box.
119
  2. Specify your policy in the "Policy" box.
120
  3. Click "Submit" to see the results.
121
 
122
+ **Note**: Inference times are **very slow** (30-45 seconds) since this is built on dev infra and not yet optimized for live systems. Please be patient while testing!
123
 
124
+ ## More Info
125
 
126
  - [Give us feedback](https://example.com) to help us improve
127
  - Read our FAQ to learn more about CoPE
128
  - Join our mailing list to keep in touch
129
+ """)
130
+
131
+ submit_btn.click(predict, inputs=[content_input, policy_input], outputs=output)
132
 
133
  # Launch the app
134
  iface.launch()