diff --git a/src/STranslate/ViewModels/Preference/Translator/TranslatorAzureOpenAI.cs b/src/STranslate/ViewModels/Preference/Translator/TranslatorAzureOpenAI.cs index 98dab363..f5bd9395 100644 --- a/src/STranslate/ViewModels/Preference/Translator/TranslatorAzureOpenAI.cs +++ b/src/STranslate/ViewModels/Preference/Translator/TranslatorAzureOpenAI.cs @@ -354,8 +354,7 @@ public async Task TranslateAsync(object request, Action onDataReceived, a_model = string.IsNullOrEmpty(a_model) ? "gpt35" : a_model; var path = $"/openai/deployments/{a_model}/chat/completions"; - // 如果路径为空或者不是有效的API路径结尾,使用默认路径 - if (!uriBuilder.Path.EndsWith(path) && uriBuilder.Path == "/") + if (uriBuilder.Path == "/") uriBuilder.Path = path; if (string.IsNullOrEmpty(uriBuilder.Query)) diff --git a/src/STranslate/ViewModels/Preference/Translator/TranslatorChatglm.cs b/src/STranslate/ViewModels/Preference/Translator/TranslatorChatglm.cs index d38a32b6..fe449fc8 100644 --- a/src/STranslate/ViewModels/Preference/Translator/TranslatorChatglm.cs +++ b/src/STranslate/ViewModels/Preference/Translator/TranslatorChatglm.cs @@ -355,8 +355,7 @@ public async Task TranslateAsync(object request, Action onDataReceived, UriBuilder uriBuilder = new(Url); // 兼容旧版API: https://open.bigmodel.cn/dev/api#glm-4 - // 如果路径为空或者不是有效的API路径结尾,使用默认路径 - if (!uriBuilder.Path.EndsWith("/api/paas/v4/chat/completions") && uriBuilder.Path == "/") + if (uriBuilder.Path == "/") uriBuilder.Path = "/api/paas/v4/chat/completions"; // 选择模型 diff --git a/src/STranslate/ViewModels/Preference/Translator/TranslatorClaude.cs b/src/STranslate/ViewModels/Preference/Translator/TranslatorClaude.cs index f6b06527..05d76af2 100644 --- a/src/STranslate/ViewModels/Preference/Translator/TranslatorClaude.cs +++ b/src/STranslate/ViewModels/Preference/Translator/TranslatorClaude.cs @@ -349,8 +349,7 @@ public async Task TranslateAsync(object request, Action onDataReceived, UriBuilder uriBuilder = new(Url); - // 如果路径为空或者不是有效的API路径结尾,使用默认路径 - if (!uriBuilder.Path.EndsWith("/v1/messages") && uriBuilder.Path == "/") + if (uriBuilder.Path == "/") uriBuilder.Path = "/v1/messages"; // 选择模型 diff --git a/src/STranslate/ViewModels/Preference/Translator/TranslatorDeepSeek.cs b/src/STranslate/ViewModels/Preference/Translator/TranslatorDeepSeek.cs index 078e69d5..e9b58c4a 100644 --- a/src/STranslate/ViewModels/Preference/Translator/TranslatorDeepSeek.cs +++ b/src/STranslate/ViewModels/Preference/Translator/TranslatorDeepSeek.cs @@ -347,8 +347,7 @@ public async Task TranslateAsync(object request, Action onDataReceived, UriBuilder uriBuilder = new(Url); - // 如果路径为空或者不是有效的API路径结尾,使用默认路径 - if (!uriBuilder.Path.EndsWith("/chat/completions") && uriBuilder.Path == "/") + if (uriBuilder.Path == "/") uriBuilder.Path = "/chat/completions"; // 选择模型 diff --git a/src/STranslate/ViewModels/Preference/Translator/TranslatorGemini.cs b/src/STranslate/ViewModels/Preference/Translator/TranslatorGemini.cs index 99a613fc..851bb8ee 100644 --- a/src/STranslate/ViewModels/Preference/Translator/TranslatorGemini.cs +++ b/src/STranslate/ViewModels/Preference/Translator/TranslatorGemini.cs @@ -359,8 +359,7 @@ public async Task TranslateAsync(object request, Action onDataReceived, var a_model = Model.Trim(); a_model = string.IsNullOrEmpty(a_model) ? "gemini-pro" : a_model; - // 如果路径为空或者不是有效的API路径结尾,使用默认路径 - if (!uriBuilder.Path.EndsWith($"/v1beta/models/{a_model}:streamGenerateContent") && uriBuilder.Path == "/") + if (uriBuilder.Path == "/") uriBuilder.Path = $"/v1beta/models/{a_model}:streamGenerateContent"; uriBuilder.Query = $"key={AppKey}"; diff --git a/src/STranslate/ViewModels/Preference/Translator/TranslatorOllama.cs b/src/STranslate/ViewModels/Preference/Translator/TranslatorOllama.cs index 54b8f026..edbb77a0 100644 --- a/src/STranslate/ViewModels/Preference/Translator/TranslatorOllama.cs +++ b/src/STranslate/ViewModels/Preference/Translator/TranslatorOllama.cs @@ -349,8 +349,7 @@ public async Task TranslateAsync(object request, Action onDataReceived, UriBuilder uriBuilder = new(Url); - // 如果路径为空或者不是有效的API路径结尾,使用默认路径 - if (!uriBuilder.Path.EndsWith("/api/chat") && uriBuilder.Path == "/") + if (uriBuilder.Path == "/") uriBuilder.Path = "/api/chat"; // 选择模型 diff --git a/src/STranslate/ViewModels/Preference/Translator/TranslatorOpenAI.cs b/src/STranslate/ViewModels/Preference/Translator/TranslatorOpenAI.cs index ce06fb11..cab08d1e 100644 --- a/src/STranslate/ViewModels/Preference/Translator/TranslatorOpenAI.cs +++ b/src/STranslate/ViewModels/Preference/Translator/TranslatorOpenAI.cs @@ -350,8 +350,8 @@ public async Task TranslateAsync(object request, Action onDataReceived, UriBuilder uriBuilder = new(Url); // 兼容旧版API: https://platform.openai.com/docs/guides/text-generation - // 如果路径为空或者不是有效的API路径结尾,使用默认路径 - if (!uriBuilder.Path.EndsWith("/v1/chat/completions") && !uriBuilder.Path.EndsWith("/v1/completions") && uriBuilder.Path == "/") + // 如果路径不是有效的API路径结尾,使用默认路径 + if (uriBuilder.Path == "/") uriBuilder.Path = "/v1/chat/completions"; // 选择模型