问题描述
今天在学习Spring-AI的时,调用openAiChatModel.call(message)方法时,遇到了这个错误
Error while extracting response for type [org.springframework.ai.openai.api.OpenAiApi$ChatCompletion] and content type [application/json;charset=utf-8]
org.springframework.web.client.RestClientException: Error while extracting response for type [org.springframework.ai.openai.api.OpenAiApi$ChatCompletion] and content type [application/json;charset=utf-8]
解决方案
项目中添加该依赖
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2.1</version>
</dependency>
参考
https://stackoverflow.com/questions/78121525/spring-ai-openai-error-extracting-response-of-type-openaiapiembeddinglist