Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am timrwilliams on github.
  • I am timrwilliams (https://keybase.io/timrwilliams) on keybase.
  • I have a public key ASCF7rBSZKT4Ky7-WsaVO4KgpqhM2cxa8GzcTBfaIV4DZgo

To claim this, I am signing this object:

@timrwilliams
timrwilliams / README.md
Created September 19, 2023 09:17
OpenAI process streaming JSON in Ruby

Summary

This example shows how to process a JSON response from the OpenAI Chat API in streaming mode.

  • We are looking for a JSON key named questions which contains an array of JSON objects with the keys question and answer
  • As each question and answer pair is found we process it via the end_object block.

Dependencies

https://github.com/dgraham/json-stream