Skip to content

Commit 2b3bb75

Browse files
authored
Merge pull request #19 from Tencent/Branch_dev
bug fixed && add actions callback
2 parents b831832 + 75e828f commit 2b3bb75

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

javascript/state.core.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,17 @@ state.core = (function () {
659659
if(filename != ".flow"){
660660
// const handle = window.showDirectoryPicker();
661661
// console.log(handle)
662+
662663
state.utils.saveFile(filename, stored_config);
664+
665+
fetch('https://api.lightflow.ai/openapi/access?action=export')
666+
.then(response => response.json())
667+
.then(config => {
668+
console.log(config)
669+
}).catch(function(e) {
670+
console.log("Oops, export callback error!");
671+
});
672+
663673
}
664674

665675
}).catch(error => console.error('[state]: Error getting Flow file:', error));

javascript/state.utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ state.utils = {
5757
}
5858
if(downloadUrl == undefined){downloadUrl = data["files"][0]["downloadUrl"]}
5959
//} catch (error) {}
60+
}).catch(function(e) {
61+
console.log("search model error!");
6062
});
6163

6264
return downloadUrl

scripts/state_api.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,12 @@ def find_checkpoint_from_hash(hash:str):
134134

135135
def SearchingCheckPointByHashFromCivitai(hash:str):
136136
hash_str = hash.replace("[","").replace("]","").strip()
137-
response = requests.get("https://civitai.com/api/v1/model-versions/by-hash/"+hash_str)
138-
if(response.status_code == 200):
139-
print(response.content)
137+
try:
138+
response = requests.get("https://civitai.com/api/v1/model-versions/by-hash/"+hash_str)
139+
if(response.status_code == 200):
140+
print(response.content)
141+
except:
142+
pass
140143

141144
def set_lightdiffusionflow_file():
142145
global Preload_File
@@ -592,9 +595,18 @@ def fn_import_workflow(workflow_file):
592595
with open(config_file, mode='r', encoding='UTF-8') as f:
593596
workflow_json_str = f.read()
594597
workflow_json = json.loads(workflow_json_str)
598+
599+
try:
600+
response = requests.get("https://api.lightflow.ai/openapi/access?action=import")
601+
if(response.status_code == 200):
602+
pass
603+
except:
604+
pass
605+
595606
else:
596607
print("invalid file!")
597608

609+
598610
workflow_json = config_filter(workflow_json)
599611

600612
Webui_Comps_Cur_Val = []

0 commit comments

Comments
 (0)