From 5eee4912347a29ff8d5ba8bb982c8907bf4bdde2 Mon Sep 17 00:00:00 2001 From: quyixiao <2621048238@qq.com> Date: Thu, 11 Sep 2025 08:29:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../translation/TranslationController.java | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/translation/TranslationController.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/translation/TranslationController.java index 71085c2..8cbd64b 100644 --- a/api-web/api-interface/src/main/java/com/heyu/api/controller/translation/TranslationController.java +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/translation/TranslationController.java @@ -20,8 +20,46 @@ public class TranslationController { // http://localhost:8888/general/translation/language?content=我是一只小猫&language=英语 @EbAuthentication(tencent = ApiConstants.TENCENT_AUTH) - @RequestMapping("/language") + @RequestMapping("/language1000") + public R language1000(@RequestBody TranslationRequest translationRequest) throws Exception { + if(translationRequest.getContent().length() > 1000){ + return R.ok("字符长度不能超过1000"); + } + return doTranslation(translationRequest); + + } + + // http://localhost:8888/general/translation/language?content=我是一只小猫&language=英语 + @EbAuthentication(tencent = ApiConstants.TENCENT_AUTH) + @RequestMapping("/language2000") + public R language2000(@RequestBody TranslationRequest translationRequest) throws Exception { + if(translationRequest.getContent().length() > 2000){ + return R.ok("字符长度不能超过2000"); + } + return doTranslation(translationRequest); + } + + // http://localhost:8888/general/translation/language?content=我是一只小猫&language=英语 + @EbAuthentication(tencent = ApiConstants.TENCENT_AUTH) + @RequestMapping("/language5000") public R language(@RequestBody TranslationRequest translationRequest) throws Exception { + if(translationRequest.getContent().length() > 5000){ + return R.ok("字符长度不能超过5000"); + } + return doTranslation(translationRequest); + } + + // http://localhost:8888/general/translation/language?content=我是一只小猫&language=英语 + @EbAuthentication(tencent = ApiConstants.TENCENT_AUTH) + @RequestMapping("/language8000") + public R language8000(@RequestBody TranslationRequest translationRequest) throws Exception { + if(translationRequest.getContent().length() > 8000){ + return R.ok("字符长度不能超过8000"); + } + return doTranslation(translationRequest); + } + + public R doTranslation(@RequestBody TranslationRequest translationRequest) { String prompt = LLMUtils.prompt + translationRequest.getLanguage(); ModelResult modelResult = LLMUtils.callBaiLian(translationRequest.getContent(), prompt); @@ -37,4 +75,7 @@ public class TranslationController { return R.ok().setData(resp); } + + + } \ No newline at end of file