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

bug: Mistral streaming mode raise a NPE if content JSON field is missing #489

Closed
philippart-s opened this issue Apr 23, 2024 · 12 comments · Fixed by #510
Closed

bug: Mistral streaming mode raise a NPE if content JSON field is missing #489

philippart-s opened this issue Apr 23, 2024 · 12 comments · Fixed by #510
Labels
bug Something isn't working

Comments

@philippart-s
Copy link
Contributor

Hi,
I use Mistral 7b model self deployed and I have the following error in streaming mode:

java.lang.NullPointerException: `emit` called with `null`.
        at io.smallrye.mutiny.operators.multi.builders.SerializedMultiEmitter.emit(SerializedMultiEmitter.java:138)
        at dev.langchain4j.service.AiServiceStreamingResponseHandler.onNext(AiServiceStreamingResponseHandler.java:53)
        at io.quarkiverse.langchain4j.mistralai.QuarkusMistralAiClient$2.accept(QuarkusMistralAiClient.java:82)
        at io.quarkiverse.langchain4j.mistralai.QuarkusMistralAiClient$2.accept(QuarkusMistralAiClient.java:76)

this seems to be due to the fact that the first JSON response line has not a content field:

- body: data: {"id":"cmpl-bb94685434ec46669cd161cc42ee5ed5","model":"Mixtral-8x7B-Instruct-v0.1","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"cmpl-bb94685434ec46669cd161cc42ee5ed5","object":"chat.completion.chunk","created":1713899355,"model":"Mixtral-8x7B-Instruct-v0.1","choices":[{"index":0,"delta":{"role":null,"content":"Certain"},"finish_reason":null}]}

...

Perhaps it should be fine to test the presence of the content field?

@geoand
Copy link
Collaborator

geoand commented Apr 24, 2024

@langchain4j is this a known issue on the library side?

@geoand geoand added the bug Something isn't working label Apr 24, 2024
@philippart-s
Copy link
Contributor Author

@geoand
Copy link
Collaborator

geoand commented Apr 25, 2024

@philippart-s would you like to provide a PR with the proposed fix?

@philippart-s
Copy link
Contributor Author

@philippart-s would you like to provide a PR with the proposed fix?

If you agree with my proposal, I'd love to 😉

@geoand
Copy link
Collaborator

geoand commented Apr 25, 2024

Go right ahead :)

@nhh1603
Copy link

nhh1603 commented Apr 26, 2024

Capture d'écran 2024-04-26 141850
Capture d'écran 2024-04-26 142545

I'm not sure if it's the same problem, but I also use Mistral 7b locally, and the problem is each time it finishes token streaming, it returns this error to me. When i inspect with Postman it seems to me that the last token has no content in it (to indicate that it's done) but somehow the code continues to pass in the onNext block which causes this IllegalArgumentException instead of entering the onComplete block. For the streaming code, I literally copied paste the one from the example.

@geoand
Copy link
Collaborator

geoand commented Apr 26, 2024

Have you tried with 0.12.1?

@nhh1603
Copy link

nhh1603 commented Apr 26, 2024

That is the version of which one ?

@geoand
Copy link
Collaborator

geoand commented Apr 26, 2024

Of quarkus-langchain4j-mistral-ai

@nhh1603
Copy link

nhh1603 commented Apr 26, 2024

Ok thanks I'll try it out and I'll let you know if the problem persists

@geoand
Copy link
Collaborator

geoand commented Apr 26, 2024

🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants