Spaces:
Sleeping
Sleeping
Commit ·
d50af99
1
Parent(s): 3fa1cfd
Fix generator handling in button click function
Browse files
app.py
CHANGED
|
@@ -148,17 +148,18 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 148 |
span_code = next((code for code, display in time_emojis.items() if display == span), "7d")
|
| 149 |
return crypto_code, span_code
|
| 150 |
|
| 151 |
-
# Connect the button click -
|
| 152 |
def process_and_run(crypto_display, span_display):
|
| 153 |
# First preprocess the display values to get the codes
|
| 154 |
crypto_code, span_code = preprocess_input(crypto_display, span_display)
|
| 155 |
-
#
|
| 156 |
return run_chat(crypto_code, span_code)
|
| 157 |
|
| 158 |
start_btn.click(
|
| 159 |
-
process_and_run,
|
| 160 |
-
[crypto_dropdown, span_dropdown],
|
| 161 |
-
[chatbot, state],
|
|
|
|
| 162 |
)
|
| 163 |
|
| 164 |
demo.launch()
|
|
|
|
| 148 |
span_code = next((code for code, display in time_emojis.items() if display == span), "7d")
|
| 149 |
return crypto_code, span_code
|
| 150 |
|
| 151 |
+
# Connect the button click - properly handling the generator function
|
| 152 |
def process_and_run(crypto_display, span_display):
|
| 153 |
# First preprocess the display values to get the codes
|
| 154 |
crypto_code, span_code = preprocess_input(crypto_display, span_display)
|
| 155 |
+
# Create and return the generator
|
| 156 |
return run_chat(crypto_code, span_code)
|
| 157 |
|
| 158 |
start_btn.click(
|
| 159 |
+
fn=process_and_run, # Use named parameter for clarity
|
| 160 |
+
inputs=[crypto_dropdown, span_dropdown],
|
| 161 |
+
outputs=[chatbot, state],
|
| 162 |
+
api_name="start_analysis" # Add API name for better traceability
|
| 163 |
)
|
| 164 |
|
| 165 |
demo.launch()
|