Dango233 commited on
Commit
7536943
·
unverified ·
2 Parent(s): 5075ade 40e83d7

Merge pull request #2 from Intelligent-Internet/CoT-Focused-Mode

Browse files
Files changed (2) hide show
  1. app.py +7 -9
  2. lang.py +3 -3
app.py CHANGED
@@ -20,9 +20,7 @@ class AppConfig:
20
  DEFAULT_THROUGHPUT = 10
21
  SYNC_THRESHOLD_DEFAULT = 0
22
  API_TIMEOUT = 20
23
- LOADING_DEFAULT = (
24
- "✅ Ready! <br> Think together with AI. Use Shift+Enter to toggle generation"
25
- )
26
 
27
 
28
  class DynamicState:
@@ -185,7 +183,7 @@ class ConvoState:
185
  )
186
  for chunk in response_stream:
187
  chunk_content = chunk.choices[0].delta.content
188
- if coordinator.should_pause_for_human(full_response):
189
  dynamic_state.should_stream = False
190
  if not dynamic_state.should_stream:
191
  break
@@ -211,7 +209,7 @@ class ConvoState:
211
  else lang_data["loading_output"]
212
  )
213
  editor_label = f"{lang_data['editor_label']} - {status}"
214
- yield full_response, gr.update(
215
  label=editor_label
216
  ), self.flatten_output()
217
 
@@ -219,7 +217,7 @@ class ConvoState:
219
  start_time = time.time()
220
  while (
221
  time.time() - start_time
222
- ) < interval and dynamic_state.should_stream:
223
  time.sleep(0.005)
224
 
225
  except Exception as e:
@@ -247,9 +245,9 @@ class ConvoState:
247
  )
248
  editor_label = f"{lang_data['editor_label']} - {final_status}"
249
  if not self.is_error:
250
- yield full_response, gr.update(label=editor_label), self.flatten_output()
251
  else:
252
- yield full_response, gr.update(label=editor_label_error), self.flatten_output() + [
253
  {
254
  "role": "assistant",
255
  "content": error_msg,
@@ -311,7 +309,7 @@ with gr.Blocks(theme=theme, css_paths="styles.css") as demo:
311
  bot_default = LANGUAGE_CONFIG["en"]["bot_default"] + [
312
  {
313
  "role": "assistant",
314
- "content": f"Running `{os.getenv('API_MODEL')}` @ {os.getenv('API_URL')} \n Proformance subjects to API provider situation",
315
  "metadata": {"title": f"API INFO"},
316
  }
317
  ]
 
20
  DEFAULT_THROUGHPUT = 10
21
  SYNC_THRESHOLD_DEFAULT = 0
22
  API_TIMEOUT = 20
23
+
 
 
24
 
25
 
26
  class DynamicState:
 
183
  )
184
  for chunk in response_stream:
185
  chunk_content = chunk.choices[0].delta.content
186
+ if coordinator.should_pause_for_human(full_response) and dynamic_state.in_cot:
187
  dynamic_state.should_stream = False
188
  if not dynamic_state.should_stream:
189
  break
 
209
  else lang_data["loading_output"]
210
  )
211
  editor_label = f"{lang_data['editor_label']} - {status}"
212
+ yield self.current["cot"] + ("</think>" if think_complete else ""), gr.update(
213
  label=editor_label
214
  ), self.flatten_output()
215
 
 
217
  start_time = time.time()
218
  while (
219
  time.time() - start_time
220
+ ) < interval and dynamic_state.should_stream and dynamic_state.in_cot:
221
  time.sleep(0.005)
222
 
223
  except Exception as e:
 
245
  )
246
  editor_label = f"{lang_data['editor_label']} - {final_status}"
247
  if not self.is_error:
248
+ yield self.current["cot"] + ("</think>" if not dynamic_state.in_cot else ""), gr.update(label=editor_label), self.flatten_output()
249
  else:
250
+ yield self.current["cot"] + ("</think>" if not dynamic_state.in_cot else ""), gr.update(label=editor_label_error), self.flatten_output() + [
251
  {
252
  "role": "assistant",
253
  "content": error_msg,
 
309
  bot_default = LANGUAGE_CONFIG["en"]["bot_default"] + [
310
  {
311
  "role": "assistant",
312
+ "content": f"Running `{os.getenv('API_MODEL')}` @ {os.getenv('API_URL')} \n Performance subjects to API provider situation",
313
  "metadata": {"title": f"API INFO"},
314
  }
315
  ]
lang.py CHANGED
@@ -14,7 +14,7 @@ LANGUAGE_CONFIG = {
14
  "throughput_info": "Tokens/s - 5:Learn, 10:Follow, 50:Skim",
15
  "language_label": "Language",
16
  "loading_thinking": "🤖 AI Thinking ↓ Shift+Enter to Pause",
17
- "loading_output": "🖨️ Result Writing Shift+Enter to Pause",
18
  "interrupted": "🤔 Pause, Human thinking time - **EDIT THOUGHTS BELOW**",
19
  "completed": "✅ Completed → Check overview",
20
  "error": "Error",
@@ -51,8 +51,8 @@ LANGUAGE_CONFIG = {
51
  "throughput_label": "⏱ 同步思考速度",
52
  "throughput_info": "词元/秒 - 5:学习, 10:跟读, 50:跳读",
53
  "language_label": "界面语言",
54
- "loading_thinking": "🤖 AI思考中... **Shift+Enter**可暂停",
55
- "loading_output": "🖨️ 结果输出中... **Shift+Enter**可暂停",
56
  "interrupted": "🤔 暂停,人类思考回合 **下面的思考过程可以编辑**",
57
  "completed": "✅ 已完成 → 查看完整对话",
58
  "error": "错误",
 
14
  "throughput_info": "Tokens/s - 5:Learn, 10:Follow, 50:Skim",
15
  "language_label": "Language",
16
  "loading_thinking": "🤖 AI Thinking ↓ Shift+Enter to Pause",
17
+ "loading_output": "🖨️ Result Writing (Pause & submit to reroll the result)",
18
  "interrupted": "🤔 Pause, Human thinking time - **EDIT THOUGHTS BELOW**",
19
  "completed": "✅ Completed → Check overview",
20
  "error": "Error",
 
51
  "throughput_label": "⏱ 同步思考速度",
52
  "throughput_info": "词元/秒 - 5:学习, 10:跟读, 50:跳读",
53
  "language_label": "界面语言",
54
+ "loading_thinking": "🤖 AI思考中 Shift+Enter可暂停",
55
+ "loading_output": "🖨️ 结果输出中 → (暂停再提交会重新生成结果部分)",
56
  "interrupted": "🤔 暂停,人类思考回合 **下面的思考过程可以编辑**",
57
  "completed": "✅ 已完成 → 查看完整对话",
58
  "error": "错误",