Add files via upload
增加代理设置选项; 优化新版本google-generativeai 不支持 Client 类问题; 优化批量生成章节界面,使用customtkinter统一设计风格;
This commit is contained in:
+91
-8
@@ -8,14 +8,97 @@ from embedding_adapters import create_embedding_adapter
|
||||
|
||||
|
||||
def load_config(config_file: str) -> dict:
|
||||
"""从指定的 config_file 加载配置,若不存在则返回空字典。"""
|
||||
if os.path.exists(config_file):
|
||||
try:
|
||||
with open(config_file, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
except:
|
||||
pass
|
||||
return {}
|
||||
"""从指定的 config_file 加载配置,若不存在则创建一个默认配置文件。"""
|
||||
|
||||
# PenBo 修改代码,增加配置文件不存在则创建一个默认配置文件
|
||||
if not os.path.exists(config_file):
|
||||
create_config(config_file)
|
||||
|
||||
try:
|
||||
with open(config_file, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
except:
|
||||
return {}
|
||||
|
||||
|
||||
# PenBo 增加了创建默认配置文件函数
|
||||
def create_config(config_file: str) -> dict:
|
||||
"""创建一个创建默认配置文件。"""
|
||||
config = {
|
||||
"last_interface_format": "OpenAI",
|
||||
"last_embedding_interface_format": "OpenAI",
|
||||
"llm_configs": {
|
||||
"DeepSeek V3": {
|
||||
"api_key": "",
|
||||
"base_url": "https://api.deepseek.com/v1",
|
||||
"model_name": "deepseek-chat",
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 8192,
|
||||
"timeout": 600,
|
||||
"interface_format": "OpenAI"
|
||||
},
|
||||
"GPT 5": {
|
||||
"api_key": "",
|
||||
"base_url": "https://api.openai.com/v1",
|
||||
"model_name": "gpt-5",
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 32768,
|
||||
"timeout": 600,
|
||||
"interface_format": "OpenAI"
|
||||
},
|
||||
"Gemini 2.5 Pro": {
|
||||
"api_key": "",
|
||||
"base_url": "https://generativelanguage.googleapis.com/v1beta/openai",
|
||||
"model_name": "gemini-2.5-pro",
|
||||
"temperature": 0.7,
|
||||
"max_tokens": 32768,
|
||||
"timeout": 600,
|
||||
"interface_format": "OpenAI"
|
||||
}
|
||||
},
|
||||
"embedding_configs": {
|
||||
"OpenAI": {
|
||||
"api_key": "",
|
||||
"base_url": "https://api.openai.com/v1",
|
||||
"model_name": "text-embedding-ada-002",
|
||||
"retrieval_k": 4,
|
||||
"interface_format": "OpenAI"
|
||||
}
|
||||
},
|
||||
"other_params": {
|
||||
"topic": "",
|
||||
"genre": "",
|
||||
"num_chapters": 0,
|
||||
"word_number": 0,
|
||||
"filepath": "",
|
||||
"chapter_num": "120",
|
||||
"user_guidance": "",
|
||||
"characters_involved": "",
|
||||
"key_items": "",
|
||||
"scene_location": "",
|
||||
"time_constraint": ""
|
||||
},
|
||||
"choose_configs": {
|
||||
"prompt_draft_llm": "DeepSeek V3",
|
||||
"chapter_outline_llm": "DeepSeek V3",
|
||||
"architecture_llm": "Gemini 2.5 Pro",
|
||||
"final_chapter_llm": "GPT 5",
|
||||
"consistency_review_llm": "DeepSeek V3"
|
||||
},
|
||||
"proxy_setting": {
|
||||
"proxy_url": "127.0.0.1",
|
||||
"proxy_port": "",
|
||||
"enabled": false
|
||||
},
|
||||
"webdav_config": {
|
||||
"webdav_url": "",
|
||||
"webdav_username": "",
|
||||
"webdav_password": ""
|
||||
}
|
||||
}
|
||||
save_config(config, config_file)
|
||||
|
||||
|
||||
|
||||
def save_config(config_data: dict, config_file: str) -> bool:
|
||||
"""将 config_data 保存到 config_file 中,返回 True/False 表示是否成功。"""
|
||||
|
||||
Reference in New Issue
Block a user