Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -108,6 +108,8 @@ def create_ui():
|
|
108 |
|
109 |
with gr.Blocks() as demo:
|
110 |
gr.Markdown("# Hugging Face Most Liked Spaces")
|
|
|
|
|
111 |
with gr.Row():
|
112 |
with gr.Column(scale=1):
|
113 |
space_list = gr.List(
|
@@ -122,22 +124,20 @@ def create_ui():
|
|
122 |
|
123 |
def on_select(evt: gr.SelectData):
|
124 |
selected_space_id = evt.value[1] # tuple์ ๋ ๋ฒ์งธ ์์๊ฐ space_id์
๋๋ค.
|
125 |
-
|
126 |
-
if
|
127 |
-
app_content = get_app_py_content(
|
128 |
-
return
|
129 |
-
return "์ ํ๋ space๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.", ""
|
130 |
-
|
131 |
-
def on_summarize(
|
132 |
-
|
133 |
-
|
134 |
-
if selected_space:
|
135 |
-
summary = summarize_space(selected_space)
|
136 |
return summary
|
137 |
-
return "์ ํ๋ space
|
138 |
|
139 |
-
space_list.select(on_select, None, [output, app_py_content])
|
140 |
-
summarize_btn.click(on_summarize,
|
141 |
|
142 |
return demo
|
143 |
|
|
|
108 |
|
109 |
with gr.Blocks() as demo:
|
110 |
gr.Markdown("# Hugging Face Most Liked Spaces")
|
111 |
+
selected_space = gr.State(None)
|
112 |
+
|
113 |
with gr.Row():
|
114 |
with gr.Column(scale=1):
|
115 |
space_list = gr.List(
|
|
|
124 |
|
125 |
def on_select(evt: gr.SelectData):
|
126 |
selected_space_id = evt.value[1] # tuple์ ๋ ๋ฒ์งธ ์์๊ฐ space_id์
๋๋ค.
|
127 |
+
selected_space_data = next((space for space in formatted_spaces if space['id'] == selected_space_id), None)
|
128 |
+
if selected_space_data:
|
129 |
+
app_content = get_app_py_content(selected_space_data['id'])
|
130 |
+
return selected_space_data, selected_space_data['url'], app_content
|
131 |
+
return None, "์ ํ๋ space๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.", ""
|
132 |
+
|
133 |
+
def on_summarize(space):
|
134 |
+
if space:
|
135 |
+
summary = summarize_space(space)
|
|
|
|
|
136 |
return summary
|
137 |
+
return "์ ํ๋ space๊ฐ ์์ต๋๋ค. ๋จผ์ ๋ฆฌ์คํธ์์ space๋ฅผ ์ ํํด์ฃผ์ธ์."
|
138 |
|
139 |
+
space_list.select(on_select, None, [selected_space, output, app_py_content])
|
140 |
+
summarize_btn.click(on_summarize, inputs=[selected_space], outputs=[output])
|
141 |
|
142 |
return demo
|
143 |
|