CodePhiliaX / Chat2DB

🔥🔥🔥AI-driven database tool and SQL client, The hottest GUI client, supporting MySQL, Oracle, PostgreSQL, DB2, SQL Server, DB2, SQLite, H2, ClickHouse, and more.
http://chat2db.ai
Apache License 2.0
15.95k stars 1.78k forks source link

Bug: web端无法使用自定义ai功能 #601

Closed caoyutingtjpu closed 12 months ago

caoyutingtjpu commented 1 year ago

Chat2DB Version

3.0.0

Describe the bug

在使用ai功能时候,点击没有反应 image

是api/ai/chat?message=%E5%88%9B%E5%BB%BA%E7%94%A8%E6%88%B7&promptType=NL_2_SQL&dataSourceId=2&databaseName=mysql 接口返回500

还没有到调用自定义ai url那块,就已经报错

CoderXiaohui commented 1 year ago

同错误

CoderXiaohui commented 1 year ago

错误日志如下:

2023-10-19 03:54:35.511 ERROR 1 --- [io-10824-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]   .175 :  | Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.IllegalArgumentException: Expected URL scheme 'http' or 'https' but no scheme was found for ] with root cause

java.lang.IllegalArgumentException: Expected URL scheme 'http' or 'https' but no scheme was found for 
        at okhttp3.HttpUrl$Builder.parse$okhttp(HttpUrl.kt:1261)
        at okhttp3.HttpUrl$Companion.get(HttpUrl.kt:1634)
        at okhttp3.HttpUrl.get(HttpUrl.kt)
        at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:506)
        at ai.chat2db.server.web.api.controller.ai.fastchat.client.FastChatAIStreamClient.<init>(FastChatAIStreamClient.java:89)
        at ai.chat2db.server.web.api.controller.ai.fastchat.client.FastChatAIStreamClient$Builder.build(FastChatAIStreamClient.java:173)
        at ai.chat2db.server.web.api.controller.ai.fastchat.client.FastChatAIClient.refresh(FastChatAIClient.java:77)
        at ai.chat2db.server.web.api.controller.ai.fastchat.client.FastChatAIClient.singleton(FastChatAIClient.java:52)
        at ai.chat2db.server.web.api.controller.ai.fastchat.client.FastChatAIClient.getInstance(FastChatAIClient.java:44)
        at ai.chat2db.server.web.api.controller.ai.ChatController.chatWithFastChatAi(ChatController.java:382)
        at ai.chat2db.server.web.api.controller.ai.ChatController.distributeAISql(ChatController.java:238)
        at ai.chat2db.server.web.api.controller.ai.ChatController.completions(ChatController.java:211)
        at jdk.internal.reflect.GeneratedMethodAccessor220.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.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
        at ai.chat2db.server.web.api.aspect.ConnectionInfoHandler.connectionInfoHandler(ConnectionInfoHandler.java:61)
        at jdk.internal.reflect.GeneratedMethodAccessor38.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.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:637)
        at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:627)
        at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:71)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:702)
        at ai.chat2db.server.web.api.controller.ai.ChatController$$SpringCGLIB$$0.completions(<generated>)
        at jdk.internal.reflect.GeneratedMethodAccessor220.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.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:207)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:152)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:974)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1011)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:527)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
        at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:614)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
        at ai.chat2db.server.start.config.interceptor.CorsFilter.doFilter(CorsFilter.java:37)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
        at org.zalando.logbook.servlet.LogbookFilter.doFilter(LogbookFilter.java:76)
        at org.zalando.logbook.servlet.HttpFilter.doFilter(HttpFilter.java:32)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
        at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
        at ai.chat2db.server.start.log.LogOncePerRequestFilter.doFilterInternal(LogOncePerRequestFilter.java:32)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:166)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:390)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:894)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:833)
shanhexi commented 1 year ago

欢迎PR

caoyutingtjpu commented 12 months ago

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/ai/ChatController.java该文件的

232 switch (Objects.requireNonNull(aiSqlSourceEnum)) { 233 case OPENAI : 234 return chatWithOpenAi(queryRequest, sseEmitter, uid); 235 case CHAT2DBAI: 236 return chatWithChat2dbAi(queryRequest, sseEmitter, uid); 237 case RESTAI : 需要添加return

Edisonwei54 commented 11 months ago

chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/ai/ChatController.java该文件的

232 switch (Objects.requireNonNull(aiSqlSourceEnum)) { 233 case OPENAI : 234 return chatWithOpenAi(queryRequest, sseEmitter, uid); 235 case CHAT2DBAI: 236 return chatWithChat2dbAi(queryRequest, sseEmitter, uid); 237 case RESTAI : 需要添加return

似乎没有任何效果,我在3.0.11版本同样的bug