Update schat_client.py
Browse files- schat_client.py +13 -9
schat_client.py
CHANGED
|
@@ -7,18 +7,18 @@ import requests
|
|
| 7 |
import json
|
| 8 |
|
| 9 |
# Lazy initialization to avoid crash if Space is down at import time
|
| 10 |
-
|
| 11 |
|
| 12 |
|
| 13 |
-
def
|
| 14 |
"""Get or create the svision client (lazy initialization)."""
|
| 15 |
-
global
|
| 16 |
-
if
|
| 17 |
-
|
| 18 |
-
return
|
| 19 |
|
| 20 |
def get_from_prompt(prompt):
|
| 21 |
-
client =
|
| 22 |
|
| 23 |
result = client.predict(
|
| 24 |
prompt=prompt,
|
|
@@ -32,7 +32,9 @@ def resumir_frases_salamandra(frase, num_palabras):
|
|
| 32 |
"""
|
| 33 |
Llama al endpoint /resumir del Space remoto VeuReu/schat
|
| 34 |
"""
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
frase=frase,
|
| 37 |
num_palabras=num_palabras,
|
| 38 |
api_name="/resumir"
|
|
@@ -44,7 +46,9 @@ def identificar_personajes (frase, personas):
|
|
| 44 |
"""
|
| 45 |
Llama al endpoint /modificar del Space remoto VeuReu/schat
|
| 46 |
"""
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
frase=frase,
|
| 49 |
persona = personas,
|
| 50 |
api_name="/modificar"
|
|
|
|
| 7 |
import json
|
| 8 |
|
| 9 |
# Lazy initialization to avoid crash if Space is down at import time
|
| 10 |
+
_schat_client = None
|
| 11 |
|
| 12 |
|
| 13 |
+
def _get_schat_client():
|
| 14 |
"""Get or create the svision client (lazy initialization)."""
|
| 15 |
+
global _schat_client
|
| 16 |
+
if _schat_client is None:
|
| 17 |
+
_schat_client = Client("VeuReu/schat")
|
| 18 |
+
return _schat_client
|
| 19 |
|
| 20 |
def get_from_prompt(prompt):
|
| 21 |
+
client = _get_schat_client()
|
| 22 |
|
| 23 |
result = client.predict(
|
| 24 |
prompt=prompt,
|
|
|
|
| 32 |
"""
|
| 33 |
Llama al endpoint /resumir del Space remoto VeuReu/schat
|
| 34 |
"""
|
| 35 |
+
client = _get_schat_client()
|
| 36 |
+
|
| 37 |
+
result = client.predict(
|
| 38 |
frase=frase,
|
| 39 |
num_palabras=num_palabras,
|
| 40 |
api_name="/resumir"
|
|
|
|
| 46 |
"""
|
| 47 |
Llama al endpoint /modificar del Space remoto VeuReu/schat
|
| 48 |
"""
|
| 49 |
+
client = _get_schat_client()
|
| 50 |
+
|
| 51 |
+
result = client.predict(
|
| 52 |
frase=frase,
|
| 53 |
persona = personas,
|
| 54 |
api_name="/modificar"
|