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)
    yield [RecordMessage.new(data: data, emitted_at: Time.now.to_i).to_multiwoven_message] if block_given?
  rescue StandardError => e
    handle_exception(e, { context: "OPEN AI:PROCESS_STREAMING_RESPONSE:EXCEPTION", type: "error", entry: entry })
  end
end