Update app.py
Browse files
app.py
CHANGED
|
@@ -80,6 +80,7 @@ gradio.utils.watchfn_spaces = watchfn
|
|
| 80 |
DEFAULT_QUESTION = "In MCP's 1st Birthday Hackathon, hosted by Anthropic and Gradio, what percentage of participants submitted a solution so far?"
|
| 81 |
|
| 82 |
CSS_FULL_WIDTH = """
|
|
|
|
| 83 |
html,
|
| 84 |
body,
|
| 85 |
main,
|
|
@@ -101,10 +102,46 @@ main,
|
|
| 101 |
.content-padding {
|
| 102 |
padding: 0 1.5rem 0;
|
| 103 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
"""
|
| 105 |
|
| 106 |
with gr.Blocks(elem_classes=["full-width-app"]) as gaia:
|
| 107 |
-
gr.HTML(
|
|
|
|
| 108 |
|
| 109 |
with gr.Column(elem_classes=["content-padding"]):
|
| 110 |
gr.Markdown("## General AI Assistant")
|
|
|
|
| 80 |
DEFAULT_QUESTION = "In MCP's 1st Birthday Hackathon, hosted by Anthropic and Gradio, what percentage of participants submitted a solution so far?"
|
| 81 |
|
| 82 |
CSS_FULL_WIDTH = """
|
| 83 |
+
<style>
|
| 84 |
html,
|
| 85 |
body,
|
| 86 |
main,
|
|
|
|
| 102 |
.content-padding {
|
| 103 |
padding: 0 1.5rem 0;
|
| 104 |
}
|
| 105 |
+
</style>
|
| 106 |
+
"""
|
| 107 |
+
CSS_JS_AUTO_RESIZE = """
|
| 108 |
+
<style>
|
| 109 |
+
/* Make all Gradio textboxes use auto height */
|
| 110 |
+
textarea {
|
| 111 |
+
height: auto !important;
|
| 112 |
+
min-height: 2em; /* fallback minimal height */
|
| 113 |
+
overflow: hidden !important;
|
| 114 |
+
resize: none !important;
|
| 115 |
+
box-sizing: border-box;
|
| 116 |
+
width: 100% !important;
|
| 117 |
+
}
|
| 118 |
+
/* Optionally, ensure the container width works nicely on mobile */
|
| 119 |
+
.gradio-container {
|
| 120 |
+
width: 100% !important;
|
| 121 |
+
}
|
| 122 |
+
</style>
|
| 123 |
+
|
| 124 |
+
<script>
|
| 125 |
+
window.addEventListener('input', function (event) {
|
| 126 |
+
const el = event.target;
|
| 127 |
+
if (el.tagName === 'TEXTAREA') {
|
| 128 |
+
el.style.height = 'auto';
|
| 129 |
+
el.style.height = (el.scrollHeight) + 'px';
|
| 130 |
+
}
|
| 131 |
+
});
|
| 132 |
+
// On initial load, trigger resizing for existing contents
|
| 133 |
+
window.addEventListener('load', function () {
|
| 134 |
+
document.querySelectorAll('textarea').forEach(el => {
|
| 135 |
+
el.style.height = 'auto';
|
| 136 |
+
el.style.height = (el.scrollHeight) + 'px';
|
| 137 |
+
});
|
| 138 |
+
});
|
| 139 |
+
</script>
|
| 140 |
"""
|
| 141 |
|
| 142 |
with gr.Blocks(elem_classes=["full-width-app"]) as gaia:
|
| 143 |
+
gr.HTML(CSS_FULL_WIDTH}")
|
| 144 |
+
gr.HTML(CSS_JS_AUTO_RESIZE)
|
| 145 |
|
| 146 |
with gr.Column(elem_classes=["content-padding"]):
|
| 147 |
gr.Markdown("## General AI Assistant")
|