nttwt1597 commited on
Commit
dba0d48
·
verified ·
1 Parent(s): 71f6ac4

Update app.py

Browse files

Test HuggingFaceDatasetSaver

Files changed (1) hide show
  1. app.py +64 -61
app.py CHANGED
@@ -95,46 +95,46 @@ Masking:"""
95
 
96
 
97
  hf_writer = gr.HuggingFaceDatasetSaver("criteria-feedback-demo",token_w, private=True)
98
- with gr.Blocks() as demo:
99
- with gr.Row():
100
- with gr.Column():
101
- prompt_box = gr.Textbox(
102
- label="Research Information",
103
- placeholder=place_holder,
104
- value=prefilled_value,
105
- lines=10)
106
- submit_button = gr.Button("Generate")
107
- with gr.Column():
108
- output_box = gr.Textbox(
109
- label="Eligiblecriteria Criteria",
110
- lines=21,
111
- interactive=False)
112
- with gr.Row():
113
- with gr.Column():
114
- feedback_box = gr.Textbox(label="Enter your feedback here...", lines=3, interactive=True)
115
- feedback_button = gr.Button("Submit Feedback")
116
- status_text = gr.Textbox(label="Status", lines=1, interactive=False)
117
-
118
- submit_button.click(
119
- run_model_on_text,
120
- inputs=prompt_box,
121
- outputs=output_box
122
- )
123
-
124
- def submit_feedback(prompt, generated_text, feedback):
125
- data = {
126
- "prompt": prompt,
127
- "generated_text": generated_text,
128
- "feedback": feedback
129
- }
130
- hf_writer.flag(data)
131
- return "Feedback submitted."
132
-
133
- feedback_button.click(
134
- submit_feedback,
135
- inputs=[prompt_box, output_box, feedback_box],
136
- outputs=status_text
137
- )
138
 
139
  # feedback_button.click(
140
  # hf_writer.flag([prompt_box,output_box,feedback_box]),
@@ -151,28 +151,31 @@ with gr.Blocks() as demo:
151
  # outputs=status_text
152
  # )
153
 
154
- demo.launch()
155
 
156
 
157
 
158
  #----------------------------------
159
- # prompt_box = gr.Textbox(
160
- # lines=25,
161
- # label="Research Information",
162
- # placeholder=place_holder,
163
- # value=prefilled_value,
164
- # )
165
-
166
- # output_box = gr.Textbox(
167
- # lines=25,
168
- # label="Eligiblecriteria Criteria",
169
- # )
170
-
171
- # demo = gr.Interface(
172
- # fn=run_model_on_text,
173
- # inputs=prompt_box,
174
- # outputs=output_box,
175
- # allow_flagging='auto',
176
- # )
177
-
178
- # demo.queue(max_size=20).launch(debug=True, share=True)
 
 
 
 
95
 
96
 
97
  hf_writer = gr.HuggingFaceDatasetSaver("criteria-feedback-demo",token_w, private=True)
98
+ # with gr.Blocks() as demo:
99
+ # with gr.Row():
100
+ # with gr.Column():
101
+ # prompt_box = gr.Textbox(
102
+ # label="Research Information",
103
+ # placeholder=place_holder,
104
+ # value=prefilled_value,
105
+ # lines=10)
106
+ # submit_button = gr.Button("Generate")
107
+ # with gr.Column():
108
+ # output_box = gr.Textbox(
109
+ # label="Eligiblecriteria Criteria",
110
+ # lines=21,
111
+ # interactive=False)
112
+ # with gr.Row():
113
+ # with gr.Column():
114
+ # feedback_box = gr.Textbox(label="Enter your feedback here...", lines=3, interactive=True)
115
+ # feedback_button = gr.Button("Submit Feedback")
116
+ # status_text = gr.Textbox(label="Status", lines=1, interactive=False)
117
+
118
+ # submit_button.click(
119
+ # run_model_on_text,
120
+ # inputs=prompt_box,
121
+ # outputs=output_box
122
+ # )
123
+
124
+ # def submit_feedback(prompt, generated_text, feedback):
125
+ # data = {
126
+ # "prompt": prompt,
127
+ # "generated_text": generated_text,
128
+ # "feedback": feedback
129
+ # }
130
+ # hf_writer.flag(data)
131
+ # return "Feedback submitted."
132
+
133
+ # feedback_button.click(
134
+ # submit_feedback,
135
+ # inputs=[prompt_box, output_box, feedback_box],
136
+ # outputs=status_text
137
+ # )
138
 
139
  # feedback_button.click(
140
  # hf_writer.flag([prompt_box,output_box,feedback_box]),
 
151
  # outputs=status_text
152
  # )
153
 
154
+ # demo.launch()
155
 
156
 
157
 
158
  #----------------------------------
159
+ prompt_box = gr.Textbox(
160
+ lines=25,
161
+ label="Research Information",
162
+ placeholder=place_holder,
163
+ value=prefilled_value,
164
+ )
165
+
166
+ output_box = gr.Textbox(
167
+ lines=25,
168
+ label="Eligiblecriteria Criteria",
169
+ )
170
+
171
+ demo = gr.Interface(
172
+ fn=run_model_on_text,
173
+ inputs=prompt_box,
174
+ outputs=output_box,
175
+ allow_flagging="manual",
176
+ flagging_options=["incorrect", "inappropriate", "appropriate"],
177
+ flagging_callback=hf_writer
178
+ )
179
+ )
180
+
181
+ demo.queue(max_size=20).launch(debug=True, share=True)