| @@ -41,7 +41,7 @@ func NewLLM(cfg LLMConfig) TextModel { |
| 41 | | 41 | |
| 42 | func (c *llm) DetectLanguages(ctx context.Context, texts []string) ([]string, error) { | 42 | func (c *llm) DetectLanguages(ctx context.Context, texts []string) ([]string, error) { |
| 43 | var b strings.Builder | 43 | var b strings.Builder |
| 44 | - b.WriteString("For each text below, respond with ONLY the ISO 639-1 language code (e.g. en, fr, de, es, pt, it, ru, ja, zh, ko, ar). One code per line, same order as input. If uncertain, respond with 'en'.\n\n") | 44 | + b.WriteString("For each text below, respond with ONLY the ISO 639-1 language code (e.g. en, fr, de, es, pt, it, ru, ja, zh, ko, ar). One code per line, same order as input. If uncertain, respond with 'unknown'.\n\n") |
| 45 | for i, t := range texts { | 45 | for i, t := range texts { |
| 46 | truncated := t | 46 | truncated := t |
| 47 | if len(truncated) > 500 { | 47 | if len(truncated) > 500 { |
| @@ -71,7 +71,7 @@ func (c *llm) DetectLanguages(ctx context.Context, texts []string) ([]string, er |
| 71 | code := strings.TrimSpace(line) | 71 | code := strings.TrimSpace(line) |
| 72 | code = strings.TrimPrefix(code, fmt.Sprintf("%d.", i+1)) | 72 | code = strings.TrimPrefix(code, fmt.Sprintf("%d.", i+1)) |
| 73 | code = strings.TrimSpace(code) | 73 | code = strings.TrimSpace(code) |
| 74 | - if IsKnownLanguage(code) { | 74 | + if IsKnownLanguage(code) || code == "unknown" { |
| 75 | result[i] = code | 75 | result[i] = code |
| 76 | } | 76 | } |
| 77 | } | 77 | } |