moyangzhan / langchain4j-aideepin

基于AI的工作效率提升工具 | Retrieval enhancement generation(RAG) project
http://www.aideepin.com
MIT License
310 stars 80 forks source link

知识库问答出现ApiException #36

Closed nemolig closed 1 month ago

nemolig commented 2 months ago

2024-08-20 13:33:02.254 ERROR [mainExecutor-6] com.moyz.adi.common.helper.SSEEmitterHelper ragProcess error

com.alibaba.dashscope.exception.ApiException: {"statusCode":400,"message":"<400> InternalError.Algo.InvalidParameter: Range of input length should be [1, 6000]","code":"InvalidParameter","isJson":true,"requestId":"c95f102f-50a9-975b-954d-b5ed182052cf"} at com.alibaba.dashscope.protocol.okhttp.OkHttpHttpClient.send(OkHttpHttpClient.java:187) at com.alibaba.dashscope.api.SynchronizeHalfDuplexApi.call(SynchronizeHalfDuplexApi.java:58) at com.alibaba.dashscope.aigc.generation.Generation.call(Generation.java:102) at dev.langchain4j.model.dashscope.QwenChatModel.generateByNonMultimodalModel(QwenChatModel.java:105) at dev.langchain4j.model.dashscope.QwenChatModel.generate(QwenChatModel.java:83) at dev.langchain4j.model.chat.ChatLanguageModel.generate(ChatLanguageModel.java:39) at dev.langchain4j.model.chat.ChatLanguageModel.generate(ChatLanguageModel.java:27) at dev.langchain4j.rag.query.transformer.CompressingQueryTransformer.transform(CompressingQueryTransformer.java:74) at dev.langchain4j.rag.DefaultRetrievalAugmentor.augment(DefaultRetrievalAugmentor.java:141) at dev.langchain4j.service.DefaultAiServices$1.invoke(DefaultAiServices.java:103) at jdk.proxy2/jdk.proxy2.$Proxy175.chatWithoutSystemMessage(Unknown Source) at com.moyz.adi.common.interfaces.AbstractLLMService.ragChat(AbstractLLMService.java:108) at com.moyz.adi.common.helper.SSEEmitterHelper.ragProcess(SSEEmitterHelper.java:101) at com.moyz.adi.common.service.KnowledgeBaseService.retrieveAndPushToLLM(KnowledgeBaseService.java:392) at jdk.internal.reflect.GeneratedMethodAccessor46.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: com.alibaba.dashscope.exception.ApiException: {"statusCode":400,"message":"<400> InternalError.Algo.InvalidParameter: Range of input length should be [1, 6000]","code":"InvalidParameter","isJson":true,"requestId":"c95f102f-50a9-975b-954d-b5ed182052cf"} ... 27 common frames omitted

moyangzhan commented 2 months ago

@nemolig 看起来是请求LLM时参数太长了,知识库有设置了召回文档数量吗?

nemolig commented 2 months ago

没有设置,是自动计算的,使用的模型是qwen-turbo,知识库中只有一个800KB的pdf文件 image

moyangzhan commented 2 months ago

@nemolig 初步判断是携带的历史记录太多了,可以先把AbstractLLMService.ragChat方法里的maxMessages(6)里的值改小点,比如说改成maxMessages(2),过几天我再提交一个好点的版本,可以自动判断应该携带多少条历史记录。

nemolig commented 2 months ago

还有个建议,就是好像没有清空知识库聊天记录功能,每次进页面都自动加载历史,能不能手动清除呢

moyangzhan commented 2 months ago

还有个建议,就是好像没有清空知识库聊天记录功能,每次进页面都自动加载历史,能不能手动清除呢

@nemolig 功能加上去了,需要重新拉下前后端的代码 image

image