Spaces:
Sleeping
Sleeping
File size: 1,364 Bytes
0a435af b6140a0 0a435af cd82693 5ec27e5 b6140a0 a8c7886 b6140a0 f6efbe7 a8c7886 b6140a0 5d06394 b6140a0 |
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 |
import os
import time
import nodes
import requests
import gradio_client
def getTokens(sulkukey):
print("Entre a SulkuGateway...")
time.sleep(3)
#var_secreta = os.environ.get("huggingface_key")
var_secreta = os.environ.get("hf_write")
#print("Esto es var_secreta: ", var_secreta)
print("A punto de hacer llamado a cliente de API via Sulku...")
try:
#client = gradio_client.Client("Moibe/sulku", hf_token=var_secreta, verbose=True)
client = gradio_client.Client("Moibe/sulku", verbose=True)
print("ESTE ES EL CLIENTE:", client)
time.sleep(7)
resultado = client.predict(sulkukey, api_name="/getTokens")
return resultado
# except gradio_client.exceptions.APIError as e:
# print(f"Error 404 calling the API: {e}")
# return None
except requests.exceptions.RequestException as e:
print(f"Error 405: Network error, {e}")
return None
def debitTokens(sulkukey, work):
#client = gradio_client.Client(nodes.validator, nodes.hf_token, verbose=False)
client = gradio_client.Client("Moibe/sulku", verbose=True)
tokens = client.predict(
sulkukey,
work,
api_name="/debitTokens"
)
print(f"Available tokens now: {tokens}.")
time.sleep(1)
return tokens |