From c6673e26e17b2057340c054a969ade266db1aee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90=C6=B0=E1=BB=A3c=20Nguy=E1=BB=85n=20V=C4=83n?= Date: Mon, 9 Sep 2024 17:46:35 +0700 Subject: [PATCH] feat: enhance translation instruction handling - Add conditional logic to include previous translation in instruction - Improve formatting of instruction string when previous translation exists --- cmd/serve.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/serve.go b/cmd/serve.go index d7a01a0..f237fb3 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -411,7 +411,12 @@ func runServe(cmd *cobra.Command, args []string) error { } }) - instructment := `previous translation:` + currentTranslatedContent + `\n` + req.Instructions + instructment := req.Instructions + + if len(currentTranslatedContent) == 0{ + instructment = `Previous translation:\n\n` + currentTranslatedContent + `\n\n` + instructment + } + translatedContent, err := translateWithAI(originalContent, instructment) if err != nil {