mgallo / openai.ex

community-maintained OpenAI API Wrapper written in Elixir.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: Atomize string keys in stream responses

APB9785 opened this issue · comments

Describe the feature or improvement you're requesting

Currently when stream: true is set, we're receiving responses with string keys:

%{
  "choices" => [
    %{"delta" => %{"role" => "assistant"}, "finish_reason" => nil, "index" => 0}
  ],
  "created" => 1682700668,
  "id" => "chatcmpl-7ALbIuLju70hXy3jPa3o5VVlrxR6a",
  "model" => "gpt-3.5-turbo-0301",
  "object" => "chat.completion.chunk"
}

In line with the standard (non-stream) responses, I'd expect this map to use atom keys i.e.

%{
  choices: [
    %{delta: %{role: "assistant"}, finish_reason: nil, index: 0}
  ],
  created: 1682700668,
  id: "chatcmpl-7ALbIuLju70hXy3jPa3o5VVlrxR6a",
  model: "gpt-3.5-turbo-0301",
  object: "chat.completion.chunk"
}

Additional context

No response