zio/zio-openai

Support streaming responses from Chat.createChatCompletion

Closed this issue · 0 comments

There is a parameter stream, but when using it the response is not decoded correctly:

ResponseDecodeError(URL(/v1/chat/completions,Absolute(HTTPS,api.openai.com,443),Map(),None),POST,zio.schema.codec.DecodeError$ReadError: (expected '{' got 'd'
),data: {"id":"chatcmpl-[..]","object":"chat.completion.chunk","created":1680112421,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-[..]","object":"chat.completion.chunk","created":1680112421,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"To"},"index":0,"finish_reason":null}]}

data: {"id":"chatcmpl-[..]","object":"chat.completion.chunk","created":1680112421,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" find"},"index":0,"finish_reason":null}]}
...