samidh commited on
Commit
8f8bd3a
·
verified ·
1 Parent(s): 1202c79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -12
app.py CHANGED
@@ -119,16 +119,57 @@ def predict(content, policy):
119
  return f'NO MATCHES (i.e., non-violating)'
120
 
121
 
122
- # Create Gradio interface
123
- iface = gr.Interface(
124
- fn=predict,
125
- inputs=[gr.Textbox(label="Content", lines=2, value=DEFAULT_CONTENT),
126
- gr.Textbox(label="Policy", lines=8, value=DEFAULT_POLICY)],
127
- outputs=[gr.Textbox(label="Result")],
128
- title="Zentropi CoPE Demo",
129
- description=gr.Markdown("TEST: See if the given content violates your given policy."),
130
- api_name=False
131
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
- # Launch the app
134
- iface.launch(show_api=False)
 
119
  return f'NO MATCHES (i.e., non-violating)'
120
 
121
 
122
+ # Create the interface
123
+ with gr.Blocks(api_name=False) as demo:
124
+ with gr.Row():
125
+ # Left column with inputs
126
+ with gr.Column(scale=1):
127
+ input1 = gr.Textbox(label="Content", lines=2, value=DEFAULT_CONTENT)
128
+ input2 = gr.Textbox(label="Policy", lines=8, value=DEFAULT_POLICY)
129
+
130
+ # Right column with output
131
+ with gr.Column(scale=1):
132
+ output = gr.Textbox(label="Result")
133
+
134
+ # Button below inputs
135
+ submit_btn = gr.Button("Submit")
136
+
137
+ # Markdown content below the output
138
+ gr.Markdown("""
139
+ # Usage Instructions
140
+
141
+ This interface allows you to process two inputs and see the results.
142
+
143
+ ## Features
144
+
145
+ 1. Two input text boxes for versatile data entry
146
+ 2. Real-time processing
147
+ 3. Clear output display
148
+
149
+ ## How to Use
150
+
151
+ 1. Enter your first input in the left text box
152
+ 2. Enter your second input in the right text box
153
+ 3. Click the "Process" button to see results
154
+
155
+ ## Notes
156
+
157
+ - Both inputs are required for processing
158
+ - The output will be displayed in the right column
159
+ - Results are generated instantly
160
+
161
+ ## Additional Information
162
+
163
+ This interface is built using Gradio, a Python library for creating easy-to-use web interfaces for machine learning models and data processing functions.
164
+ """)
165
+
166
+ # Set up the processing function
167
+ submit_btn.click(
168
+ fn=predict,
169
+ inputs=[input1, input2],
170
+ outputs=output
171
+ )
172
+
173
+ # Launch the interface
174
+ demo.launch(show_api=False)
175