优化本地Ollama接口使用体验
用户在使用本地Ollama接口时无需再填写API Key,API Key字段可以留空。
This commit is contained in:
@@ -35,6 +35,9 @@ def generate_novel_architecture_ui(self):
|
||||
max_tokens = self.max_tokens_var.get()
|
||||
timeout_val = self.safe_get_int(self.timeout_var, 600)
|
||||
|
||||
if interface_format == 'Ollama' and api_key == '':
|
||||
api_key = 'ollama'
|
||||
|
||||
topic = self.topic_text.get("0.0", "end").strip()
|
||||
genre = self.genre_var.get().strip()
|
||||
num_chapters = self.safe_get_int(self.num_chapters_var, 10)
|
||||
@@ -80,6 +83,9 @@ def generate_chapter_blueprint_ui(self):
|
||||
max_tokens = self.max_tokens_var.get()
|
||||
timeout_val = self.safe_get_int(self.timeout_var, 600)
|
||||
|
||||
if interface_format == 'Ollama' and api_key == '':
|
||||
api_key = 'ollama'
|
||||
|
||||
self.safe_log("开始生成章节蓝图...")
|
||||
Chapter_blueprint_generate(
|
||||
interface_format=interface_format,
|
||||
@@ -116,6 +122,9 @@ def generate_chapter_draft_ui(self):
|
||||
max_tokens = self.max_tokens_var.get()
|
||||
timeout_val = self.safe_get_int(self.timeout_var, 600)
|
||||
|
||||
if interface_format == 'Ollama' and api_key == '':
|
||||
api_key = 'ollama'
|
||||
|
||||
chap_num = self.safe_get_int(self.chapter_num_var, 1)
|
||||
word_number = self.safe_get_int(self.word_number_var, 3000)
|
||||
user_guidance = self.user_guide_text.get("0.0", "end").strip()
|
||||
@@ -246,6 +255,9 @@ def finalize_chapter_ui(self):
|
||||
max_tokens = self.max_tokens_var.get()
|
||||
timeout_val = self.safe_get_int(self.timeout_var, 600)
|
||||
|
||||
if interface_format == 'Ollama' and api_key == '':
|
||||
api_key = 'ollama'
|
||||
|
||||
embedding_api_key = self.embedding_api_key_var.get().strip()
|
||||
embedding_url = self.embedding_url_var.get().strip()
|
||||
embedding_interface_format = self.embedding_interface_format_var.get().strip()
|
||||
@@ -326,6 +338,9 @@ def do_consistency_check(self):
|
||||
max_tokens = self.max_tokens_var.get()
|
||||
timeout = self.timeout_var.get()
|
||||
|
||||
if interface_format == 'Ollama' and api_key == '':
|
||||
api_key = 'ollama'
|
||||
|
||||
chap_num = self.safe_get_int(self.chapter_num_var, 1)
|
||||
chap_file = os.path.join(filepath, "chapters", f"chapter_{chap_num}.txt")
|
||||
chapter_text = read_file(chap_file)
|
||||
|
||||
@@ -187,6 +187,9 @@ class NovelGeneratorGUI:
|
||||
max_tokens = self.max_tokens_var.get()
|
||||
timeout = self.timeout_var.get()
|
||||
|
||||
if interface_format == 'Ollama' and api_key == '':
|
||||
api_key = 'ollama'
|
||||
|
||||
test_llm_config(
|
||||
interface_format=interface_format,
|
||||
api_key=api_key,
|
||||
|
||||
Reference in New Issue
Block a user