Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -108,7 +108,7 @@ def create_ui():
|
|
108 |
|
109 |
with gr.Blocks() as demo:
|
110 |
gr.Markdown("# Hugging Face Most Liked Spaces")
|
111 |
-
|
112 |
|
113 |
with gr.Row():
|
114 |
with gr.Column(scale=1):
|
@@ -123,21 +123,27 @@ def create_ui():
|
|
123 |
app_py_content = gr.Code(language="python", label="app.py ๋ด์ฉ")
|
124 |
|
125 |
def on_select(evt: gr.SelectData):
|
126 |
-
|
127 |
-
|
128 |
-
if
|
129 |
-
app_content = get_app_py_content(
|
130 |
-
|
|
|
|
|
131 |
return None, "์ ํ๋ space๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.", ""
|
132 |
|
133 |
-
def on_summarize(
|
134 |
-
if
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
return "์ ํ๋ space๊ฐ ์์ต๋๋ค. ๋จผ์ ๋ฆฌ์คํธ์์ space๋ฅผ ์ ํํด์ฃผ์ธ์."
|
138 |
|
139 |
-
space_list.select(on_select, None, [
|
140 |
-
summarize_btn.click(on_summarize, inputs=[
|
141 |
|
142 |
return demo
|
143 |
|
|
|
108 |
|
109 |
with gr.Blocks() as demo:
|
110 |
gr.Markdown("# Hugging Face Most Liked Spaces")
|
111 |
+
selected_space_id = gr.State(None)
|
112 |
|
113 |
with gr.Row():
|
114 |
with gr.Column(scale=1):
|
|
|
123 |
app_py_content = gr.Code(language="python", label="app.py ๋ด์ฉ")
|
124 |
|
125 |
def on_select(evt: gr.SelectData):
|
126 |
+
selected_id = evt.value[1] # tuple์ ๋ ๋ฒ์งธ ์์๊ฐ space_id์
๋๋ค.
|
127 |
+
selected_space = next((space for space in formatted_spaces if space['id'] == selected_id), None)
|
128 |
+
if selected_space:
|
129 |
+
app_content = get_app_py_content(selected_id)
|
130 |
+
print(f"Selected space: {selected_space['name']}") # ๋๋ฒ๊น
์ฉ ์ถ๋ ฅ
|
131 |
+
return selected_id, selected_space['url'], app_content
|
132 |
+
print("Selected space not found") # ๋๋ฒ๊น
์ฉ ์ถ๋ ฅ
|
133 |
return None, "์ ํ๋ space๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.", ""
|
134 |
|
135 |
+
def on_summarize(space_id):
|
136 |
+
if space_id:
|
137 |
+
selected_space = next((space for space in formatted_spaces if space['id'] == space_id), None)
|
138 |
+
if selected_space:
|
139 |
+
summary = summarize_space(selected_space)
|
140 |
+
print(f"Summarizing space: {selected_space['name']}") # ๋๋ฒ๊น
์ฉ ์ถ๋ ฅ
|
141 |
+
return summary
|
142 |
+
print("No space selected for summarization") # ๋๋ฒ๊น
์ฉ ์ถ๋ ฅ
|
143 |
return "์ ํ๋ space๊ฐ ์์ต๋๋ค. ๋จผ์ ๋ฆฌ์คํธ์์ space๋ฅผ ์ ํํด์ฃผ์ธ์."
|
144 |
|
145 |
+
space_list.select(on_select, None, [selected_space_id, output, app_py_content])
|
146 |
+
summarize_btn.click(on_summarize, inputs=[selected_space_id], outputs=[output])
|
147 |
|
148 |
return demo
|
149 |
|