Class: Langchain::Utils::HashTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/langchain/utils/hash_transformer.rb

Class Method Summary collapse

Class Method Details

.symbolize_keys(hash) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/langchain/utils/hash_transformer.rb', line 4

def self.symbolize_keys(hash)
  hash.map do |k, v|
    new_key = begin
      k.to_sym
    rescue
      k
    end
    new_value = v.is_a?(Hash) ? symbolize_keys(v) : v
    [new_key, new_value]
  end.to_h
end