File size: 1,535 Bytes
5a08dcb
 
 
 
 
 
 
 
 
cc94ee2
5a08dcb
 
cc94ee2
5a08dcb
cc94ee2
 
 
 
5a08dcb
 
cc94ee2
5a08dcb
 
 
 
 
 
f023d4b
 
 
 
 
 
 
cc94ee2
 
 
f023d4b
 
 
 
 
 
 
 
 
 
 
cc94ee2
 
 
f023d4b
 
 
 
4fcfe12
 
 
 
 
 
 
 
 
 
 
 
5a08dcb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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

# Lazy initialization to avoid crash if Space is down at import time
_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