Spaces:
Runtime error
Runtime error
Update chatchain.py
Browse files- chatchain.py +15 -0
chatchain.py
CHANGED
@@ -9,6 +9,21 @@ api = HfApi(token=token_self)
|
|
9 |
chain_d="chain1.json"
|
10 |
chain_t="trans1.json"
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def update_rec_list(main_chain):
|
13 |
repo = main_chain.split('datasets/',1)[1].split('/raw',1)[0].split('/',1)[0]
|
14 |
name = main_chain.split('datasets/',1)[1].split('/raw',1)[0].split('/',1)[1]
|
|
|
9 |
chain_d="chain1.json"
|
10 |
chain_t="trans1.json"
|
11 |
|
12 |
+
|
13 |
+
def store_image(img,chain_load):
|
14 |
+
main_chain_im=chain_load
|
15 |
+
chain_r=f"{main_chain_im.split('datasets/',1)[1].split('/raw',1)[0]}"
|
16 |
+
try:
|
17 |
+
api.upload_file(
|
18 |
+
path_or_fileobj=img,
|
19 |
+
path_in_repo="key.png",
|
20 |
+
repo_id=chain_r,
|
21 |
+
token=token_self,
|
22 |
+
repo_type="dataset",
|
23 |
+
)
|
24 |
+
os.remove("tmp_send.json")
|
25 |
+
except Exception as e:
|
26 |
+
print (f'Error storing image: {e}')
|
27 |
def update_rec_list(main_chain):
|
28 |
repo = main_chain.split('datasets/',1)[1].split('/raw',1)[0].split('/',1)[0]
|
29 |
name = main_chain.split('datasets/',1)[1].split('/raw',1)[0].split('/',1)[1]
|