Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- mods/btn_submit_vo_suggest.py +1 -7
- mods/btn_vo.py +4 -3
- mods/read_cfg.py +16 -3
mods/btn_submit_vo_suggest.py
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
def init(cfg):
|
2 |
# ========== 自定义组合建的功能 ==========
|
3 |
-
combine = [
|
4 |
-
'btn_submit_fn_usr',
|
5 |
-
'btn_rag_fn',
|
6 |
-
'btn_submit_fn_bot',
|
7 |
-
'btn_vo_fn',
|
8 |
-
'btn_suggest_fn'
|
9 |
-
]
|
10 |
tmp = cfg['btn_submit_vo_suggest'].click(**cfg['btn_start'])
|
11 |
for f in combine:
|
12 |
tmp = tmp.success(**cfg[f])
|
|
|
1 |
def init(cfg):
|
2 |
# ========== 自定义组合建的功能 ==========
|
3 |
+
combine = cfg['btn_submit_vo_suggest_combine']
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
tmp = cfg['btn_submit_vo_suggest'].click(**cfg['btn_start'])
|
5 |
for f in combine:
|
6 |
tmp = tmp.success(**cfg[f])
|
mods/btn_vo.py
CHANGED
@@ -19,9 +19,6 @@ def init(cfg):
|
|
19 |
if cfg['btn_stop_status']:
|
20 |
yield '', model.venv_info
|
21 |
return
|
22 |
-
# ========== 及时清理上一次生成的旁白 ==========
|
23 |
-
model.venv_remove('vo')
|
24 |
-
print('清理旁白', model.venv_info)
|
25 |
# ========== 模型输出旁白 ==========
|
26 |
model.venv_create('vo') # 创建隔离环境
|
27 |
_tmp = btn_com(_n_keep, _n_discard,
|
@@ -32,6 +29,10 @@ def init(cfg):
|
|
32 |
_mirostat_tau, '旁白', _max_tokens)
|
33 |
for _h in _tmp:
|
34 |
yield _h, model.venv_info
|
|
|
|
|
|
|
|
|
35 |
|
36 |
cfg['btn_vo_fn'] = {
|
37 |
'fn': btn_vo,
|
|
|
19 |
if cfg['btn_stop_status']:
|
20 |
yield '', model.venv_info
|
21 |
return
|
|
|
|
|
|
|
22 |
# ========== 模型输出旁白 ==========
|
23 |
model.venv_create('vo') # 创建隔离环境
|
24 |
_tmp = btn_com(_n_keep, _n_discard,
|
|
|
29 |
_mirostat_tau, '旁白', _max_tokens)
|
30 |
for _h in _tmp:
|
31 |
yield _h, model.venv_info
|
32 |
+
# ========== 及时清理上一次生成的旁白 ==========
|
33 |
+
model.venv_remove('vo', keep_last=True)
|
34 |
+
yield _h, model.venv_info
|
35 |
+
print('清理旁白', model.venv_info)
|
36 |
|
37 |
cfg['btn_vo_fn'] = {
|
38 |
'fn': btn_vo,
|
mods/read_cfg.py
CHANGED
@@ -1,5 +1,16 @@
|
|
1 |
import hashlib
|
2 |
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
|
5 |
# ========== 哈希函数 ==========
|
@@ -10,7 +21,9 @@ def x_hash(x: str):
|
|
10 |
# ========== 读取配置文件 ==========
|
11 |
with open('rp_config.json', encoding='utf-8') as f:
|
12 |
tmp = f.read()
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
cfg['setting_cache_path']['value'] += x_hash(tmp)
|
16 |
-
|
|
|
1 |
import hashlib
|
2 |
import json
|
3 |
+
import os
|
4 |
+
|
5 |
+
|
6 |
+
def get_all_files_in_directory(directory, ext=''):
|
7 |
+
all_files = []
|
8 |
+
for root, dirs, files in os.walk(directory):
|
9 |
+
for file in files:
|
10 |
+
if file.endswith(ext):
|
11 |
+
file_path = os.path.join(root, file)
|
12 |
+
all_files.append(file_path)
|
13 |
+
return all_files
|
14 |
|
15 |
|
16 |
# ========== 哈希函数 ==========
|
|
|
21 |
# ========== 读取配置文件 ==========
|
22 |
with open('rp_config.json', encoding='utf-8') as f:
|
23 |
tmp = f.read()
|
24 |
+
cfg = json.loads(tmp)
|
25 |
+
for path in get_all_files_in_directory('config', ext='.json'):
|
26 |
+
with open(path, encoding='utf-8') as f:
|
27 |
+
cfg.update(json.load(f))
|
28 |
cfg['setting_cache_path']['value'] += x_hash(tmp)
|
29 |
+
|