3v324v23 commited on
Commit
095385f
1 Parent(s): adb49f3

强调完整翻译

Browse files
crazy_functions/批量翻译PDF文档_多线程.py CHANGED
@@ -59,7 +59,7 @@ def 批量翻译PDF文档(txt, llm_kwargs, plugin_kwargs, chatbot, history, sys_
59
  def 解析PDF(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, sys_prompt):
60
  import os
61
  import tiktoken
62
- TOKEN_LIMIT_PER_FRAGMENT = 1600
63
  generated_conclusion_files = []
64
  for index, fp in enumerate(file_manifest):
65
 
@@ -91,13 +91,13 @@ def 解析PDF(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot,
91
  # 多线,翻译
92
  gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
93
  inputs_array=[
94
- f"以下是你需要翻译的论文片段:\n{frag}" for frag in paper_fragments],
95
  inputs_show_user_array=[f"\n---\n 原文: \n\n {frag.replace('#', '')} \n---\n 翻译:\n " for frag in paper_fragments],
96
  llm_kwargs=llm_kwargs,
97
  chatbot=chatbot,
98
  history_array=[[paper_meta] for _ in paper_fragments],
99
  sys_prompt_array=[
100
- "请你作为一个学术翻译,负责把学术论文的片段准确翻译成中文。" for _ in paper_fragments],
101
  # max_workers=5 # OpenAI所允许的最大并行过载
102
  )
103
 
 
59
  def 解析PDF(file_manifest, project_folder, llm_kwargs, plugin_kwargs, chatbot, history, sys_prompt):
60
  import os
61
  import tiktoken
62
+ TOKEN_LIMIT_PER_FRAGMENT = 1280
63
  generated_conclusion_files = []
64
  for index, fp in enumerate(file_manifest):
65
 
 
91
  # 多线,翻译
92
  gpt_response_collection = yield from request_gpt_model_multi_threads_with_very_awesome_ui_and_high_efficiency(
93
  inputs_array=[
94
+ f"你需要翻译以下内容:\n{frag}" for frag in paper_fragments],
95
  inputs_show_user_array=[f"\n---\n 原文: \n\n {frag.replace('#', '')} \n---\n 翻译:\n " for frag in paper_fragments],
96
  llm_kwargs=llm_kwargs,
97
  chatbot=chatbot,
98
  history_array=[[paper_meta] for _ in paper_fragments],
99
  sys_prompt_array=[
100
+ "请你作为一个学术翻译,负责把学术论文准确翻译成中文。注意文章中的每一句话都要翻译。" for _ in paper_fragments],
101
  # max_workers=5 # OpenAI所允许的最大并行过载
102
  )
103