Spaces:
Running
Running
update
Browse files
app.py
CHANGED
|
@@ -1451,7 +1451,7 @@ This will help me create a better design for you."""
|
|
| 1451 |
model=_current_model["id"],
|
| 1452 |
messages=messages,
|
| 1453 |
stream=True,
|
| 1454 |
-
max_tokens=
|
| 1455 |
)
|
| 1456 |
content = ""
|
| 1457 |
for chunk in completion:
|
|
@@ -2147,20 +2147,22 @@ with gr.Blocks(
|
|
| 2147 |
except Exception as e:
|
| 2148 |
return gr.update(value=f"Error creating Space: {e}", visible=True)
|
| 2149 |
# Streamlit/docker logic
|
| 2150 |
-
if sdk == "docker"
|
| 2151 |
try:
|
| 2152 |
-
#
|
| 2153 |
-
|
| 2154 |
-
|
| 2155 |
-
|
| 2156 |
-
|
| 2157 |
-
|
| 2158 |
-
|
| 2159 |
-
|
| 2160 |
-
|
| 2161 |
-
|
|
|
|
|
|
|
| 2162 |
|
| 2163 |
-
# Upload the user's code to
|
| 2164 |
import tempfile
|
| 2165 |
with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as f:
|
| 2166 |
f.write(code)
|
|
@@ -2187,7 +2189,8 @@ with gr.Blocks(
|
|
| 2187 |
os.unlink(temp_path)
|
| 2188 |
|
| 2189 |
except Exception as e:
|
| 2190 |
-
|
|
|
|
| 2191 |
# Transformers.js logic
|
| 2192 |
elif sdk_name == "Transformers.js" and not is_update:
|
| 2193 |
try:
|
|
|
|
| 1451 |
model=_current_model["id"],
|
| 1452 |
messages=messages,
|
| 1453 |
stream=True,
|
| 1454 |
+
max_tokens=16384
|
| 1455 |
)
|
| 1456 |
content = ""
|
| 1457 |
for chunk in completion:
|
|
|
|
| 2147 |
except Exception as e:
|
| 2148 |
return gr.update(value=f"Error creating Space: {e}", visible=True)
|
| 2149 |
# Streamlit/docker logic
|
| 2150 |
+
if sdk == "docker":
|
| 2151 |
try:
|
| 2152 |
+
# For new spaces, duplicate the template first
|
| 2153 |
+
if not is_update:
|
| 2154 |
+
# Use duplicate_space to create a Streamlit template space
|
| 2155 |
+
from huggingface_hub import duplicate_space
|
| 2156 |
+
|
| 2157 |
+
# Duplicate the streamlit template space
|
| 2158 |
+
duplicated_repo = duplicate_space(
|
| 2159 |
+
from_id="streamlit/streamlit-template-space",
|
| 2160 |
+
to_id=space_name.strip(),
|
| 2161 |
+
token=token.token,
|
| 2162 |
+
exist_ok=True
|
| 2163 |
+
)
|
| 2164 |
|
| 2165 |
+
# Upload the user's code to src/streamlit_app.py (for both new and existing spaces)
|
| 2166 |
import tempfile
|
| 2167 |
with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as f:
|
| 2168 |
f.write(code)
|
|
|
|
| 2189 |
os.unlink(temp_path)
|
| 2190 |
|
| 2191 |
except Exception as e:
|
| 2192 |
+
error_prefix = "Error duplicating Streamlit space" if not is_update else "Error updating Streamlit space"
|
| 2193 |
+
return gr.update(value=f"{error_prefix}: {e}", visible=True)
|
| 2194 |
# Transformers.js logic
|
| 2195 |
elif sdk_name == "Transformers.js" and not is_update:
|
| 2196 |
try:
|