diff --git a/STranslate/ViewModels/Preference/Services/TranslatorOpenAI.cs b/STranslate/ViewModels/Preference/Services/TranslatorOpenAI.cs
index 47b16f7f..c9f8a06b 100644
--- a/STranslate/ViewModels/Preference/Services/TranslatorOpenAI.cs
+++ b/STranslate/ViewModels/Preference/Services/TranslatorOpenAI.cs
@@ -73,6 +73,10 @@ public TranslatorOpenAI(
[ObservableProperty]
public string _appKey = string.Empty;
+ [JsonIgnore]
+ [ObservableProperty]
+ private string _model = "gpt-3.5-turbo";
+
[JsonIgnore]
public object _data = string.Empty;
diff --git a/STranslate/ViewModels/ServiceHandler.cs b/STranslate/ViewModels/ServiceHandler.cs
index 5a11b972..0e5540aa 100644
--- a/STranslate/ViewModels/ServiceHandler.cs
+++ b/STranslate/ViewModels/ServiceHandler.cs
@@ -1,7 +1,6 @@
using System;
using System.Linq;
using System.Net.Http;
-using System.Security.Policy;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -9,6 +8,7 @@
using Newtonsoft.Json.Linq;
using STranslate.Model;
using STranslate.Util;
+using STranslate.ViewModels.Preference.Services;
namespace STranslate.ViewModels
{
@@ -121,10 +121,13 @@ public static async Task OpenAIHandlerAsync(ITranslator service, string content,
uriBuilder.Path = uriBuilder.Path.TrimEnd('/') + "/v1/completions";
}
+ var a_model = (service as TranslatorOpenAI)?.Model;
+ a_model = string.IsNullOrEmpty(a_model) ? "gpt-3.5-turbo" : a_model;
+
// 构建请求数据
var reqData = new
{
- model = "gpt-3.5-turbo",
+ model = a_model,
messages = new[] { new { role = "user", content = $"Translate the following text to {target}: {content}" } },
temperature = 1.0,
stream = true
@@ -232,7 +235,7 @@ public static async Task GeminiHandlerAsync(ITranslator service, string content,
Content = new StringContent(jsonData, Encoding.UTF8, "application/json")
};
- // 发送请求
+ // 发送请求
using var response = await client.SendAsync(req, HttpCompletionOption.ResponseHeadersRead, token);
// 获取响应流
using var responseStream = await response.Content.ReadAsStreamAsync(token);
diff --git a/STranslate/Views/Preference/Service/TextOpenAIServicesPage.xaml b/STranslate/Views/Preference/Service/TextOpenAIServicesPage.xaml
index 47245350..85a2b493 100644
--- a/STranslate/Views/Preference/Service/TextOpenAIServicesPage.xaml
+++ b/STranslate/Views/Preference/Service/TextOpenAIServicesPage.xaml
@@ -45,6 +45,20 @@
+
+
+
+
+
+
+
+
+
+
@@ -88,7 +102,7 @@
SelectedValue="{Binding Icon}" />
-
+