修复超时传参问题
This commit is contained in:
+6
-5
@@ -137,18 +137,19 @@ def create_llm_adapter(
|
|||||||
model_name: str,
|
model_name: str,
|
||||||
api_key: str,
|
api_key: str,
|
||||||
temperature: float,
|
temperature: float,
|
||||||
max_tokens: int
|
max_tokens: int,
|
||||||
|
timeout: int
|
||||||
) -> BaseLLMAdapter:
|
) -> BaseLLMAdapter:
|
||||||
"""
|
"""
|
||||||
工厂函数:根据 interface_format 返回不同的适配器实例。
|
工厂函数:根据 interface_format 返回不同的适配器实例。
|
||||||
"""
|
"""
|
||||||
if interface_format.lower() == "deepseek":
|
if interface_format.lower() == "deepseek":
|
||||||
return DeepSeekAdapter(api_key, base_url, model_name, max_tokens, temperature)
|
return DeepSeekAdapter(api_key, base_url, model_name, max_tokens, temperature, timeout)
|
||||||
elif interface_format.lower() == "openai":
|
elif interface_format.lower() == "openai":
|
||||||
return OpenAIAdapter(api_key, base_url, model_name, max_tokens, temperature)
|
return OpenAIAdapter(api_key, base_url, model_name, max_tokens, temperature, timeout)
|
||||||
elif interface_format.lower() == "ollama":
|
elif interface_format.lower() == "ollama":
|
||||||
return OllamaAdapter(api_key, base_url, model_name, max_tokens, temperature)
|
return OllamaAdapter(api_key, base_url, model_name, max_tokens, temperature, timeout)
|
||||||
elif interface_format.lower() == "ml studio":
|
elif interface_format.lower() == "ml studio":
|
||||||
return MLStudioAdapter(api_key, base_url, model_name, max_tokens, temperature)
|
return MLStudioAdapter(api_key, base_url, model_name, max_tokens, temperature, timeout)
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unknown interface_format: {interface_format}")
|
raise ValueError(f"Unknown interface_format: {interface_format}")
|
||||||
|
|||||||
+9
-5
@@ -467,7 +467,8 @@ def Novel_architecture_generate(
|
|||||||
word_number: int,
|
word_number: int,
|
||||||
filepath: str,
|
filepath: str,
|
||||||
temperature: float = 0.7,
|
temperature: float = 0.7,
|
||||||
max_tokens: int = 2048
|
max_tokens: int = 2048,
|
||||||
|
timeout: int = 600
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
依次调用:
|
依次调用:
|
||||||
@@ -491,7 +492,8 @@ def Novel_architecture_generate(
|
|||||||
model_name=llm_model,
|
model_name=llm_model,
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
temperature=temperature,
|
temperature=temperature,
|
||||||
max_tokens=max_tokens
|
max_tokens=max_tokens,
|
||||||
|
timeout=timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
# Step1: 核心种子
|
# Step1: 核心种子
|
||||||
@@ -895,7 +897,7 @@ def finalize_chapter(
|
|||||||
|
|
||||||
# 如果内容过短,则尝试扩写
|
# 如果内容过短,则尝试扩写
|
||||||
if len(chapter_text) < 0.7 * word_number:
|
if len(chapter_text) < 0.7 * word_number:
|
||||||
chapter_text = enrich_chapter_text(chapter_text, word_number, api_key, base_url, model_name, temperature, interface_format, max_tokens)
|
chapter_text = enrich_chapter_text(chapter_text, word_number, api_key, base_url, model_name, temperature, interface_format, max_tokens, timeout)
|
||||||
clear_file_content(chapter_file)
|
clear_file_content(chapter_file)
|
||||||
save_string_to_txt(chapter_text, chapter_file)
|
save_string_to_txt(chapter_text, chapter_file)
|
||||||
|
|
||||||
@@ -959,7 +961,8 @@ def enrich_chapter_text(
|
|||||||
model_name: str,
|
model_name: str,
|
||||||
temperature: float,
|
temperature: float,
|
||||||
interface_format: str,
|
interface_format: str,
|
||||||
max_tokens: int
|
max_tokens: int,
|
||||||
|
timeout: int=600
|
||||||
) -> str:
|
) -> str:
|
||||||
llm_adapter = create_llm_adapter(
|
llm_adapter = create_llm_adapter(
|
||||||
interface_format=interface_format,
|
interface_format=interface_format,
|
||||||
@@ -967,7 +970,8 @@ def enrich_chapter_text(
|
|||||||
model_name=model_name,
|
model_name=model_name,
|
||||||
api_key=api_key,
|
api_key=api_key,
|
||||||
temperature=temperature,
|
temperature=temperature,
|
||||||
max_tokens=max_tokens
|
max_tokens=max_tokens,
|
||||||
|
timeout=timeout
|
||||||
)
|
)
|
||||||
prompt = f"""以下章节文本较短,请在保持剧情连贯的前提下进行扩写,使其更充实,接近 {word_number} 字左右:
|
prompt = f"""以下章节文本较短,请在保持剧情连贯的前提下进行扩写,使其更充实,接近 {word_number} 字左右:
|
||||||
原内容:
|
原内容:
|
||||||
|
|||||||
Reference in New Issue
Block a user