Update space
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import requests
|
4 |
from bs4 import BeautifulSoup
|
5 |
-
import pandas as pd
|
6 |
|
7 |
client = InferenceClient("meta-llama/Llama-3.2-3B-Instruct")
|
8 |
|
@@ -76,6 +75,14 @@ def handle_prepare(index):
|
|
76 |
return f"Prepare a 10-minute reading on what I should know before the class for the topic: {topic}"
|
77 |
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
# Gradio App
|
80 |
with gr.Blocks() as demo:
|
81 |
with gr.Row():
|
@@ -97,23 +104,14 @@ with gr.Blocks() as demo:
|
|
97 |
],
|
98 |
)
|
99 |
|
100 |
-
# Container for dynamically generated buttons
|
101 |
buttons_container = gr.Column(visible=True)
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
inputs=[gr.State(i)],
|
110 |
-
outputs=[chatbot],
|
111 |
-
)
|
112 |
-
components.append(btn)
|
113 |
-
return components
|
114 |
-
|
115 |
-
# Create buttons when table is extracted
|
116 |
-
extract_btn.click(fn=create_buttons, inputs=[], outputs=[buttons_container])
|
117 |
|
118 |
if __name__ == "__main__":
|
119 |
demo.launch()
|
|
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import requests
|
4 |
from bs4 import BeautifulSoup
|
|
|
5 |
|
6 |
client = InferenceClient("meta-llama/Llama-3.2-3B-Instruct")
|
7 |
|
|
|
75 |
return f"Prepare a 10-minute reading on what I should know before the class for the topic: {topic}"
|
76 |
|
77 |
|
78 |
+
def create_buttons():
|
79 |
+
# Dynamically create buttons for each topic
|
80 |
+
button_list = []
|
81 |
+
for i, row in enumerate(data):
|
82 |
+
button_list.append(gr.Button(f"Prepare: {row['Topic']}").style(full_width=False))
|
83 |
+
return button_list
|
84 |
+
|
85 |
+
|
86 |
# Gradio App
|
87 |
with gr.Blocks() as demo:
|
88 |
with gr.Row():
|
|
|
104 |
],
|
105 |
)
|
106 |
|
|
|
107 |
buttons_container = gr.Column(visible=True)
|
108 |
|
109 |
+
# Dynamically add buttons after table extraction
|
110 |
+
def update_buttons():
|
111 |
+
buttons = create_buttons()
|
112 |
+
return gr.update(components=buttons)
|
113 |
+
|
114 |
+
extract_btn.click(fn=update_buttons, inputs=[], outputs=[buttons_container])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
if __name__ == "__main__":
|
117 |
demo.launch()
|