Spaces:
Sleeping
Sleeping
Commit
Β·
7cb1ba7
1
Parent(s):
60d6368
app.py
CHANGED
@@ -125,7 +125,7 @@ def generate_blurb(prompt):
|
|
125 |
|
126 |
# Modified function to log blurb and vote
|
127 |
def log_blurb_and_vote(
|
128 |
-
prompt, blurb, vote, user_info: gr.OAuthProfile | None, has_voted
|
129 |
):
|
130 |
if has_voted:
|
131 |
return (
|
@@ -150,6 +150,7 @@ def log_blurb_and_vote(
|
|
150 |
return f"Logged: {vote} by user {user_id}", True, gr.Row.update(visible=False)
|
151 |
|
152 |
|
|
|
153 |
tufte_theme = TufteInspired()
|
154 |
|
155 |
# Create Gradio interface
|
@@ -160,6 +161,7 @@ with gr.Blocks(theme=tufte_theme) as demo:
|
|
160 |
Would you read a book based on this LLM generated blurb? <br> Your vote will be added to <a href="https://huggingface.co/datasets/your-username/your-dataset-repo">this</a> Hugging Face dataset</p>"""
|
161 |
)
|
162 |
|
|
|
163 |
login_btn = gr.LoginButton()
|
164 |
|
165 |
with gr.Row():
|
@@ -169,26 +171,26 @@ with gr.Blocks(theme=tufte_theme) as demo:
|
|
169 |
blurb_output = gr.Markdown(label="Book blurb")
|
170 |
has_voted = gr.State(False)
|
171 |
|
172 |
-
with gr.Row() as voting_row:
|
173 |
upvote_btn = gr.Button("π would read")
|
174 |
downvote_btn = gr.Button("π wouldn't read")
|
175 |
|
176 |
vote_output = gr.Textbox(label="Vote Status", interactive=False, visible=False)
|
177 |
|
178 |
def generate_and_show(prompt):
|
179 |
-
return "Generating...",
|
180 |
|
181 |
def show_voting_buttons(blurb):
|
182 |
-
return blurb,
|
183 |
|
184 |
generate_btn.click(get_and_store_prompt, outputs=prompt_state).then(
|
185 |
generate_and_show,
|
186 |
inputs=prompt_state,
|
187 |
-
outputs=[blurb_output,
|
188 |
).then(generate_blurb, inputs=prompt_state, outputs=blurb_output).then(
|
189 |
show_voting_buttons,
|
190 |
inputs=blurb_output,
|
191 |
-
outputs=[blurb_output,
|
192 |
)
|
193 |
|
194 |
upvote_btn.click(
|
|
|
125 |
|
126 |
# Modified function to log blurb and vote
|
127 |
def log_blurb_and_vote(
|
128 |
+
prompt, blurb, vote, user_info: gr.OAuthProfile | None, has_voted, *args
|
129 |
):
|
130 |
if has_voted:
|
131 |
return (
|
|
|
150 |
return f"Logged: {vote} by user {user_id}", True, gr.Row.update(visible=False)
|
151 |
|
152 |
|
153 |
+
# Create custom theme
|
154 |
tufte_theme = TufteInspired()
|
155 |
|
156 |
# Create Gradio interface
|
|
|
161 |
Would you read a book based on this LLM generated blurb? <br> Your vote will be added to <a href="https://huggingface.co/datasets/your-username/your-dataset-repo">this</a> Hugging Face dataset</p>"""
|
162 |
)
|
163 |
|
164 |
+
# Add the login button
|
165 |
login_btn = gr.LoginButton()
|
166 |
|
167 |
with gr.Row():
|
|
|
171 |
blurb_output = gr.Markdown(label="Book blurb")
|
172 |
has_voted = gr.State(False)
|
173 |
|
174 |
+
with gr.Row(visible=False) as voting_row:
|
175 |
upvote_btn = gr.Button("π would read")
|
176 |
downvote_btn = gr.Button("π wouldn't read")
|
177 |
|
178 |
vote_output = gr.Textbox(label="Vote Status", interactive=False, visible=False)
|
179 |
|
180 |
def generate_and_show(prompt):
|
181 |
+
return "Generating...", gr.Row.update(visible=False), False
|
182 |
|
183 |
def show_voting_buttons(blurb):
|
184 |
+
return blurb, gr.Row.update(visible=True), False
|
185 |
|
186 |
generate_btn.click(get_and_store_prompt, outputs=prompt_state).then(
|
187 |
generate_and_show,
|
188 |
inputs=prompt_state,
|
189 |
+
outputs=[blurb_output, voting_row, has_voted],
|
190 |
).then(generate_blurb, inputs=prompt_state, outputs=blurb_output).then(
|
191 |
show_voting_buttons,
|
192 |
inputs=blurb_output,
|
193 |
+
outputs=[blurb_output, voting_row, has_voted],
|
194 |
)
|
195 |
|
196 |
upvote_btn.click(
|