class Multiwoven::Integrations::Source::OpenAI::Client

def process_streaming_response(chunk)

def process_streaming_response(chunk)
  data_entries = extract_data_entries(chunk)
  data_entries.each do |entry|
    next if entry == "[DONE]"
    data = parse_json(entry)
    raise StandardError, "Error: #{data["error"]["message"]}" if data["error"] && data["error"]["message"]
    yield [RecordMessage.new(data: data, emitted_at: Time.now.to_i).to_multiwoven_message] if block_given?
  end
end