Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
chore: remove deprecated code
沈浩a09a8dc5babb
diff --git a/config/config-example.toml b/config/config-example.tomlindex c571a1e4..ff94ea60 100644--- a/config/config-example.toml+++ b/config/config-example.toml@@ -4,7 +4,7 @@translate_parallel_num = 3 # 并发进行翻译的数量上限,建议值:3,倍于转录的并发量,如果使用TPM限制严格的API,可以适当调低transcribe_max_attempts = 3 # 转录最大尝试次数,建议值:3translate_max_attempts = 5 # 翻译最大尝试次数,建议值:5,如果模型参数量较少或翻译失败率较高可以适当调高- max_sentence_length = 70 # 最大句子长度,超过这个长度的句子会被拆分,建议值:50-70+ max_sentence_length = 70 # 每句最大字符数,超过这个长度的句子会被拆分,建议值:50-70proxy = "" # 网络代理地址,格式如http://127.0.0.1:7890,可不填[server]diff --git a/config/config.go b/config/config.goindex 009c6d73..244f82f0 100644--- a/config/config.go+++ b/config/config.go@@ -35,7 +35,6 @@ type OpenaiCompatibleConfig struct {BaseUrl string `toml:"base_url"`ApiKey string `toml:"api_key"`Model string `toml:"model"`- Json bool `toml:"json"`}type LocalModelConfig struct {@@ -99,6 +98,7 @@ var Conf = Config{TranscribeParallelNum: 1,TranscribeMaxAttempts: 3,TranslateMaxAttempts: 3,+ MaxSentenceLength: 70,},Server: Server{Host: "127.0.0.1",diff --git a/internal/desktop/ui.go b/internal/desktop/ui.goindex e99f0ac5..9f99d33a 100644--- a/internal/desktop/ui.go+++ b/internal/desktop/ui.go@@ -193,6 +193,19 @@ func createAppConfigGroup() *fyne.Container {return nil}+ appMaxSentenceLengthEntry := StyledEntry("每个句子最大字符数 Max sentence length")+ appMaxSentenceLengthEntry.Bind(binding.IntToString(binding.BindInt(&config.Conf.App.MaxSentenceLength)))+ appMaxSentenceLengthEntry.Validator = func(s string) error {+ val, err := strconv.Atoi(s)+ if err != nil {+ return fmt.Errorf("请输入数字")+ }+ if val < 1 || val > 200 {+ return fmt.Errorf("请输入1-200之间的数字")+ }+ return nil+ }+appProxyEntry := StyledEntry("网络代理地址")appProxyEntry.Bind(binding.BindString(&config.Conf.App.Proxy))@@ -202,6 +215,7 @@ func createAppConfigGroup() *fyne.Container {widget.NewFormItem("翻译最大并行数量 Translate parallel num", appTranslateParallelNumEntry),widget.NewFormItem("转录最大尝试次数 Transcribe max attempts", appTranscribeMaxAttemptsEntry),widget.NewFormItem("翻译最大尝试次数 Translate max attempts", appTranslateMaxAttemptsEntry),+ widget.NewFormItem("每个句子最大字符数 Max sentence length", appMaxSentenceLengthEntry),widget.NewFormItem("网络代理地址 proxy", appProxyEntry),)@@ -244,15 +258,10 @@ func createLlmConfigGroup() *fyne.Container {modelEntry := StyledEntry("模型名称 Model name")modelEntry.Bind(binding.BindString(&config.Conf.Llm.Model))- jsonCheck := widget.NewCheck("JSON 格式化 format", func(b bool) {- config.Conf.Llm.Json = b- })-form := widget.NewForm(widget.NewFormItem("API Base URL", baseUrlEntry),widget.NewFormItem("API Key", apiKeyEntry),widget.NewFormItem("模型名称 Model name", modelEntry),- widget.NewFormItem("模型是否支持 Does model support", jsonCheck),)return GlassCard("LLM 配置 LLM Config", "LLM配置 LLM config", form)}diff --git a/internal/service/audio2subtitle.go b/internal/service/audio2subtitle.goindex c604957e..1445d1d0 100644--- a/internal/service/audio2subtitle.go+++ b/internal/service/audio2subtitle.go@@ -12,7 +12,6 @@ import ("krillin-ai/pkg/util""os""path/filepath"- "regexp""runtime""runtime/debug""strconv"@@ -114,53 +113,6 @@ func (s Service) transcribeAudio(id int, audioFilePath string, language string,return transcriptionData, nil}-func (s Service) splitTextAndTranslate(basePath, inputText, targetLanguage string, enableModalFilter bool, id int) ([]*TranslatedItem, error) {- var prompt string- var promptPrefix string-- promptPrefix = ""-- //// 对于qwen3模型,开启非思考模式- //if config.Conf.Openai.NoThinkTag {- // promptPrefix = "\\no_think\n"- //}-- // 选择提示词- if enableModalFilter {- if config.Conf.Llm.Json {- prompt = promptPrefix + fmt.Sprintf(types.SplitTextPromptWithModalFilterJson, targetLanguage)- } else {- prompt = promptPrefix + fmt.Sprintf(types.SplitTextPromptWithModalFilter, targetLanguage)- }- } else {- if config.Conf.Llm.Json {- prompt = promptPrefix + fmt.Sprintf(types.SplitTextPromptJson, targetLanguage)- } else {- prompt = promptPrefix + fmt.Sprintf(types.SplitTextPrompt, targetLanguage)- }- }-- // 如果输入文本为空,则返回空结果- if inputText == "" {- return []*TranslatedItem{}, nil- }-- textResult, err := s.ChatCompleter.ChatCompletion(prompt + inputText)- if err != nil {- return nil, fmt.Errorf("audioToSubtitle splitTextAndTranslate ChatCompletion error: %w", err)- }- _ = util.SaveToDisk(textResult, filepath.Join(basePath, fmt.Sprintf(types.SubtitleTaskTranslationRawDataPersistenceFileNamePattern, id)))-- re := regexp.MustCompile(`^\s*<think>.*?</think>`)- textResult = strings.TrimSpace(re.ReplaceAllString(textResult, ""))-- results, err := parseAndCheckContent(textResult, inputText)- if err != nil {- return nil, fmt.Errorf("audioToSubtitle splitTextAndTranslate error: %w", err)- }- return results, nil-}-func (s Service) splitTextAndTranslateV2(basePath, inputText string, originLang, targetLang types.StandardLanguageCode, enableModalFilter bool, id int) ([]*TranslatedItem, error) {sentences := util.SplitTextSentences(inputText)if len(sentences) == 0 {diff --git a/pkg/openai/openai.go b/pkg/openai/openai.goindex 21ddd458..1707ad34 100644--- a/pkg/openai/openai.go+++ b/pkg/openai/openai.go@@ -17,39 +17,6 @@ import (func (c *Client) ChatCompletion(query string) (string, error) {var responseFormat *openai.ChatCompletionResponseFormat- if config.Conf.Llm.Json {- responseFormat = &openai.ChatCompletionResponseFormat{- Type: "json_schema",- JSONSchema: &openai.ChatCompletionResponseFormatJSONSchema{- Name: "translation_response",- Strict: true,- Schema: json.RawMessage(`{- "type": "object",- "properties": {- "translations": {- "type": "array",- "items": {- "type": "object",- "properties": {- "original_sentence": {"type": "string"},- "translated_sentence": {"type": "string"}- },- "required": ["original_sentence", "translated_sentence"],- "additionalProperties": false- }- }- },- "required": ["translations"],- "additionalProperties": false- }`),- },- }- } else {- responseFormat = &openai.ChatCompletionResponseFormat{- Type: "text",- }- }-req := openai.ChatCompletionRequest{Model: config.Conf.Llm.Model,Messages: []openai.ChatCompletionMessage{@@ -93,15 +60,6 @@ func (c *Client) ChatCompletion(query string) (string, error) {resContent += response.Choices[0].Delta.Content}- if config.Conf.Llm.Json {- parsedContent, err := parseJSONResponse(resContent)- if err != nil {- log.GetLogger().Error("failed to parse JSON response", zap.Error(err))- return "", err- }- return parsedContent, nil- }-return resContent, nil}