Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from http import HTTPStatus
|
|
4 |
from typing import Dict, List, Optional, Tuple
|
5 |
import base64
|
6 |
import anthropic
|
7 |
-
from functools import partial
|
8 |
|
9 |
import gradio as gr
|
10 |
import modelscope_studio.components.base as ms
|
@@ -64,10 +64,14 @@ def send_to_sandbox(code):
|
|
64 |
return f"<iframe src=\"{data_uri}\" width=\"100%\" height=\"920px\"></iframe>"
|
65 |
|
66 |
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
def demo_card_click(e: gr.EventData):
|
69 |
index = e._data['component']['index']
|
70 |
-
return
|
71 |
|
72 |
|
73 |
with gr.Blocks(css_paths="app.css") as demo:
|
|
|
4 |
from typing import Dict, List, Optional, Tuple
|
5 |
import base64
|
6 |
import anthropic
|
7 |
+
from functools import partial, lru_cache
|
8 |
|
9 |
import gradio as gr
|
10 |
import modelscope_studio.components.base as ms
|
|
|
64 |
return f"<iframe src=\"{data_uri}\" width=\"100%\" height=\"920px\"></iframe>"
|
65 |
|
66 |
|
67 |
+
# 캐시 구현
|
68 |
+
@lru_cache(maxsize=len(DEMO_LIST))
|
69 |
+
def get_demo_description(index: int) -> str:
|
70 |
+
return DEMO_LIST[index]['description']
|
71 |
+
|
72 |
def demo_card_click(e: gr.EventData):
|
73 |
index = e._data['component']['index']
|
74 |
+
return get_demo_description(index)
|
75 |
|
76 |
|
77 |
with gr.Blocks(css_paths="app.css") as demo:
|