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