Limour commited on
Commit
8f18205
1 Parent(s): 026cf13

Upload 5 files

Browse files
mods/btn_com.py CHANGED
@@ -11,6 +11,7 @@ def init(cfg):
11
  cfg['btn_stop'] = gr.Button("Stop")
12
  cfg['btn_reset'] = gr.Button("Reset")
13
  cfg['btn_debug'] = gr.Button("Debug")
 
14
  cfg['btn_submit'] = gr.Button("Submit")
15
  cfg['btn_suggest'] = gr.Button("建议")
16
 
@@ -87,8 +88,13 @@ def init(cfg):
87
 
88
  cfg['btn_com'] = btn_com
89
 
 
 
 
 
90
  def btn_start_or_finish(finish):
91
  tmp = gr.update(interactive=finish)
 
92
 
93
  def _inner():
94
  with lock:
@@ -96,13 +102,10 @@ def init(cfg):
96
  raise RuntimeError('任务中断!请稍等或Reset,如已Reset,请忽略。')
97
  cfg['session_active'] = not cfg['session_active']
98
  cfg['btn_stop_status'] = finish
99
- return tmp, tmp, tmp, tmp
100
 
101
  return _inner
102
 
103
- btn_start_or_finish_outputs = [cfg['btn_submit'], cfg['btn_vo'],
104
- cfg['btn_suggest'], cfg['btn_retry']]
105
-
106
  cfg['btn_concurrency'] = {
107
  'trigger_mode': 'once',
108
  'concurrency_id': 'btn_com',
@@ -113,13 +116,12 @@ def init(cfg):
113
  'fn': btn_start_or_finish(False),
114
  'outputs': btn_start_or_finish_outputs
115
  }
 
116
 
117
  cfg['btn_finish'] = {
118
  'fn': btn_start_or_finish(True),
119
  'outputs': btn_start_or_finish_outputs
120
  }
121
-
122
- cfg['btn_start'].update(cfg['btn_concurrency'])
123
  cfg['btn_finish'].update(cfg['btn_concurrency'])
124
 
125
  cfg['setting'] = [cfg[x] for x in ('setting_n_keep', 'setting_n_discard',
 
11
  cfg['btn_stop'] = gr.Button("Stop")
12
  cfg['btn_reset'] = gr.Button("Reset")
13
  cfg['btn_debug'] = gr.Button("Debug")
14
+ cfg['btn_submit_vo_suggest'] = gr.Button("Submit&旁白&建议", variant="primary")
15
  cfg['btn_submit'] = gr.Button("Submit")
16
  cfg['btn_suggest'] = gr.Button("建议")
17
 
 
88
 
89
  cfg['btn_com'] = btn_com
90
 
91
+ btn_start_or_finish_outputs = [cfg['btn_submit'], cfg['btn_vo'],
92
+ cfg['btn_suggest'], cfg['btn_retry'],
93
+ cfg['btn_submit_vo_suggest']]
94
+
95
  def btn_start_or_finish(finish):
96
  tmp = gr.update(interactive=finish)
97
+ tmp = (tmp,) * len(btn_start_or_finish_outputs)
98
 
99
  def _inner():
100
  with lock:
 
102
  raise RuntimeError('任务中断!请稍等或Reset,如已Reset,请忽略。')
103
  cfg['session_active'] = not cfg['session_active']
104
  cfg['btn_stop_status'] = finish
105
+ return tmp
106
 
107
  return _inner
108
 
 
 
 
109
  cfg['btn_concurrency'] = {
110
  'trigger_mode': 'once',
111
  'concurrency_id': 'btn_com',
 
116
  'fn': btn_start_or_finish(False),
117
  'outputs': btn_start_or_finish_outputs
118
  }
119
+ cfg['btn_start'].update(cfg['btn_concurrency'])
120
 
121
  cfg['btn_finish'] = {
122
  'fn': btn_start_or_finish(True),
123
  'outputs': btn_start_or_finish_outputs
124
  }
 
 
125
  cfg['btn_finish'].update(cfg['btn_concurrency'])
126
 
127
  cfg['setting'] = [cfg[x] for x in ('setting_n_keep', 'setting_n_discard',
mods/btn_submit.py CHANGED
@@ -61,18 +61,26 @@ def init(cfg):
61
  model.venv_remove('rag') # 销毁对应的 venv
62
  yield history, model.venv_info
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  cfg['btn_submit'].click(
65
  **cfg['btn_start']
66
  ).success(
67
- fn=btn_submit_usr, api_name="submit",
68
- inputs=[msg, chatbot],
69
- outputs=[msg, chatbot],
70
- **cfg['btn_concurrency']
71
  ).success(
72
- fn=btn_submit_bot,
73
- inputs=[chatbot]+cfg['setting'],
74
- outputs=[chatbot, s_info],
75
- **cfg['btn_concurrency']
76
  ).success(
77
  **cfg['btn_finish']
78
  )
 
61
  model.venv_remove('rag') # 销毁对应的 venv
62
  yield history, model.venv_info
63
 
64
+ cfg['btn_submit_fn_usr'] = {
65
+ 'fn': btn_submit_usr,
66
+ 'inputs': [msg, chatbot],
67
+ 'outputs': [msg, chatbot]
68
+ }
69
+ cfg['btn_submit_fn_usr'].update(cfg['btn_concurrency'])
70
+
71
+ cfg['btn_submit_fn_bot'] = {
72
+ 'fn': btn_submit_bot,
73
+ 'inputs': [chatbot]+cfg['setting'],
74
+ 'outputs': [chatbot, s_info],
75
+ }
76
+ cfg['btn_submit_fn_bot'].update(cfg['btn_concurrency'])
77
+
78
  cfg['btn_submit'].click(
79
  **cfg['btn_start']
80
  ).success(
81
+ **cfg['btn_submit_fn_usr']
 
 
 
82
  ).success(
83
+ **cfg['btn_submit_fn_bot']
 
 
 
84
  ).success(
85
  **cfg['btn_finish']
86
  )
mods/btn_submit_vo_suggest.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def init(cfg):
2
+ cfg['btn_submit_vo_suggest'].click(
3
+ **cfg['btn_start']
4
+ ).success(
5
+ **cfg['btn_submit_fn_usr']
6
+ ).success(
7
+ **cfg['btn_submit_fn_bot']
8
+ ).success(
9
+ **cfg['btn_vo_fn']
10
+ ).success(
11
+ **cfg['btn_suggest_fn']
12
+ ).success(
13
+ **cfg['btn_finish']
14
+ )
mods/btn_suggest.py CHANGED
@@ -30,13 +30,17 @@ def init(cfg):
30
  model.venv_remove('suggest') # 销毁隔离环境
31
  yield _h, model.venv_info
32
 
 
 
 
 
 
 
 
33
  cfg['btn_suggest'].click(
34
  **cfg['btn_start']
35
  ).success(
36
- fn=btn_suggest,
37
- inputs=cfg['setting'],
38
- outputs=[cfg['msg'], s_info],
39
- **cfg['btn_concurrency']
40
  ).success(
41
  **cfg['btn_finish']
42
  )
 
30
  model.venv_remove('suggest') # 销毁隔离环境
31
  yield _h, model.venv_info
32
 
33
+ cfg['btn_suggest_fn'] = {
34
+ 'fn': btn_suggest,
35
+ 'inputs': cfg['setting'],
36
+ 'outputs': [cfg['msg'], s_info]
37
+ }
38
+ cfg['btn_suggest_fn'].update(cfg['btn_concurrency'])
39
+
40
  cfg['btn_suggest'].click(
41
  **cfg['btn_start']
42
  ).success(
43
+ **cfg['btn_suggest_fn']
 
 
 
44
  ).success(
45
  **cfg['btn_finish']
46
  )
mods/btn_vo.py CHANGED
@@ -30,13 +30,17 @@ def init(cfg):
30
  for _h in _tmp:
31
  yield _h, model.venv_info
32
 
 
 
 
 
 
 
 
33
  cfg['btn_vo'].click(
34
  **cfg['btn_start']
35
  ).success(
36
- fn=btn_vo,
37
- inputs=cfg['setting'],
38
- outputs=[cfg['vo'], s_info],
39
- **cfg['btn_concurrency']
40
  ).success(
41
  **cfg['btn_finish']
42
  )
 
30
  for _h in _tmp:
31
  yield _h, model.venv_info
32
 
33
+ cfg['btn_vo_fn'] = {
34
+ 'fn': btn_vo,
35
+ 'inputs': cfg['setting'],
36
+ 'outputs': [cfg['vo'], s_info]
37
+ }
38
+ cfg['btn_vo_fn'].update(cfg['btn_concurrency'])
39
+
40
  cfg['btn_vo'].click(
41
  **cfg['btn_start']
42
  ).success(
43
+ **cfg['btn_vo_fn']
 
 
 
44
  ).success(
45
  **cfg['btn_finish']
46
  )