Spaces:
Sleeping
Sleeping
Naisong Zhou
commited on
Commit
·
e426a7f
1
Parent(s):
b4d2108
ui change for aih; add initial ai answer check in aih case and send warning
Browse files
app.py
CHANGED
|
@@ -145,8 +145,13 @@ def update_word_count(text):
|
|
| 145 |
words = text.split()
|
| 146 |
return f"Word Count: {len(words)}"
|
| 147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
if __name__ == "__main__":
|
| 149 |
-
deploy_local =
|
| 150 |
api_key = get_api_key(local=deploy_local)
|
| 151 |
service, SHEET_IDs = get_sheet_service(local=deploy_local)
|
| 152 |
SHEET_ID1, SHEET_ID2, SHEET_ID3 = SHEET_IDs
|
|
@@ -247,9 +252,11 @@ if __name__ == "__main__":
|
|
| 247 |
create_initial_btn = gr.Button("Create")
|
| 248 |
with gr.Row():
|
| 249 |
initial_answer = gr.Textbox(label="AI Output")
|
|
|
|
| 250 |
modification_suggestions = gr.Textbox(label="Enter each idea on a new line, starting with '1', '2', and '3' (use Shift+Enter for new lines)", placeholder="Please propose 3 ideas to help Airbnb’s business model align with 17 SDGs (At least 50 words)")
|
| 251 |
word_count_display_b = gr.Label(value="Word count: 0")
|
| 252 |
modification_suggestions.change(fn=update_word_count, inputs=modification_suggestions, outputs=word_count_display_b)
|
|
|
|
| 253 |
with gr.Row():
|
| 254 |
create_final_btn = gr.Button("Review")
|
| 255 |
with gr.Row():
|
|
|
|
| 145 |
words = text.split()
|
| 146 |
return f"Word Count: {len(words)}"
|
| 147 |
|
| 148 |
+
def check_initial_generated(initial_answer):
|
| 149 |
+
if not initial_answer:
|
| 150 |
+
gr.Warning("Please click 'Create' to generate the AI output first.")
|
| 151 |
+
return None
|
| 152 |
+
|
| 153 |
if __name__ == "__main__":
|
| 154 |
+
deploy_local = True
|
| 155 |
api_key = get_api_key(local=deploy_local)
|
| 156 |
service, SHEET_IDs = get_sheet_service(local=deploy_local)
|
| 157 |
SHEET_ID1, SHEET_ID2, SHEET_ID3 = SHEET_IDs
|
|
|
|
| 252 |
create_initial_btn = gr.Button("Create")
|
| 253 |
with gr.Row():
|
| 254 |
initial_answer = gr.Textbox(label="AI Output")
|
| 255 |
+
with gr.Row():
|
| 256 |
modification_suggestions = gr.Textbox(label="Enter each idea on a new line, starting with '1', '2', and '3' (use Shift+Enter for new lines)", placeholder="Please propose 3 ideas to help Airbnb’s business model align with 17 SDGs (At least 50 words)")
|
| 257 |
word_count_display_b = gr.Label(value="Word count: 0")
|
| 258 |
modification_suggestions.change(fn=update_word_count, inputs=modification_suggestions, outputs=word_count_display_b)
|
| 259 |
+
modification_suggestions.change(fn=check_initial_generated, inputs = [initial_answer] )
|
| 260 |
with gr.Row():
|
| 261 |
create_final_btn = gr.Button("Review")
|
| 262 |
with gr.Row():
|