on error in createDataStreamResponse #4890
Unanswered
pedrocarnevale
asked this question in
Help
Replies: 1 comment
-
Use a fallback middleware instead https://github.com/remorses/ai-fallback |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all!!
I'm having a problem here. Sometimes openai is not available, and the API is down. So, to increase availability of my app, I use a togetherAi model if the openAi API is down.
The function
getResponse = async (isError: boolean, dataStream: DataStreamWriter)
is where I get the streamText. If isError is false, I use openAi, if it's true I use togetherAi. So I use thistry ... catch
to try to call togetherAi if the first response fails. But when an error happens it does not go to the catch, it goes to the onError.So, when OpenAi is down, my endpoint returns an error, without trying to use togetherAi
How can I implement the logic that I want, so the availability of my endpoint increases?
Beta Was this translation helpful? Give feedback.
All reactions