Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -307,7 +307,7 @@ class GradioInterface:
|
|
307 |
outputs=[analysis_evaluation, refined_prompt, explanation_of_refinements, full_response_json]
|
308 |
)
|
309 |
|
310 |
-
|
311 |
apply_button.click(
|
312 |
fn=self.apply_prompts,
|
313 |
inputs=[prompt_text, refined_prompt, apply_model],
|
@@ -329,14 +329,22 @@ class GradioInterface:
|
|
329 |
)
|
330 |
|
331 |
def apply_prompts(self, original_prompt: str, refined_prompt: str, model: str):
|
332 |
-
def stream_generator():
|
333 |
-
|
334 |
-
|
335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
for response in self.prompt_refiner.apply_prompt(refined_prompt, model):
|
337 |
-
|
|
|
338 |
|
339 |
return stream_generator()
|
|
|
340 |
|
341 |
|
342 |
|
|
|
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],
|
|
|
329 |
)
|
330 |
|
331 |
def apply_prompts(self, original_prompt: str, refined_prompt: str, model: str):
|
332 |
+
async def stream_generator():
|
333 |
+
original_output = ""
|
334 |
+
refined_output = ""
|
335 |
|
336 |
+
# Stream original prompt
|
337 |
+
for response in self.prompt_refiner.apply_prompt(original_prompt, model):
|
338 |
+
original_output = response
|
339 |
+
yield original_output, refined_output
|
340 |
+
|
341 |
+
# Stream refined prompt
|
342 |
for response in self.prompt_refiner.apply_prompt(refined_prompt, model):
|
343 |
+
refined_output = response
|
344 |
+
yield original_output, refined_output
|
345 |
|
346 |
return stream_generator()
|
347 |
+
|
348 |
|
349 |
|
350 |
|