Spaces:
Sleeping
Sleeping
Sulku Package Ready!
Browse files- flux_capacitor.py +10 -3
- sulkuPypi.py +45 -0
flux_capacitor.py
CHANGED
@@ -1,16 +1,22 @@
|
|
1 |
import theApp
|
2 |
import nodes
|
3 |
import sulkuGateway
|
|
|
4 |
import time
|
5 |
|
6 |
#Flux capacitor une la Autenticación y la App.
|
7 |
def do(access, content):
|
8 |
|
|
|
|
|
|
|
|
|
9 |
print("Entré a flux_capacitor.do...")
|
10 |
-
|
11 |
#AUTENTICACIÓN#
|
12 |
#Obten cantidad de tokens dispobibles vía Sulku para ese usuario.
|
13 |
-
resultado = sulkuGateway.getTokens(access)
|
|
|
14 |
|
15 |
#Un try para convertirlo en entero porque quizá bajo alguna circunstancia no sea un número lo que regresa y marcará error al aplicarle int().
|
16 |
try:
|
@@ -46,7 +52,8 @@ def do(access, content):
|
|
46 |
#CHARGE TOKENS
|
47 |
#Si se generó un resultado de AI entonces si hay que debitar el token correspondiente basado en la regla propia de la app.
|
48 |
if resultado != 0:
|
49 |
-
sulkuGateway.debitTokens(access, nodes.work)
|
|
|
50 |
else:
|
51 |
"No tokens will be charged because no outcome was produced."
|
52 |
|
|
|
1 |
import theApp
|
2 |
import nodes
|
3 |
import sulkuGateway
|
4 |
+
import sulkuPypi
|
5 |
import time
|
6 |
|
7 |
#Flux capacitor une la Autenticación y la App.
|
8 |
def do(access, content):
|
9 |
|
10 |
+
print("Esto es access: ", access)
|
11 |
+
print("Esto es content: ", content)
|
12 |
+
time.sleep(10)
|
13 |
+
|
14 |
print("Entré a flux_capacitor.do...")
|
15 |
+
|
16 |
#AUTENTICACIÓN#
|
17 |
#Obten cantidad de tokens dispobibles vía Sulku para ese usuario.
|
18 |
+
#resultado = sulkuGateway.getTokens(access)
|
19 |
+
resultado = sulkuPypi.getTokens(access)
|
20 |
|
21 |
#Un try para convertirlo en entero porque quizá bajo alguna circunstancia no sea un número lo que regresa y marcará error al aplicarle int().
|
22 |
try:
|
|
|
52 |
#CHARGE TOKENS
|
53 |
#Si se generó un resultado de AI entonces si hay que debitar el token correspondiente basado en la regla propia de la app.
|
54 |
if resultado != 0:
|
55 |
+
#sulkuGateway.debitTokens(access, nodes.work)
|
56 |
+
sulkuPypi.debitTokens(access, nodes.work)
|
57 |
else:
|
58 |
"No tokens will be charged because no outcome was produced."
|
59 |
|
sulkuPypi.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import time
|
3 |
+
|
4 |
+
base_url = "https://moibe-sulku-docker.hf.space/"
|
5 |
+
userfile = "gAAAAABmEZA4SLBC2YczouOrjIEi9WNCNGOIvyUcqBUnzxNsftXTdy54KaX9x8mAjFkABSI6FJrdZDQKk_5lpJOgJoMChxlniw=="
|
6 |
+
work = "picswap"
|
7 |
+
|
8 |
+
|
9 |
+
def getTokens(userfile):
|
10 |
+
|
11 |
+
api_url = base_url + "getTokens/" + userfile
|
12 |
+
|
13 |
+
response = requests.get(api_url)
|
14 |
+
|
15 |
+
if response.status_code == 200:
|
16 |
+
print("Conexión a Sulku successful...")
|
17 |
+
tokens = response.json()
|
18 |
+
print("Tokens:", tokens)
|
19 |
+
else:
|
20 |
+
print("Error al obtener el elemento todo:", response.status_code)
|
21 |
+
|
22 |
+
return tokens
|
23 |
+
|
24 |
+
def debitTokens(userfile, work):
|
25 |
+
|
26 |
+
api_url = base_url + "debitTokens" + "/" + userfile + "/" + work
|
27 |
+
|
28 |
+
print("Apiurl es: ", api_url)
|
29 |
+
time.sleep(8)
|
30 |
+
|
31 |
+
response = requests.get(api_url)
|
32 |
+
|
33 |
+
if response.status_code == 200:
|
34 |
+
print("Conexión a Sulku successful...")
|
35 |
+
tokens = response.json()
|
36 |
+
print("Tokens:", tokens)
|
37 |
+
else:
|
38 |
+
print("Error al obtener el elemento todo:", response.status_code)
|
39 |
+
|
40 |
+
return tokens
|
41 |
+
|
42 |
+
if __name__ == "__main__":
|
43 |
+
getTokens(userfile)
|
44 |
+
debitTokens(userfile, work)
|
45 |
+
pass
|