Spaces:
Sleeping
Sleeping
fix
Browse files
app.py
CHANGED
|
@@ -5827,7 +5827,6 @@ def generation_code(query: str | None, vlm_image: Optional[gr.Image], website_ur
|
|
| 5827 |
yield {
|
| 5828 |
code_output: error_message,
|
| 5829 |
history_output: history_to_chatbot_messages(_history or []),
|
| 5830 |
-
sandbox: f"<div style='padding:2em;text-align:center;color:#e74c3c;font-size:1.2em;'><h3>🔒 Authentication Required</h3><p>{auth_message}</p><p>Please log in to use AnyCoder.</p></div>",
|
| 5831 |
}
|
| 5832 |
return
|
| 5833 |
|
|
@@ -5946,7 +5945,6 @@ Generate the exact search/replace blocks needed to make these changes."""
|
|
| 5946 |
yield {
|
| 5947 |
code_output: modified_content,
|
| 5948 |
history: _history,
|
| 5949 |
-
sandbox: deploy_message,
|
| 5950 |
history_output: history_to_chatbot_messages(_history),
|
| 5951 |
}
|
| 5952 |
return
|
|
@@ -6072,7 +6070,6 @@ This will help me create a better design for you."""
|
|
| 6072 |
yield {
|
| 6073 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6074 |
history_output: history_to_chatbot_messages(_history),
|
| 6075 |
-
sandbox: progress_message,
|
| 6076 |
}
|
| 6077 |
|
| 6078 |
except Exception as e:
|
|
@@ -6092,14 +6089,12 @@ This will help me create a better design for you."""
|
|
| 6092 |
yield {
|
| 6093 |
code_output: formatted_output,
|
| 6094 |
history: _history,
|
| 6095 |
-
sandbox: send_transformers_to_sandbox(files),
|
| 6096 |
history_output: history_to_chatbot_messages(_history),
|
| 6097 |
}
|
| 6098 |
else:
|
| 6099 |
yield {
|
| 6100 |
code_output: clean_code,
|
| 6101 |
history: _history,
|
| 6102 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>Error parsing transformers.js output. Please try again.</div>",
|
| 6103 |
history_output: history_to_chatbot_messages(_history),
|
| 6104 |
}
|
| 6105 |
elif language == "svelte":
|
|
@@ -6112,14 +6107,12 @@ This will help me create a better design for you."""
|
|
| 6112 |
yield {
|
| 6113 |
code_output: formatted_output,
|
| 6114 |
history: _history,
|
| 6115 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your Svelte code using the download button above.</div>",
|
| 6116 |
history_output: history_to_chatbot_messages(_history),
|
| 6117 |
}
|
| 6118 |
else:
|
| 6119 |
yield {
|
| 6120 |
code_output: clean_code,
|
| 6121 |
history: _history,
|
| 6122 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your Svelte code using the download button above.</div>",
|
| 6123 |
history_output: history_to_chatbot_messages(_history),
|
| 6124 |
}
|
| 6125 |
else:
|
|
@@ -6133,13 +6126,6 @@ This will help me create a better design for you."""
|
|
| 6133 |
yield {
|
| 6134 |
code_output: clean_content,
|
| 6135 |
history: _history,
|
| 6136 |
-
sandbox: f"""
|
| 6137 |
-
<div style='padding: 1.5em; text-align: center; background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; border-radius: 10px;'>
|
| 6138 |
-
<h3 style='margin-top: 0; color: white;'>✅ {language.upper()} Code Generated!</h3>
|
| 6139 |
-
<p style='margin: 0.5em 0; opacity: 0.9;'>Your code is ready for deployment.</p>
|
| 6140 |
-
<p style='margin: 0.5em 0; font-weight: bold;'>👉 Use the Deploy button in the sidebar to publish your app!</p>
|
| 6141 |
-
</div>
|
| 6142 |
-
""",
|
| 6143 |
history_output: history_to_chatbot_messages(_history),
|
| 6144 |
}
|
| 6145 |
else:
|
|
@@ -6183,7 +6169,6 @@ This will help me create a better design for you."""
|
|
| 6183 |
yield {
|
| 6184 |
code_output: final_content,
|
| 6185 |
history: _history,
|
| 6186 |
-
sandbox: deploy_message,
|
| 6187 |
history_output: history_to_chatbot_messages(_history),
|
| 6188 |
}
|
| 6189 |
return
|
|
@@ -6251,7 +6236,6 @@ This will help me create a better design for you."""
|
|
| 6251 |
yield {
|
| 6252 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6253 |
history_output: history_to_chatbot_messages(_history),
|
| 6254 |
-
sandbox: preview_val or "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML or Streamlit-in-Python.</div>",
|
| 6255 |
}
|
| 6256 |
except Exception as e:
|
| 6257 |
content = f"Error with GLM-4.5V: {str(e)}\n\nPlease make sure HF_TOKEN environment variable is set."
|
|
@@ -6272,7 +6256,6 @@ This will help me create a better design for you."""
|
|
| 6272 |
yield {
|
| 6273 |
code_output: clean_code,
|
| 6274 |
history: _history,
|
| 6275 |
-
sandbox: preview_val or "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML or Streamlit-in-Python.</div>",
|
| 6276 |
history_output: history_to_chatbot_messages(_history),
|
| 6277 |
}
|
| 6278 |
return
|
|
@@ -6366,7 +6349,6 @@ This will help me create a better design for you."""
|
|
| 6366 |
yield {
|
| 6367 |
code_output: gr.update(value=(content or "") + "\n<!-- " + status_line + " -->", language="html"),
|
| 6368 |
history_output: history_to_chatbot_messages(_history),
|
| 6369 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>" + status_line + "</div>",
|
| 6370 |
}
|
| 6371 |
continue
|
| 6372 |
# Filter placeholders
|
|
@@ -6420,7 +6402,6 @@ This will help me create a better design for you."""
|
|
| 6420 |
yield {
|
| 6421 |
code_output: gr.update(value=merged_html, language="html"),
|
| 6422 |
history_output: history_to_chatbot_messages(_history),
|
| 6423 |
-
sandbox: preview_val or "<div style='padding:1em;color:#888;text-align:center;'>Generating transformers.js app...</div>",
|
| 6424 |
}
|
| 6425 |
elif has_existing_content:
|
| 6426 |
# Model is returning search/replace changes for transformers.js - apply them
|
|
@@ -6430,14 +6411,12 @@ This will help me create a better design for you."""
|
|
| 6430 |
yield {
|
| 6431 |
code_output: gr.update(value=modified_content, language="html"),
|
| 6432 |
history_output: history_to_chatbot_messages(_history),
|
| 6433 |
-
sandbox: send_transformers_to_sandbox(_mf) if _mf['index.html'] else "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your code using the download button above.</div>",
|
| 6434 |
}
|
| 6435 |
else:
|
| 6436 |
# Still streaming, show partial content
|
| 6437 |
yield {
|
| 6438 |
code_output: gr.update(value=content, language="html"),
|
| 6439 |
history_output: history_to_chatbot_messages(_history),
|
| 6440 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>Generating transformers.js app...</div>",
|
| 6441 |
}
|
| 6442 |
elif language == "svelte":
|
| 6443 |
# For Svelte, just show the content as it streams
|
|
@@ -6445,7 +6424,6 @@ This will help me create a better design for you."""
|
|
| 6445 |
yield {
|
| 6446 |
code_output: gr.update(value=content, language="html"),
|
| 6447 |
history_output: history_to_chatbot_messages(_history),
|
| 6448 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>Generating Svelte app...</div>",
|
| 6449 |
}
|
| 6450 |
else:
|
| 6451 |
clean_code = remove_code_block(content)
|
|
@@ -6465,7 +6443,6 @@ This will help me create a better design for you."""
|
|
| 6465 |
yield {
|
| 6466 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6467 |
history_output: history_to_chatbot_messages(_history),
|
| 6468 |
-
sandbox: preview_val or "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML or Streamlit-in-Python.</div>",
|
| 6469 |
}
|
| 6470 |
else:
|
| 6471 |
# Model returned search/replace changes - apply them
|
|
@@ -6484,7 +6461,6 @@ This will help me create a better design for you."""
|
|
| 6484 |
yield {
|
| 6485 |
code_output: gr.update(value=clean_content, language=get_gradio_language(language)),
|
| 6486 |
history_output: history_to_chatbot_messages(_history),
|
| 6487 |
-
sandbox: preview_val or "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML or Streamlit-in-Python.</div>",
|
| 6488 |
}
|
| 6489 |
else:
|
| 6490 |
preview_val = None
|
|
@@ -6499,7 +6475,6 @@ This will help me create a better design for you."""
|
|
| 6499 |
yield {
|
| 6500 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6501 |
history_output: history_to_chatbot_messages(_history),
|
| 6502 |
-
sandbox: preview_val or "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML or Streamlit-in-Python.</div>",
|
| 6503 |
}
|
| 6504 |
# Skip chunks with empty choices (end of stream)
|
| 6505 |
# Do not treat as error
|
|
@@ -6514,7 +6489,6 @@ This will help me create a better design for you."""
|
|
| 6514 |
yield {
|
| 6515 |
code_output: formatted_output,
|
| 6516 |
history: _history,
|
| 6517 |
-
sandbox: send_transformers_to_sandbox(files),
|
| 6518 |
history_output: history_to_chatbot_messages(_history),
|
| 6519 |
}
|
| 6520 |
elif has_existing_content:
|
|
@@ -6526,7 +6500,6 @@ This will help me create a better design for you."""
|
|
| 6526 |
yield {
|
| 6527 |
code_output: modified_content,
|
| 6528 |
history: _history,
|
| 6529 |
-
sandbox: send_transformers_to_sandbox(_mf),
|
| 6530 |
history_output: history_to_chatbot_messages(_history),
|
| 6531 |
}
|
| 6532 |
else:
|
|
@@ -6535,7 +6508,6 @@ This will help me create a better design for you."""
|
|
| 6535 |
yield {
|
| 6536 |
code_output: content,
|
| 6537 |
history: _history,
|
| 6538 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>Error parsing transformers.js output. Please try again.</div>",
|
| 6539 |
history_output: history_to_chatbot_messages(_history),
|
| 6540 |
}
|
| 6541 |
elif language == "svelte":
|
|
@@ -6548,7 +6520,6 @@ This will help me create a better design for you."""
|
|
| 6548 |
yield {
|
| 6549 |
code_output: formatted_output,
|
| 6550 |
history: _history,
|
| 6551 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your Svelte code using the download button above.</div>",
|
| 6552 |
history_output: history_to_chatbot_messages(_history),
|
| 6553 |
}
|
| 6554 |
elif has_existing_content:
|
|
@@ -6559,7 +6530,6 @@ This will help me create a better design for you."""
|
|
| 6559 |
yield {
|
| 6560 |
code_output: modified_content,
|
| 6561 |
history: _history,
|
| 6562 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your Svelte code using the download button above.</div>",
|
| 6563 |
history_output: history_to_chatbot_messages(_history),
|
| 6564 |
}
|
| 6565 |
else:
|
|
@@ -6568,7 +6538,6 @@ This will help me create a better design for you."""
|
|
| 6568 |
yield {
|
| 6569 |
code_output: content,
|
| 6570 |
history: _history,
|
| 6571 |
-
sandbox: "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your Svelte code using the download button above.</div>",
|
| 6572 |
history_output: history_to_chatbot_messages(_history),
|
| 6573 |
}
|
| 6574 |
elif has_existing_content:
|
|
@@ -6590,7 +6559,6 @@ This will help me create a better design for you."""
|
|
| 6590 |
yield {
|
| 6591 |
code_output: clean_content,
|
| 6592 |
history: _history,
|
| 6593 |
-
sandbox: ((send_to_sandbox_with_refresh(inline_multipage_into_single_preview(parse_multipage_html_output(clean_content))) if parse_multipage_html_output(clean_content).get('index.html') else send_to_sandbox_with_refresh(clean_content)) if language == "html" else (send_streamlit_to_stlite(clean_content) if (language == "python" and is_streamlit_code(clean_content)) else "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML or Streamlit-in-Python.</div>")),
|
| 6594 |
history_output: history_to_chatbot_messages(_history),
|
| 6595 |
}
|
| 6596 |
else:
|
|
@@ -6638,7 +6606,6 @@ This will help me create a better design for you."""
|
|
| 6638 |
yield {
|
| 6639 |
code_output: final_content,
|
| 6640 |
history: _history,
|
| 6641 |
-
sandbox: deploy_message,
|
| 6642 |
history_output: history_to_chatbot_messages(_history),
|
| 6643 |
}
|
| 6644 |
except Exception as e:
|
|
@@ -7916,7 +7883,6 @@ with gr.Blocks(
|
|
| 7916 |
gr.update(value="Please enter a URL.", visible=True),
|
| 7917 |
gr.update(),
|
| 7918 |
gr.update(),
|
| 7919 |
-
gr.update(),
|
| 7920 |
[],
|
| 7921 |
[],
|
| 7922 |
gr.update(value="", visible=False),
|
|
@@ -7949,7 +7915,6 @@ with gr.Blocks(
|
|
| 7949 |
return [
|
| 7950 |
gr.update(value=status, visible=True),
|
| 7951 |
gr.update(value=code, language=code_lang), # Use html for transformers.js display
|
| 7952 |
-
gr.update(value=""),
|
| 7953 |
gr.update(value="", visible=False), # hide import textbox after submit
|
| 7954 |
loaded_history,
|
| 7955 |
history_to_chatbot_messages(loaded_history),
|
|
@@ -7975,7 +7940,6 @@ with gr.Blocks(
|
|
| 7975 |
return [
|
| 7976 |
gr.update(value=status, visible=True),
|
| 7977 |
gr.update(value=code, language=code_lang),
|
| 7978 |
-
gr.update(value=""),
|
| 7979 |
gr.update(value="", visible=False), # hide import textbox after submit
|
| 7980 |
loaded_history,
|
| 7981 |
history_to_chatbot_messages(loaded_history),
|
|
@@ -8253,9 +8217,6 @@ with gr.Blocks(
|
|
| 8253 |
</div>
|
| 8254 |
"""
|
| 8255 |
|
| 8256 |
-
tjs_html_code.change(show_tjs_deployment_message, inputs=[tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8257 |
-
tjs_js_code.change(show_tjs_deployment_message, inputs=[tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8258 |
-
tjs_css_code.change(show_tjs_deployment_message, inputs=[tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8259 |
|
| 8260 |
def show_deploy_components(*args):
|
| 8261 |
return [gr.Textbox(visible=True), gr.Dropdown(visible=True), gr.Button(visible=True)]
|
|
@@ -8298,7 +8259,6 @@ with gr.Blocks(
|
|
| 8298 |
outputs=[
|
| 8299 |
load_project_status,
|
| 8300 |
code_output,
|
| 8301 |
-
sandbox,
|
| 8302 |
load_project_url,
|
| 8303 |
history,
|
| 8304 |
history_output,
|
|
@@ -8330,7 +8290,7 @@ with gr.Blocks(
|
|
| 8330 |
).then(
|
| 8331 |
generation_code,
|
| 8332 |
inputs=[input, image_input, website_url_input, setting, history, current_model, language_dropdown, provider_state],
|
| 8333 |
-
outputs=[code_output, history,
|
| 8334 |
).then(
|
| 8335 |
end_generation_ui,
|
| 8336 |
inputs=None,
|
|
@@ -8371,7 +8331,7 @@ with gr.Blocks(
|
|
| 8371 |
).then(
|
| 8372 |
generation_code,
|
| 8373 |
inputs=[input, image_input, website_url_input, setting, history, current_model, language_dropdown, provider_state],
|
| 8374 |
-
outputs=[code_output, history,
|
| 8375 |
).then(
|
| 8376 |
end_generation_ui,
|
| 8377 |
inputs=None,
|
|
@@ -8411,8 +8371,6 @@ with gr.Blocks(
|
|
| 8411 |
</div>
|
| 8412 |
"""
|
| 8413 |
|
| 8414 |
-
code_output.change(show_deployment_message, inputs=[code_output, language_dropdown, tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8415 |
-
language_dropdown.change(show_deployment_message, inputs=[code_output, language_dropdown, tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8416 |
# Update deploy button text when space name changes
|
| 8417 |
space_name_input.change(update_deploy_button_text, inputs=[space_name_input], outputs=[deploy_btn])
|
| 8418 |
clear_btn.click(clear_history, outputs=[history, history_output, website_url_input])
|
|
|
|
| 5827 |
yield {
|
| 5828 |
code_output: error_message,
|
| 5829 |
history_output: history_to_chatbot_messages(_history or []),
|
|
|
|
| 5830 |
}
|
| 5831 |
return
|
| 5832 |
|
|
|
|
| 5945 |
yield {
|
| 5946 |
code_output: modified_content,
|
| 5947 |
history: _history,
|
|
|
|
| 5948 |
history_output: history_to_chatbot_messages(_history),
|
| 5949 |
}
|
| 5950 |
return
|
|
|
|
| 6070 |
yield {
|
| 6071 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6072 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6073 |
}
|
| 6074 |
|
| 6075 |
except Exception as e:
|
|
|
|
| 6089 |
yield {
|
| 6090 |
code_output: formatted_output,
|
| 6091 |
history: _history,
|
|
|
|
| 6092 |
history_output: history_to_chatbot_messages(_history),
|
| 6093 |
}
|
| 6094 |
else:
|
| 6095 |
yield {
|
| 6096 |
code_output: clean_code,
|
| 6097 |
history: _history,
|
|
|
|
| 6098 |
history_output: history_to_chatbot_messages(_history),
|
| 6099 |
}
|
| 6100 |
elif language == "svelte":
|
|
|
|
| 6107 |
yield {
|
| 6108 |
code_output: formatted_output,
|
| 6109 |
history: _history,
|
|
|
|
| 6110 |
history_output: history_to_chatbot_messages(_history),
|
| 6111 |
}
|
| 6112 |
else:
|
| 6113 |
yield {
|
| 6114 |
code_output: clean_code,
|
| 6115 |
history: _history,
|
|
|
|
| 6116 |
history_output: history_to_chatbot_messages(_history),
|
| 6117 |
}
|
| 6118 |
else:
|
|
|
|
| 6126 |
yield {
|
| 6127 |
code_output: clean_content,
|
| 6128 |
history: _history,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6129 |
history_output: history_to_chatbot_messages(_history),
|
| 6130 |
}
|
| 6131 |
else:
|
|
|
|
| 6169 |
yield {
|
| 6170 |
code_output: final_content,
|
| 6171 |
history: _history,
|
|
|
|
| 6172 |
history_output: history_to_chatbot_messages(_history),
|
| 6173 |
}
|
| 6174 |
return
|
|
|
|
| 6236 |
yield {
|
| 6237 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6238 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6239 |
}
|
| 6240 |
except Exception as e:
|
| 6241 |
content = f"Error with GLM-4.5V: {str(e)}\n\nPlease make sure HF_TOKEN environment variable is set."
|
|
|
|
| 6256 |
yield {
|
| 6257 |
code_output: clean_code,
|
| 6258 |
history: _history,
|
|
|
|
| 6259 |
history_output: history_to_chatbot_messages(_history),
|
| 6260 |
}
|
| 6261 |
return
|
|
|
|
| 6349 |
yield {
|
| 6350 |
code_output: gr.update(value=(content or "") + "\n<!-- " + status_line + " -->", language="html"),
|
| 6351 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6352 |
}
|
| 6353 |
continue
|
| 6354 |
# Filter placeholders
|
|
|
|
| 6402 |
yield {
|
| 6403 |
code_output: gr.update(value=merged_html, language="html"),
|
| 6404 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6405 |
}
|
| 6406 |
elif has_existing_content:
|
| 6407 |
# Model is returning search/replace changes for transformers.js - apply them
|
|
|
|
| 6411 |
yield {
|
| 6412 |
code_output: gr.update(value=modified_content, language="html"),
|
| 6413 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6414 |
}
|
| 6415 |
else:
|
| 6416 |
# Still streaming, show partial content
|
| 6417 |
yield {
|
| 6418 |
code_output: gr.update(value=content, language="html"),
|
| 6419 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6420 |
}
|
| 6421 |
elif language == "svelte":
|
| 6422 |
# For Svelte, just show the content as it streams
|
|
|
|
| 6424 |
yield {
|
| 6425 |
code_output: gr.update(value=content, language="html"),
|
| 6426 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6427 |
}
|
| 6428 |
else:
|
| 6429 |
clean_code = remove_code_block(content)
|
|
|
|
| 6443 |
yield {
|
| 6444 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6445 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6446 |
}
|
| 6447 |
else:
|
| 6448 |
# Model returned search/replace changes - apply them
|
|
|
|
| 6461 |
yield {
|
| 6462 |
code_output: gr.update(value=clean_content, language=get_gradio_language(language)),
|
| 6463 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6464 |
}
|
| 6465 |
else:
|
| 6466 |
preview_val = None
|
|
|
|
| 6475 |
yield {
|
| 6476 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6477 |
history_output: history_to_chatbot_messages(_history),
|
|
|
|
| 6478 |
}
|
| 6479 |
# Skip chunks with empty choices (end of stream)
|
| 6480 |
# Do not treat as error
|
|
|
|
| 6489 |
yield {
|
| 6490 |
code_output: formatted_output,
|
| 6491 |
history: _history,
|
|
|
|
| 6492 |
history_output: history_to_chatbot_messages(_history),
|
| 6493 |
}
|
| 6494 |
elif has_existing_content:
|
|
|
|
| 6500 |
yield {
|
| 6501 |
code_output: modified_content,
|
| 6502 |
history: _history,
|
|
|
|
| 6503 |
history_output: history_to_chatbot_messages(_history),
|
| 6504 |
}
|
| 6505 |
else:
|
|
|
|
| 6508 |
yield {
|
| 6509 |
code_output: content,
|
| 6510 |
history: _history,
|
|
|
|
| 6511 |
history_output: history_to_chatbot_messages(_history),
|
| 6512 |
}
|
| 6513 |
elif language == "svelte":
|
|
|
|
| 6520 |
yield {
|
| 6521 |
code_output: formatted_output,
|
| 6522 |
history: _history,
|
|
|
|
| 6523 |
history_output: history_to_chatbot_messages(_history),
|
| 6524 |
}
|
| 6525 |
elif has_existing_content:
|
|
|
|
| 6530 |
yield {
|
| 6531 |
code_output: modified_content,
|
| 6532 |
history: _history,
|
|
|
|
| 6533 |
history_output: history_to_chatbot_messages(_history),
|
| 6534 |
}
|
| 6535 |
else:
|
|
|
|
| 6538 |
yield {
|
| 6539 |
code_output: content,
|
| 6540 |
history: _history,
|
|
|
|
| 6541 |
history_output: history_to_chatbot_messages(_history),
|
| 6542 |
}
|
| 6543 |
elif has_existing_content:
|
|
|
|
| 6559 |
yield {
|
| 6560 |
code_output: clean_content,
|
| 6561 |
history: _history,
|
|
|
|
| 6562 |
history_output: history_to_chatbot_messages(_history),
|
| 6563 |
}
|
| 6564 |
else:
|
|
|
|
| 6606 |
yield {
|
| 6607 |
code_output: final_content,
|
| 6608 |
history: _history,
|
|
|
|
| 6609 |
history_output: history_to_chatbot_messages(_history),
|
| 6610 |
}
|
| 6611 |
except Exception as e:
|
|
|
|
| 7883 |
gr.update(value="Please enter a URL.", visible=True),
|
| 7884 |
gr.update(),
|
| 7885 |
gr.update(),
|
|
|
|
| 7886 |
[],
|
| 7887 |
[],
|
| 7888 |
gr.update(value="", visible=False),
|
|
|
|
| 7915 |
return [
|
| 7916 |
gr.update(value=status, visible=True),
|
| 7917 |
gr.update(value=code, language=code_lang), # Use html for transformers.js display
|
|
|
|
| 7918 |
gr.update(value="", visible=False), # hide import textbox after submit
|
| 7919 |
loaded_history,
|
| 7920 |
history_to_chatbot_messages(loaded_history),
|
|
|
|
| 7940 |
return [
|
| 7941 |
gr.update(value=status, visible=True),
|
| 7942 |
gr.update(value=code, language=code_lang),
|
|
|
|
| 7943 |
gr.update(value="", visible=False), # hide import textbox after submit
|
| 7944 |
loaded_history,
|
| 7945 |
history_to_chatbot_messages(loaded_history),
|
|
|
|
| 8217 |
</div>
|
| 8218 |
"""
|
| 8219 |
|
|
|
|
|
|
|
|
|
|
| 8220 |
|
| 8221 |
def show_deploy_components(*args):
|
| 8222 |
return [gr.Textbox(visible=True), gr.Dropdown(visible=True), gr.Button(visible=True)]
|
|
|
|
| 8259 |
outputs=[
|
| 8260 |
load_project_status,
|
| 8261 |
code_output,
|
|
|
|
| 8262 |
load_project_url,
|
| 8263 |
history,
|
| 8264 |
history_output,
|
|
|
|
| 8290 |
).then(
|
| 8291 |
generation_code,
|
| 8292 |
inputs=[input, image_input, website_url_input, setting, history, current_model, language_dropdown, provider_state],
|
| 8293 |
+
outputs=[code_output, history, history_output]
|
| 8294 |
).then(
|
| 8295 |
end_generation_ui,
|
| 8296 |
inputs=None,
|
|
|
|
| 8331 |
).then(
|
| 8332 |
generation_code,
|
| 8333 |
inputs=[input, image_input, website_url_input, setting, history, current_model, language_dropdown, provider_state],
|
| 8334 |
+
outputs=[code_output, history, history_output]
|
| 8335 |
).then(
|
| 8336 |
end_generation_ui,
|
| 8337 |
inputs=None,
|
|
|
|
| 8371 |
</div>
|
| 8372 |
"""
|
| 8373 |
|
|
|
|
|
|
|
| 8374 |
# Update deploy button text when space name changes
|
| 8375 |
space_name_input.change(update_deploy_button_text, inputs=[space_name_input], outputs=[deploy_btn])
|
| 8376 |
clear_btn.click(clear_history, outputs=[history, history_output, website_url_input])
|