Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import crypt
|
3 |
import os
|
4 |
rec_list = []
|
5 |
pa=os.environ['PASS']
|
6 |
|
|
|
7 |
|
8 |
|
9 |
def checkp(inp):
|
@@ -31,7 +33,10 @@ with gr.Blocks() as app:
|
|
31 |
rec=gr.Dropdown(label="Recipient", choices=[f for f in rec_list], allow_custom_value=True)
|
32 |
send_mes=gr.Textbox(label="Message", lines=6)
|
33 |
send_mes_btn=gr.Button()
|
34 |
-
|
|
|
|
|
|
|
35 |
|
36 |
|
37 |
|
@@ -61,12 +66,39 @@ with gr.Blocks() as app:
|
|
61 |
gr.Column()
|
62 |
def test_fn(im):
|
63 |
return (im)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
|
|
65 |
input_key.change(crypt.address,input_key,sender)
|
66 |
|
67 |
pass_btn.click(checkp,pass_box,[invalid,valida])
|
68 |
|
69 |
-
gen_wal_btn.click(crypt.generate_keys,None,[out2,out1,img3,out3,img1,img2]).then(test_fn,[img1],[input_key])
|
70 |
rsa_enc_btn.click(crypt.encrypt_text,[rsa_to_enc,pub_key_in,priv_key_in1,out3],[rsa_enc_mes,qr_enc_mes])
|
71 |
rsa_dec_btn.click(crypt.decrypt_text,[mes_in,priv_key_in],rsa_dec_mes)
|
72 |
|
|
|
1 |
import gradio as gr
|
2 |
+
import chatchain
|
3 |
import crypt
|
4 |
import os
|
5 |
rec_list = []
|
6 |
pa=os.environ['PASS']
|
7 |
|
8 |
+
main_chain='https://huggingface.co/datasets/Omnibus/chat-at/raw/main/chat/'
|
9 |
|
10 |
|
11 |
def checkp(inp):
|
|
|
33 |
rec=gr.Dropdown(label="Recipient", choices=[f for f in rec_list], allow_custom_value=True)
|
34 |
send_mes=gr.Textbox(label="Message", lines=6)
|
35 |
send_mes_btn=gr.Button()
|
36 |
+
with gr.Column():
|
37 |
+
block_text = gr.Textbox(label = "System", interactive = False)
|
38 |
+
response_json=gr.JSON()
|
39 |
+
rec_mes = gr.Textbox(lines=6)
|
40 |
|
41 |
|
42 |
|
|
|
66 |
gr.Column()
|
67 |
def test_fn(im):
|
68 |
return (im)
|
69 |
+
|
70 |
+
|
71 |
+
def update_rec_list():
|
72 |
+
f_ist = (api.list_repo_files(repo_id=f'{repo}/{name}', repo_type="dataset"))
|
73 |
+
rec_list =[]
|
74 |
+
for i,ea in enumerate(f_ist):
|
75 |
+
if "balance/" in ea:
|
76 |
+
try:
|
77 |
+
if not "__Source__" in ea:
|
78 |
+
rec_list.append(ea.split("/",1)[1].split(".",1)[0])
|
79 |
+
except Exception:
|
80 |
+
pass
|
81 |
+
return rec_list, gr.Dropdown.update(label="Recipient", choices=[f for f in rec_list])
|
82 |
+
rec_list, rec_drop = update_rec_list()
|
83 |
+
|
84 |
+
|
85 |
+
|
86 |
+
def create_new_chain(address):
|
87 |
+
address = str(address.strip("b").strip("'"))
|
88 |
+
mychain_rec = chatchain.MyChainRec(chain_load=main_chain,create=address)
|
89 |
+
response = {'chain': mychain_rec.chain,
|
90 |
+
'length': len(mychain_rec.chain)}
|
91 |
+
|
92 |
+
message = f"Blockchain loaded from: {main_chain}{address}.json"
|
93 |
+
#send_list,send_drop = update_send_list()
|
94 |
+
rec_list, rec_drop = update_rec_list()
|
95 |
|
96 |
+
return response,message,rec_drop
|
97 |
input_key.change(crypt.address,input_key,sender)
|
98 |
|
99 |
pass_btn.click(checkp,pass_box,[invalid,valida])
|
100 |
|
101 |
+
gen_wal_btn.click(crypt.generate_keys,None,[out2,out1,img3,out3,img1,img2]).then(create_new_chain,out1,[response_json,block_text,rec]).then(test_fn,[img1],[input_key])
|
102 |
rsa_enc_btn.click(crypt.encrypt_text,[rsa_to_enc,pub_key_in,priv_key_in1,out3],[rsa_enc_mes,qr_enc_mes])
|
103 |
rsa_dec_btn.click(crypt.decrypt_text,[mes_in,priv_key_in],rsa_dec_mes)
|
104 |
|