Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -118,7 +118,6 @@ def run_llm(
|
|
| 118 |
return f"An error occurred: {e}", ""
|
| 119 |
|
| 120 |
target_options = get_target_options()
|
| 121 |
-
|
| 122 |
model_choices = ["gpt-4.1", "gpt-4", "gpt-3.5-turbo"]
|
| 123 |
|
| 124 |
with gr.Blocks() as demo:
|
|
@@ -229,28 +228,30 @@ This tool was created by [Organizing for Change](https://www.organizingforchange
|
|
| 229 |
info="Paste or write your actual message here."
|
| 230 |
)
|
| 231 |
|
|
|
|
| 232 |
submit = gr.Button("Generate Targetted Message", variant="primary")
|
| 233 |
output = gr.Textbox(
|
| 234 |
lines=10,
|
| 235 |
label="Message as Modified by LLM for Target Audience(s)",
|
| 236 |
info="The LLM’s refined response will appear here. You can regenerate the response and get something new by clicking 'Generate Targetted Message' again."
|
| 237 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
token_pricing_md = gr.Markdown(
|
| 239 |
"<a href='https://platform.openai.com/docs/pricing' target='_blank'>View OpenAI pricing details</a>"
|
| 240 |
)
|
| 241 |
|
|
|
|
| 242 |
submit.click(
|
| 243 |
fn=run_llm,
|
| 244 |
inputs=[api_key, target, feedback, additional_sysinfo, user_message, region, model, temperature, top_p],
|
| 245 |
outputs=[output, token_count_box]
|
| 246 |
)
|
| 247 |
|
| 248 |
-
with gr.Row():
|
| 249 |
-
token_count_box = gr.Textbox(
|
| 250 |
-
label="Token Usage",
|
| 251 |
-
interactive=False,
|
| 252 |
-
value="Tokens exchanged will appear here."
|
| 253 |
-
)
|
| 254 |
-
|
| 255 |
if __name__ == "__main__":
|
| 256 |
demo.launch(share=True)
|
|
|
|
| 118 |
return f"An error occurred: {e}", ""
|
| 119 |
|
| 120 |
target_options = get_target_options()
|
|
|
|
| 121 |
model_choices = ["gpt-4.1", "gpt-4", "gpt-3.5-turbo"]
|
| 122 |
|
| 123 |
with gr.Blocks() as demo:
|
|
|
|
| 228 |
info="Paste or write your actual message here."
|
| 229 |
)
|
| 230 |
|
| 231 |
+
# --- Define output boxes BEFORE wiring up .click() ---
|
| 232 |
submit = gr.Button("Generate Targetted Message", variant="primary")
|
| 233 |
output = gr.Textbox(
|
| 234 |
lines=10,
|
| 235 |
label="Message as Modified by LLM for Target Audience(s)",
|
| 236 |
info="The LLM’s refined response will appear here. You can regenerate the response and get something new by clicking 'Generate Targetted Message' again."
|
| 237 |
)
|
| 238 |
+
with gr.Row():
|
| 239 |
+
token_count_box = gr.Textbox(
|
| 240 |
+
label="Token Usage",
|
| 241 |
+
interactive=False,
|
| 242 |
+
value="Tokens exchanged will appear here."
|
| 243 |
+
)
|
| 244 |
+
|
| 245 |
token_pricing_md = gr.Markdown(
|
| 246 |
"<a href='https://platform.openai.com/docs/pricing' target='_blank'>View OpenAI pricing details</a>"
|
| 247 |
)
|
| 248 |
|
| 249 |
+
# --- Connect submit button after outputs are created ---
|
| 250 |
submit.click(
|
| 251 |
fn=run_llm,
|
| 252 |
inputs=[api_key, target, feedback, additional_sysinfo, user_message, region, model, temperature, top_p],
|
| 253 |
outputs=[output, token_count_box]
|
| 254 |
)
|
| 255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
if __name__ == "__main__":
|
| 257 |
demo.launch(share=True)
|