diff --git a/llm_adapters.py b/llm_adapters.py index c771bb2..f919062 100644 --- a/llm_adapters.py +++ b/llm_adapters.py @@ -172,6 +172,9 @@ class OllamaAdapter(BaseLLMAdapter): self.temperature = temperature self.timeout = timeout + if self.api_key == '': + self.api_key= 'ollama' + self._client = ChatOpenAI( model=self.model_name, api_key=self.api_key, diff --git a/ui/generation_handlers.py b/ui/generation_handlers.py index 944fe3a..681e2e9 100644 --- a/ui/generation_handlers.py +++ b/ui/generation_handlers.py @@ -35,9 +35,6 @@ 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) @@ -83,9 +80,6 @@ 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, @@ -122,9 +116,6 @@ 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() @@ -255,9 +246,6 @@ 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() @@ -338,9 +326,6 @@ 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) diff --git a/ui/main_window.py b/ui/main_window.py index ca7f3e6..382223e 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -187,9 +187,6 @@ 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,