Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -307,11 +307,12 @@ class GradioInterface:
|
|
| 307 |
outputs=[analysis_evaluation, refined_prompt, explanation_of_refinements, full_response_json]
|
| 308 |
)
|
| 309 |
|
|
|
|
| 310 |
apply_button.click(
|
| 311 |
fn=self.apply_prompts,
|
| 312 |
inputs=[prompt_text, refined_prompt, apply_model],
|
| 313 |
outputs=[original_output, refined_output],
|
| 314 |
-
|
| 315 |
)
|
| 316 |
|
| 317 |
def refine_prompt(self, prompt: str, meta_prompt_choice: str) -> tuple:
|
|
@@ -328,12 +329,16 @@ class GradioInterface:
|
|
| 328 |
)
|
| 329 |
|
| 330 |
def apply_prompts(self, original_prompt: str, refined_prompt: str, model: str):
|
| 331 |
-
|
| 332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
|
| 338 |
def launch(self, share=False):
|
| 339 |
self.interface.launch(share=share)
|
|
|
|
| 307 |
outputs=[analysis_evaluation, refined_prompt, explanation_of_refinements, full_response_json]
|
| 308 |
)
|
| 309 |
|
| 310 |
+
# In the __init__ method, modify the click event:
|
| 311 |
apply_button.click(
|
| 312 |
fn=self.apply_prompts,
|
| 313 |
inputs=[prompt_text, refined_prompt, apply_model],
|
| 314 |
outputs=[original_output, refined_output],
|
| 315 |
+
queue=True # Enable queuing for streaming
|
| 316 |
)
|
| 317 |
|
| 318 |
def refine_prompt(self, prompt: str, meta_prompt_choice: str) -> tuple:
|
|
|
|
| 329 |
)
|
| 330 |
|
| 331 |
def apply_prompts(self, original_prompt: str, refined_prompt: str, model: str):
|
| 332 |
+
def stream_generator():
|
| 333 |
+
for response in self.prompt_refiner.apply_prompt(original_prompt, model):
|
| 334 |
+
yield response, ""
|
| 335 |
+
|
| 336 |
+
for response in self.prompt_refiner.apply_prompt(refined_prompt, model):
|
| 337 |
+
current_output = yield "", response
|
| 338 |
|
| 339 |
+
return stream_generator()
|
| 340 |
+
|
| 341 |
+
|
| 342 |
|
| 343 |
def launch(self, share=False):
|
| 344 |
self.interface.launch(share=share)
|