Return response from streamed request to Anthropic
What does this MR do and why?
Return response from streamed request to Anthropic
This accumulates the response we get from a streamed request to Anthropic and returns it as one string.
This is helpful as we need the full response when broadcasting the messages from chat.
The tests were not correct as the streamed response contained
one additional \n
.
It also fixes how we parse the SSE as it's not guaranteed that
we receive only one SSE from the HTTP.post
yield.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
a = Gitlab::Llm::Anthropic::Client.new(User.first).stream(prompt: "What is 1+1?") do |e|
end
puts a
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Nicolas Dular