修改Ollama接口调用方式

在调用本地Ollama接口时,将api_key默认值设置为“ollama”。
This commit is contained in:
Karasukaigan
2025-02-19 14:42:37 +08:00
parent 0a24217eb5
commit fd7f97b0e8
3 changed files with 3 additions and 18 deletions
+3
View File
@@ -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,
-15
View File
@@ -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)
-3
View File
@@ -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,