Refactor error handling for streaming chat flow#117
Refactor error handling for streaming chat flow#117nomisRev wants to merge 2 commits intokpavlov:mainfrom
Conversation
Removed the `Error` type from `StreamingChatLanguageModelReply` and its usage. Simplified the chat flow implementation by replacing `callbackFlow` with a `flow` and added buffering with unlimited capacity to improve stream handling.
|
Tho idea behind emitting error as data was to carry some error details from LLM error response, so it is not an erroneous response per se, but an expected LLM reply. |
Like I said I think either is fine, in the current scenario with both |
Signed-off-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
|
I opened another PR #178 to remove the |
…ption (#178) Removed the Error type from StreamingChatLanguageModelReply and its usage. Currently the error was being emitted twice. Once as an exception, and once as data. We should avoid emitting an event twice, since it only occurs once. It's possible for the user to manually transform the exception into a value using catch { emit(...) } Closes #113 Integrated changes from #117 by @nomisRev : > Removed the Error type from StreamingChatLanguageModelReply and its usage. Currently the error was being emitted twice. Once as an exception, and once as data. We should avoid emitting an event twice, since it only occurs once. It's possible for the user to manually transform the exception into a value using catch { emit(...) } as demonstrated in [my other PR](https://github.com/kpavlov/langchain4j-kotlin/pull/116/files#diff-7b90cc7eba5a803d05990cdcd146bd884ffd7a0eb77b2e9d19b13d1e054e3ebfR86).
Closes #113
Errortype fromStreamingChatLanguageModelReplyand its usage. Currently theerrorwas being emitted twice. Once as an exception, and once as data. We should avoid emitting an event twice, since it only occurs once. It's possible for the user to manually transform the exception into a value usingcatch { emit(...) }as demonstrated in my other PR. Alternatively we can keepStreamingChatLanguageModelReply.Errorbut not re-emit again onclose(throwable). This is a design decision that needs to be made. I don't have a strong preference to be honest, one or the other is fine. You can go back and forth by usingcatchorthrow.