|
|
import os |
|
|
os.environ["CUDA_VISIBLE_DEVICES"] = "1" |
|
|
|
|
|
from gradio_client import Client, handle_file |
|
|
from typing import Any, Dict, List, Optional, Tuple, Union |
|
|
import requests |
|
|
import json |
|
|
|
|
|
|
|
|
_schat_client = None |
|
|
|
|
|
|
|
|
def _get_schat_client(): |
|
|
"""Get or create the svision client (lazy initialization).""" |
|
|
global _schat_client |
|
|
if _schat_client is None: |
|
|
_schat_client = Client("VeuReu/schat") |
|
|
return _schat_client |
|
|
|
|
|
def get_from_prompt(prompt): |
|
|
client = _get_schat_client() |
|
|
|
|
|
result = client.predict( |
|
|
prompt=prompt, |
|
|
api_name="/generate_out_from_prompt" |
|
|
) |
|
|
|
|
|
return result |
|
|
|
|
|
|
|
|
def resumir_frases_salamandra(frase, num_palabras): |
|
|
""" |
|
|
Llama al endpoint /resumir del Space remoto VeuReu/schat |
|
|
""" |
|
|
client = _get_schat_client() |
|
|
|
|
|
result = client.predict( |
|
|
frase=frase, |
|
|
num_palabras=num_palabras, |
|
|
api_name="/resumir" |
|
|
) |
|
|
|
|
|
return result |
|
|
|
|
|
def identificar_personajes (frase, personas): |
|
|
""" |
|
|
Llama al endpoint /modificar del Space remoto VeuReu/schat |
|
|
""" |
|
|
client = _get_schat_client() |
|
|
|
|
|
result = client.predict( |
|
|
frase=frase, |
|
|
persona = personas, |
|
|
api_name="/modificar" |
|
|
) |
|
|
return result |
|
|
|
|
|
def free_narration_schat(texto): |
|
|
""" |
|
|
Llama al endpoint /narraci贸 del Space remoto VeuReu/schat |
|
|
""" |
|
|
client = _get_schat_client() |
|
|
|
|
|
result = client.predict( |
|
|
srt_final=texto, |
|
|
api_name="/narraci贸" |
|
|
) |
|
|
return result |