I’m abstracting OpenAI’s Chat Completion API. The API converts text input into text output. For a successful response, the http status code is 200 with either finish_reason=“stop” or finish_reason=“length” and the output. “stop” means the output is complete. “length” means the output is partial, so we should concatenate the output to the input and re-send the request.
It seemed like an obvious choice to translate status != “200” to {:error, reason}
, but I’m wavering on the example I outlined above.
What’s more Elixir?
{:ok, :stop, output}
{:ok, :length, output}
or
{:ok, output} # means "stop"
{:error, :length, output}
EDIT: writing this out makes me feel that :error, :length, output is better, since it’s an unexpected result, and :error calls more attention to it. WDYT?