Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -216,14 +216,85 @@ def generate(
|
|
216 |
return chat, history, user_message, ""
|
217 |
|
218 |
examples = [
|
219 |
-
"How
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
]
|
228 |
|
229 |
def clear_chat():
|
|
|
216 |
return chat, history, user_message, ""
|
217 |
|
218 |
examples = [
|
219 |
+
"""How to upload dataframe with content of file upload? I did not find any documentation of this.
|
220 |
+
I want to upload a CSV file, display the data in an interactive table and then us the table conents to create a plot. But I am stuck with gluing the components together.
|
221 |
+
|
222 |
+
import gradio as gr
|
223 |
+
default_csv = "Phase,Activity,Start date,End date\n\"Mapping the Field\",\"Literature review\",2024-01-01,2024-01-31"
|
224 |
+
|
225 |
+
def process_csv_text(text):
|
226 |
+
df = pd.read_csv(StringIO(text), parse_dates=["Start date", "End date"])
|
227 |
+
return df
|
228 |
+
|
229 |
+
with gr.Blocks() as demo:
|
230 |
+
upload_button = gr.UploadButton(label="Upload Timetable", file_types = ['.csv'], live=True, file_count = "single")
|
231 |
+
table = gr.Dataframe(headers=["Phase", "Activity", "Start date", "End date"], col_count=4, default=process_csv_text(default_csv))
|
232 |
+
image = gr.Plot()
|
233 |
+
upload_button.click(fn=process_csv_text, inputs=upload_button, outputs=table, api_name="upload_csv")
|
234 |
+
|
235 |
+
demo.launch()
|
236 |
+
""",
|
237 |
+
"""Hi, I want to remove the "clear" button in Gradio Interface. Is there a way to do such a thing?""",
|
238 |
+
"""Why the botton can not apply css? But textbox works great.
|
239 |
+
|
240 |
+
import gradio as gr
|
241 |
+
import numpy as np
|
242 |
+
|
243 |
+
css = \"""
|
244 |
+
#warning {background-color: #FFCCCB}
|
245 |
+
.feedback textarea {font-size: 64px !important}
|
246 |
+
\"""
|
247 |
+
|
248 |
+
with gr.Blocks(css=css) as demo:
|
249 |
+
box1 = gr.Button(value="Good Job", elem_classes="feedback")
|
250 |
+
box2 = gr.Textbox(value="Failure", elem_id="warning", elem_classes="feedback")
|
251 |
+
|
252 |
+
if __name__ == "__main__":
|
253 |
+
demo.launch(inbrowser=True) """,
|
254 |
+
|
255 |
+
"""
|
256 |
+
I'm very new to both huggingface and Gradio, so forgive me if this is a trivial issue, and I'm just a fool.
|
257 |
+
|
258 |
+
I'm using a Blocks object to implement a very basic chatbot, and I'd like to essentially clear the input textbox after the user presses enter or presses the submit button.
|
259 |
+
|
260 |
+
with gr.Blocks() as test:
|
261 |
+
outp = gr.Chatbot(label="Reply", )
|
262 |
+
inp = gr.Textbox(label="Chat with AI")
|
263 |
+
inp.submit(chatbot, [outp, inp], outp)
|
264 |
+
inp.update(lambda: None, inp)
|
265 |
+
btn = gr.Button("Submit")
|
266 |
+
btn.click(fn=chatbot, inputs=inp, outputs=outp)
|
267 |
+
|
268 |
+
My code looks like this currently.
|
269 |
+
I simply wish to clear the input textbox after the input is submitted.
|
270 |
+
""",
|
271 |
+
"""
|
272 |
+
I am trying to force Gradio to show a white background colour ALL the time in all browsers. My code below works to force white colour on my desktop (using Firefox) but on mobile it's still showing the typical default Gradio black background. How to change this behaviour to permanently show a white background in all devices? Thank you
|
273 |
+
```python
|
274 |
+
demo = gr.Interface(
|
275 |
+
lambda x:x+x,
|
276 |
+
inputs=gr.Textbox(label='Test'),
|
277 |
+
outputs=gr.Textbox(label='test2'),
|
278 |
+
css=".gradio-container {background-color: white} "
|
279 |
+
).launch(share=False)
|
280 |
+
```
|
281 |
+
""",
|
282 |
+
"""
|
283 |
+
I am using gradio. I'm creating some tabs and when i click a button i want to use the name of the tabs as an input for a function. How does it work? Thank you very much!
|
284 |
+
|
285 |
+
My way of creating tabs would be for example this, with blocks:
|
286 |
+
```python
|
287 |
+
with gr.Tabs() as tabs:
|
288 |
+
with gr.TabItem("test1"):
|
289 |
+
bt_test1 = gr.Button('test1')
|
290 |
+
with gr.TabItem("test2"):
|
291 |
+
bt_test2 = gr.Button('test2')
|
292 |
+
```
|
293 |
+
""",
|
294 |
+
"""
|
295 |
+
Can I change the layout when I click a button in gradio?
|
296 |
+
For example, I would like to add a row or change some other layout of the frame when i click a button. how can i do this operation.
|
297 |
+
"""
|
298 |
]
|
299 |
|
300 |
def clear_chat():
|