Closed adamw closed 1 month ago
just one nitpick in docs, beside that looks fine, didn't know SSEs are already supported by ox-based sttp client
So you'd keep the signature of createStreamedChatCompletion
as-is?
I mean, it does model what can happen very precisely and the inclusion of capabilities bound to context functions in that type is something to behold (maybe @odersky should see this, this is a good example of what people will build with caps). Your proposals for simplification throw out some useful properties through the window. The only thing that could possibly happen here is just to compact the complexity by hiding some details with aliases, maybe opaque types that are subtypes, eg.: Source[Either[DeserializationOpenAIException, ChatChunkResponse]]
could be ChatChunkResponseStream
or ChatChunkResponseSource
.
independently, any parsing errors might be propagated to the return Source as errors.
rrrright, but that would close the Source
on first serde error (because you have to return ChannelClosedException.Error) so the possibility that just part of the stream is borked or just unsupported on serde layer would disappear
Closes #192
There's a couple of TODOs (waiting for missing Ox features), but it works.
One issue I have is that the signature of the stream-chat-completion request is complex:
Although it says exactly what might happen ;). That is:
Ox
)IO
capabilityOx
andIO
are only required once the request is sent, hence the context functionsI don't think I'd call such a signature "simple" ;). But once you understand the basic building blocks it makes sense ...
Alternatives:
IO
&Ox
as part of thecreateStreamedChatCompletion
method. Simpler return type, more familiar signature, but not as precise: creating the request description doesn't in itself require a concurrency scopeSource
as errors.Combining these two we would end up with:
cc @lbialy