Closed Lzzzii10 closed 3 months ago
有没有具体报错
是这样的 @zRzRzRzRzRzRzR ` org.springframework.ai.retry.NonTransientAiException: 422 - {"detail":[{"type":"missing","loc":["body"],"msg":"Field required","input":null}]}
at org.springframework.ai.retry.RetryUtils$2.handleError(RetryUtils.java:77)
at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
at org.springframework.web.client.StatusHandler.lambda$fromErrorHandler$1(StatusHandler.java:71)
at org.springframework.web.client.StatusHandler.handle(StatusHandler.java:146)
at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.applyStatusHandlers(DefaultRestClient.java:698)
at org.springframework.web.client.DefaultRestClient.readWithMessageConverters(DefaultRestClient.java:200)
at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.readBody(DefaultRestClient.java:685)
at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.toEntityInternal(DefaultRestClient.java:655)
at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.toEntity(DefaultRestClient.java:644)
at org.springframework.ai.openai.api.OpenAiApi.chatCompletionEntity(OpenAiApi.java:778)
at org.springframework.ai.openai.OpenAiChatModel.doChatCompletion(OpenAiChatModel.java:376)
at org.springframework.ai.openai.OpenAiChatModel.doChatCompletion(OpenAiChatModel.java:76)
at org.springframework.ai.model.function.AbstractFunctionCallSupport.callWithFunctionSupport(AbstractFunctionCallSupport.java:127)
at org.springframework.ai.openai.OpenAiChatModel.lambda$call$1(OpenAiChatModel.java:144)
at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:344)
at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:217)
at org.springframework.ai.openai.OpenAiChatModel.call(OpenAiChatModel.java:142)
at com.mx.mxspringai.MxSpringaiApplicationTests.contextLoads(MxSpringaiApplicationTests.java:18)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
`
额这是你环境的问题吧,为什会出现java,这是python的代码
啊 就是用的java去访问这个openai_api,用的是spring ai
我们只用了sse,其他没有测过
System Info / 系統信息
python3.10
Who can help? / 谁可以帮助到您?
No response
Information / 问题信息
Reproduction / 复现过程
spring ai的代码 OpenAiApi openAiApi = new OpenAiApi(baseUrl, apiKey); return new OpenAiChatModel(openAiApi);
Expected behavior / 期待表现
解决