Spaces:
Running
Running
update history fix
Browse files
app.py
CHANGED
@@ -288,6 +288,7 @@ def generation_code(query: Optional[str], image: Optional[gr.Image], _setting: D
|
|
288 |
yield {
|
289 |
code_output: clean_code,
|
290 |
status_indicator: '<div class="status-indicator generating" id="status">Generating code...</div>',
|
|
|
291 |
}
|
292 |
_history = messages_to_history(messages + [{
|
293 |
'role': 'assistant',
|
@@ -298,12 +299,14 @@ def generation_code(query: Optional[str], image: Optional[gr.Image], _setting: D
|
|
298 |
history: _history,
|
299 |
sandbox: send_to_sandbox(remove_code_block(content)),
|
300 |
status_indicator: '<div class="status-indicator success" id="status">Code generated successfully!</div>',
|
|
|
301 |
}
|
302 |
except Exception as e:
|
303 |
error_message = f"Error: {str(e)}"
|
304 |
yield {
|
305 |
code_output: error_message,
|
306 |
status_indicator: '<div class="status-indicator error" id="status">Error generating code</div>',
|
|
|
307 |
}
|
308 |
|
309 |
# Main application
|
@@ -391,13 +394,9 @@ with gr.Blocks(theme=gr.themes.Base(), title="AnyCoder - AI Code Generator") as
|
|
391 |
btn.click(
|
392 |
generation_code,
|
393 |
inputs=[input, image_input, setting, history, current_model],
|
394 |
-
outputs=[code_output, history, sandbox, status_indicator]
|
395 |
)
|
396 |
clear_btn.click(clear_history, outputs=[history])
|
397 |
-
# History tab update
|
398 |
-
def update_history(history):
|
399 |
-
return history
|
400 |
-
history_output.change(update_history, inputs=history, outputs=history_output)
|
401 |
|
402 |
if __name__ == "__main__":
|
403 |
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|
|
|
288 |
yield {
|
289 |
code_output: clean_code,
|
290 |
status_indicator: '<div class="status-indicator generating" id="status">Generating code...</div>',
|
291 |
+
history_output: _history,
|
292 |
}
|
293 |
_history = messages_to_history(messages + [{
|
294 |
'role': 'assistant',
|
|
|
299 |
history: _history,
|
300 |
sandbox: send_to_sandbox(remove_code_block(content)),
|
301 |
status_indicator: '<div class="status-indicator success" id="status">Code generated successfully!</div>',
|
302 |
+
history_output: _history,
|
303 |
}
|
304 |
except Exception as e:
|
305 |
error_message = f"Error: {str(e)}"
|
306 |
yield {
|
307 |
code_output: error_message,
|
308 |
status_indicator: '<div class="status-indicator error" id="status">Error generating code</div>',
|
309 |
+
history_output: _history,
|
310 |
}
|
311 |
|
312 |
# Main application
|
|
|
394 |
btn.click(
|
395 |
generation_code,
|
396 |
inputs=[input, image_input, setting, history, current_model],
|
397 |
+
outputs=[code_output, history, sandbox, status_indicator, history_output]
|
398 |
)
|
399 |
clear_btn.click(clear_history, outputs=[history])
|
|
|
|
|
|
|
|
|
400 |
|
401 |
if __name__ == "__main__":
|
402 |
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|