Spaces:
Sleeping
Sleeping
Hjgugugjhuhjggg
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -193,6 +193,7 @@ async def generate(body: GenerateRequest):
|
|
193 |
async def download_all_models_in_background():
|
194 |
models_url = "https://huggingface.co/api/models"
|
195 |
try:
|
|
|
196 |
response = requests.get(models_url)
|
197 |
if response.status_code != 200:
|
198 |
raise HTTPException(status_code=500, detail="Error al obtener la lista de modelos.")
|
@@ -200,9 +201,14 @@ async def download_all_models_in_background():
|
|
200 |
models = response.json()
|
201 |
for model in models:
|
202 |
model_name = model["id"]
|
203 |
-
|
|
|
|
|
|
|
|
|
|
|
204 |
except Exception as e:
|
205 |
-
|
206 |
|
207 |
# Funci贸n que corre en segundo plano para descargar modelos
|
208 |
def run_in_background():
|
@@ -210,4 +216,8 @@ def run_in_background():
|
|
210 |
|
211 |
# Si este archivo se ejecuta directamente, inicia el servidor
|
212 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
213 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
193 |
async def download_all_models_in_background():
|
194 |
models_url = "https://huggingface.co/api/models"
|
195 |
try:
|
196 |
+
# Se obtiene la lista de modelos
|
197 |
response = requests.get(models_url)
|
198 |
if response.status_code != 200:
|
199 |
raise HTTPException(status_code=500, detail="Error al obtener la lista de modelos.")
|
|
|
201 |
models = response.json()
|
202 |
for model in models:
|
203 |
model_name = model["id"]
|
204 |
+
# Verifica si ya est谩 en S3 antes de intentar descargarlo
|
205 |
+
try:
|
206 |
+
await model_loader.download_and_save_model_from_huggingface(model_name)
|
207 |
+
except Exception as e:
|
208 |
+
logging.error(f"Error descargando o guardando el modelo {model_name}: {str(e)}")
|
209 |
+
|
210 |
except Exception as e:
|
211 |
+
logging.error(f"Error al obtener modelos de Hugging Face: {str(e)}")
|
212 |
|
213 |
# Funci贸n que corre en segundo plano para descargar modelos
|
214 |
def run_in_background():
|
|
|
216 |
|
217 |
# Si este archivo se ejecuta directamente, inicia el servidor
|
218 |
if __name__ == "__main__":
|
219 |
+
# Ejecutar la descarga de modelos en segundo plano
|
220 |
+
run_in_background()
|
221 |
+
|
222 |
+
# Iniciar el servidor FastAPI
|
223 |
uvicorn.run(app, host="0.0.0.0", port=7860)
|