admin管理员组文章数量:1353322
I have a working Spring AI project, but when I add dependencies for Spring Cloud (such as Eureka or Config Client), I get the following error when invoking the chat client.
Dependencies:
Spring Cloud Dependencies
<spring-ai.version>1.0.0-M6</spring-ai.version>
<spring-cloud.version>4.2.1</spring-cloud.version>
<dependency>
<groupId>.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>${spring-cloud.version}</version>
</dependency>
<dependency>
<groupId>.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
<version>${spring-cloud.version}</version>
</dependency>
Spring AI Dependency
<dependency>
<groupId>.springframework.ai</groupId>
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>
Version Management
<dependencyManagement>
<dependencies>
<dependency>
<groupId>.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Error Log
2025-03-31T20:28:19.393+02:00 ERROR 53666 --- [nio-8084-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: .springframework.web.client.RestClientException: Error while extracting response for type [.springframework.ai.openai.api.OpenAiApi$ChatCompletion] and content type [application/json]] with root cause
com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Object (start marker at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1])
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]
Expected Behavior
The chat client should work correctly and return a response from OpenAI, even with Spring Cloud dependencies present.
Troubleshooting Done
The project works fine when Spring Cloud dependencies are removed.
The issue occurs when adding either spring-cloud-starter-netflix-eureka-client
or spring-cloud-config-client
.
The error suggests a JSON parsing issue, possibly due to an incomplete or malformed response.
Questions
Has anyone encountered compatibility issues between Spring AI 1.0.0-M6 and Spring Cloud 4.2.1?
Could Spring Cloud be interfering with the HTTP client used by Spring AI?
Are there any known fixes or workarounds?
Any help or suggestions would be greatly appreciated! Thanks in advance.
I have a working Spring AI project, but when I add dependencies for Spring Cloud (such as Eureka or Config Client), I get the following error when invoking the chat client.
Dependencies:
Spring Cloud Dependencies
<spring-ai.version>1.0.0-M6</spring-ai.version>
<spring-cloud.version>4.2.1</spring-cloud.version>
<dependency>
<groupId>.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>${spring-cloud.version}</version>
</dependency>
<dependency>
<groupId>.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
<version>${spring-cloud.version}</version>
</dependency>
Spring AI Dependency
<dependency>
<groupId>.springframework.ai</groupId>
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>
Version Management
<dependencyManagement>
<dependencies>
<dependency>
<groupId>.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Error Log
2025-03-31T20:28:19.393+02:00 ERROR 53666 --- [nio-8084-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: .springframework.web.client.RestClientException: Error while extracting response for type [.springframework.ai.openai.api.OpenAiApi$ChatCompletion] and content type [application/json]] with root cause
com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Object (start marker at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 1])
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]
Expected Behavior
The chat client should work correctly and return a response from OpenAI, even with Spring Cloud dependencies present.
Troubleshooting Done
The project works fine when Spring Cloud dependencies are removed.
The issue occurs when adding either spring-cloud-starter-netflix-eureka-client
or spring-cloud-config-client
.
The error suggests a JSON parsing issue, possibly due to an incomplete or malformed response.
Questions
Has anyone encountered compatibility issues between Spring AI 1.0.0-M6 and Spring Cloud 4.2.1?
Could Spring Cloud be interfering with the HTTP client used by Spring AI?
Are there any known fixes or workarounds?
Any help or suggestions would be greatly appreciated! Thanks in advance.
Share Improve this question edited Mar 31 at 18:57 Hilory 2,1417 gold badges14 silver badges30 bronze badges asked Mar 31 at 18:39 ZuzzuzZuzzuz 111 bronze badge 2 |1 Answer
Reset to default 0If you want use a beta version of Spring AI (Spring AI 1.0.0-M6), You must use same period of versions of Spring Cloud (one beta version, not version 4.2.1 of Spring Cloud).
Best way: Use dependency management from Spring Boot and Spring Cloud (v2025.0.0-M1
https://github/spring-cloud/spring-cloud-release/releases) , all are latest snapshot version at this time of writing.
版权声明:本文标题:Spring AI and Spring Cloud Compatibility Issue: JSON Parsing Error in OpenAI Chat Client - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743927104a2563162.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
REDACTED
) of the AI actually contains JSON? These AI models are known to sometimes not follow the requested JSON schema and answer with plain text or invalid JSON. Maybe it's a coincidence that this happened when you added a Spring Cloud library. – Dimitri Mestdagh Commented Mar 31 at 19:36