Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -320,28 +320,28 @@ async def query_context(
|
|
| 320 |
space_info = next((s for s in spaces_metadata["spaces"] if s["name"] == space_name), None)
|
| 321 |
|
| 322 |
if not space_info:
|
| 323 |
-
|
| 324 |
return {
|
| 325 |
"status": "error",
|
| 326 |
"message": f"Space '{space_name}' no encontrado",
|
| 327 |
"available_spaces": [s["name"] for s in spaces_metadata["spaces"]]
|
| 328 |
}
|
| 329 |
|
| 330 |
-
|
| 331 |
|
| 332 |
if space_name not in space_clients:
|
| 333 |
-
|
| 334 |
space_clients[space_name] = Client(space_info["url"], hf_token=HF_TOKEN)
|
| 335 |
|
| 336 |
client = space_clients[space_name]
|
| 337 |
|
| 338 |
-
|
| 339 |
context = client.predict(
|
| 340 |
message=message_text,
|
| 341 |
api_name=api_name
|
| 342 |
)
|
| 343 |
|
| 344 |
-
|
| 345 |
|
| 346 |
return {
|
| 347 |
"status": "success",
|
|
@@ -352,7 +352,7 @@ async def query_context(
|
|
| 352 |
}
|
| 353 |
|
| 354 |
except Exception as e:
|
| 355 |
-
|
| 356 |
return {
|
| 357 |
"status": "error",
|
| 358 |
"space": space_name,
|
|
|
|
| 320 |
space_info = next((s for s in spaces_metadata["spaces"] if s["name"] == space_name), None)
|
| 321 |
|
| 322 |
if not space_info:
|
| 323 |
+
print(f"Space no encontrado: {space_name}")
|
| 324 |
return {
|
| 325 |
"status": "error",
|
| 326 |
"message": f"Space '{space_name}' no encontrado",
|
| 327 |
"available_spaces": [s["name"] for s in spaces_metadata["spaces"]]
|
| 328 |
}
|
| 329 |
|
| 330 |
+
print(f"Obteniendo contexto del space: {space_name}")
|
| 331 |
|
| 332 |
if space_name not in space_clients:
|
| 333 |
+
print(f"Creando nuevo cliente para space: {space_name}")
|
| 334 |
space_clients[space_name] = Client(space_info["url"], hf_token=HF_TOKEN)
|
| 335 |
|
| 336 |
client = space_clients[space_name]
|
| 337 |
|
| 338 |
+
print(f"Enviando consulta para contexto a space {space_name}")
|
| 339 |
context = client.predict(
|
| 340 |
message=message_text,
|
| 341 |
api_name=api_name
|
| 342 |
)
|
| 343 |
|
| 344 |
+
print(f"Contexto obtenido (longitud: {len(context) if context else 0})")
|
| 345 |
|
| 346 |
return {
|
| 347 |
"status": "success",
|
|
|
|
| 352 |
}
|
| 353 |
|
| 354 |
except Exception as e:
|
| 355 |
+
print(f"Error en query_context: {str(e)}")
|
| 356 |
return {
|
| 357 |
"status": "error",
|
| 358 |
"space": space_name,
|