Sha256: 05a25206ed551c56eb50a412fb890d8f0302a44cece9c19ceb7bb19ed5fafc5a

Contents?: true

Size: 374 Bytes

Versions: 4

Compression:

Stored size: 374 Bytes

Contents

module JSON

  def self.parse_llm_response(response_text)
    start_index = response_text.index('{')
    end_index = response_text.rindex('}')

    unless start_index && end_index && end_index > start_index
      raise "Invalid JSON response: #{response_text}"
    end

    json_text = response_text[start_index..end_index]
    JSON.parse JSON.repair(json_text)
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kaba-0.5.0 lib/kaba/json.rb
kaba-0.4.0 lib/kaba/json.rb
kaba-0.3.2 lib/kaba/json.rb
kaba-0.3.0 lib/kaba/json.rb