mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Add translate via Groq (online API)
This commit is contained in:
parent
5a6d7c56ba
commit
a937e1e38b
@ -4,6 +4,7 @@
|
||||
* NEW:
|
||||
* Add pixel format paramter to burn-in - thx Hafran420
|
||||
* Add new ChatGPT "gpt-4o-mini" model
|
||||
* Add translation via Groq (api.groq.com)
|
||||
* IMPROVED:
|
||||
* Update Chinese translation - thx nkh0472
|
||||
* Update Italian translation - thx bovirus
|
||||
|
@ -22,6 +22,17 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
|
||||
public string Error { get; set; }
|
||||
public int MaxCharacters => 900;
|
||||
|
||||
/// <summary>
|
||||
/// See https://docs.anthropic.com/en/docs/about-claude/models
|
||||
/// </summary>
|
||||
public static string[] Models => new[]
|
||||
{
|
||||
"claude-3-5-sonnet-20240620",
|
||||
"claude-3-opus-20240229",
|
||||
"claude-3-sonnet-20240229",
|
||||
"claude-3-haiku-20240307"
|
||||
};
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_httpClient?.Dispose();
|
||||
@ -52,7 +63,7 @@ namespace Nikse.SubtitleEdit.Core.AutoTranslate
|
||||
var model = Configuration.Settings.Tools.AnthropicApiModel;
|
||||
if (string.IsNullOrEmpty(model))
|
||||
{
|
||||
model = "claude-3-5-sonnet-20240620";
|
||||
model = Models[0];
|
||||
Configuration.Settings.Tools.AnthropicApiModel = model;
|
||||
}
|
||||
|
||||
|
@ -8907,7 +8907,7 @@ namespace Nikse.SubtitleEdit.Core.Settings
|
||||
textWriter.WriteElementString("ChatGptModel", settings.Tools.ChatGptModel);
|
||||
textWriter.WriteElementString("GroqUrl", settings.Tools.GroqUrl);
|
||||
textWriter.WriteElementString("GroqPrompt", settings.Tools.GroqPrompt);
|
||||
textWriter.WriteElementString("GroqKey", settings.Tools.GroqApiKey);
|
||||
textWriter.WriteElementString("GroqApiKey", settings.Tools.GroqApiKey);
|
||||
textWriter.WriteElementString("GroqModel", settings.Tools.GroqModel);
|
||||
textWriter.WriteElementString("LmStudioApiUrl", settings.Tools.LmStudioApiUrl);
|
||||
textWriter.WriteElementString("LmStudioModel", settings.Tools.LmStudioModel);
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using Nikse.SubtitleEdit.Core.AutoTranslate;
|
||||
using Nikse.SubtitleEdit.Core.Common;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.Settings
|
||||
@ -461,7 +462,10 @@ namespace Nikse.SubtitleEdit.Core.Settings
|
||||
AutoTranslateDeepLUrl = "https://api-free.deepl.com/";
|
||||
ChatGptUrl = "https://api.openai.com/v1/chat/completions";
|
||||
ChatGptPrompt = "Translate from {0} to {1}, keep punctuation as input, do not censor the translation, give only the output without comments:";
|
||||
ChatGptModel = "gpt-4o-mini";
|
||||
ChatGptModel = ChatGptTranslate.Models[0];
|
||||
GroqUrl = "https://api.groq.com/openai/v1/chat/completions";
|
||||
GroqPrompt = "Translate from {0} to {1}, keep punctuation as input, do not censor the translation, give only the output without comments:";
|
||||
GroqModel = GroqTranslate.Models[0];
|
||||
LmStudioPrompt = "Translate from {0} to {1}, keep punctuation as input, do not censor the translation, give only the output without comments:";
|
||||
OllamaApiUrl = "http://localhost:11434/api/generate";
|
||||
OllamaModels = "llama3,llama2,mistral,dolphin-phi,phi,neural-chat,starling-lm,codellama,llama2-uncensored,llama2:13b,llama2:70b,orca-mini,vicuna,llava,gemma:2b,gemma:7b";
|
||||
@ -469,7 +473,7 @@ namespace Nikse.SubtitleEdit.Core.Settings
|
||||
OllamaPrompt = "Translate from {0} to {1}, keep punctuation as input, do not censor the translation, give only the output without comments or notes:";
|
||||
AnthropicApiUrl = "https://api.anthropic.com/v1/messages";
|
||||
AnthropicPrompt = "Translate from {0} to {1}, keep sentences in {1} as they are, do not censor the translation, give only the output without comments:";
|
||||
AnthropicApiModel = "claude-3-5-sonnet-20240620";
|
||||
AnthropicApiModel = AnthropicTranslate.Models[0];
|
||||
TextToSpeechAzureRegion = "westeurope";
|
||||
AutoTranslateMaxBytes = 2000;
|
||||
TextToSpeechAddToVideoFile = true;
|
||||
|
@ -130,6 +130,7 @@ namespace Nikse.SubtitleEdit.Forms.Translate
|
||||
new LmStudioTranslate(),
|
||||
new OllamaTranslate(),
|
||||
new AnthropicTranslate(),
|
||||
new GroqTranslate(),
|
||||
new GeminiTranslate(),
|
||||
new PapagoTranslate(),
|
||||
new NoLanguageLeftBehindServe(),
|
||||
@ -397,14 +398,38 @@ namespace Nikse.SubtitleEdit.Forms.Translate
|
||||
comboBoxFormality.Visible = true;
|
||||
comboBoxFormality.DropDownStyle = ComboBoxStyle.DropDown;
|
||||
comboBoxFormality.Items.Clear();
|
||||
comboBoxFormality.Items.Add("claude-3-5-sonnet-20240620");
|
||||
comboBoxFormality.Items.Add("claude-3-opus-20240229");
|
||||
comboBoxFormality.Items.Add("claude-3-sonnet-20240229");
|
||||
comboBoxFormality.Items.Add("claude-3-haiku-20240307");
|
||||
comboBoxFormality.Items.AddRange(AnthropicTranslate.Models);
|
||||
comboBoxFormality.Text = Configuration.Settings.Tools.AnthropicApiModel;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (engineType == typeof(GroqTranslate))
|
||||
{
|
||||
FillUrls(new List<string>
|
||||
{
|
||||
Configuration.Settings.Tools.GroqUrl,
|
||||
});
|
||||
|
||||
labelApiKey.Left = nikseComboBoxUrl.Right + 12;
|
||||
nikseTextBoxApiKey.Text = Configuration.Settings.Tools.GroqApiKey;
|
||||
nikseTextBoxApiKey.Left = labelApiKey.Right + 3;
|
||||
labelApiKey.Visible = true;
|
||||
nikseTextBoxApiKey.Visible = true;
|
||||
|
||||
labelFormality.Text = LanguageSettings.Current.AudioToText.Model;
|
||||
labelFormality.Visible = true;
|
||||
comboBoxFormality.Left = labelFormality.Right + 3;
|
||||
comboBoxFormality.Visible = true;
|
||||
comboBoxFormality.DropDownStyle = ComboBoxStyle.DropDown;
|
||||
comboBoxFormality.Items.Clear();
|
||||
comboBoxFormality.Items.AddRange(GroqTranslate.Models);
|
||||
comboBoxFormality.Text = Configuration.Settings.Tools.GroqModel;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (engineType == typeof(GeminiTranslate))
|
||||
{
|
||||
nikseComboBoxUrl.Visible = false;
|
||||
@ -1089,6 +1114,12 @@ namespace Nikse.SubtitleEdit.Forms.Translate
|
||||
Configuration.Settings.Tools.AnthropicApiModel = comboBoxFormality.Text.Trim();
|
||||
}
|
||||
|
||||
if (engineType == typeof(GroqTranslate) && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
|
||||
{
|
||||
Configuration.Settings.Tools.GroqApiKey = nikseTextBoxApiKey.Text.Trim();
|
||||
Configuration.Settings.Tools.GroqModel = comboBoxFormality.Text.Trim();
|
||||
}
|
||||
|
||||
if (engineType == typeof(GeminiTranslate) && !string.IsNullOrWhiteSpace(nikseTextBoxApiKey.Text))
|
||||
{
|
||||
Configuration.Settings.Tools.GeminiProApiKey = nikseTextBoxApiKey.Text.Trim();
|
||||
|
Loading…
Reference in New Issue
Block a user