Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anthropic streaming error: NullPointerException #1870

Open
destitutus opened this issue Dec 5, 2024 · 0 comments
Open

Anthropic streaming error: NullPointerException #1870

destitutus opened this issue Dec 5, 2024 · 0 comments

Comments

@destitutus
Copy link

Bug description
NullPointerException happens during anthropic streaming

Aggregation Error
java.lang.NullPointerException: Cannot invoke "org.springframework.ai.anthropic.api.StreamHelper$ChatCompletionResponseBuilder.withType(String)" because the return value of "java.util.concurrent.atomic.AtomicReference.get()" is null

Environment
"org.springframework.ai:spring-ai-bom:1.0.0-SNAPSHOT + org.springframework.ai:spring-ai-openai + org.springframework.ai:spring-ai-anthropic-spring-boot-starter

Steps to reproduce
Unfortunately, it happens sometimes, probably it depends on the streaming response chain.
Prerequisites: Anthropic streaming call

org.springframework.ai.chat.model.MessageAggregator:170 lambda$aggregate$6 - Aggregation Error
 
 java.lang.NullPointerException: Cannot invoke "org.springframework.ai.anthropic.api.StreamHelper$ChatCompletionResponseBuilder.withType(String)" because the return value of "java.util.concurrent.atomic.AtomicReference.get()" is null
         at org.springframework.ai.anthropic.api.StreamHelper.eventToChatCompletionResponse(StreamHelper.java:185)
         at org.springframework.ai.anthropic.api.AnthropicApi.lambda$chatCompletionStream$9(AnthropicApi.java:217)
         at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:208)
         at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmit(FluxFlatMap.java:547)
         at reactor.core.publisher.FluxFlatMap$FlatMapInner.onNext(FluxFlatMap.java:988)
         at reactor.core.publisher.Operators$BaseFluxToMonoOperator.completePossiblyEmpty(Operators.java:2097)
         at reactor.core.publisher.MonoReduceSeed$ReduceSeedSubscriber.onComplete(MonoReduceSeed.java:163)
         at reactor.core.publisher.FluxWindowPredicate$WindowFlux.checkTerminated(FluxWindowPredicate.java:768)
         at reactor.core.publisher.FluxWindowPredicate$WindowFlux.drainRegular(FluxWindowPredicate.java:662)
         at reactor.core.publisher.FluxWindowPredicate$WindowFlux.drain(FluxWindowPredicate.java:748)
         at reactor.core.publisher.FluxWindowPredicate$WindowFlux.onComplete(FluxWindowPredicate.java:814)
         at reactor.core.publisher.FluxWindowPredicate$WindowPredicateMain.onNext(FluxWindowPredicate.java:243)
         at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122)
         at reactor.core.publisher.FluxFilter$FilterSubscriber.onNext(FluxFilter.java:113)
         at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:224)
         at reactor.core.publisher.FluxFilter$FilterConditionalSubscriber.onNext(FluxFilter.java:247)
         at reactor.core.publisher.FluxTakeUntil$TakeUntilPredicateSubscriber.onNext(FluxTakeUntil.java:95)
         at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:251)
         at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
         at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539)
         at reactor.core.publisher.FluxConcatMapNoPrefetch$FluxConcatMapNoPrefetchSubscriber.innerNext(FluxConcatMapNoPrefetch.java:259)
         at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:865)
         at reactor.core.publisher.FluxConcatMap$WeakScalarSubscription.request(FluxConcatMap.java:480)
         at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2367)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant