Class: Langchain::Processors::CSV

Inherits:
Base
  • Object
show all
Defined in:
lib/langchain/processors/csv.rb

Defined Under Namespace

Classes: InvalidChunkMode

Constant Summary collapse

EXTENSIONS =
[".csv"]
CONTENT_TYPES =
["text/csv"]
CHUNK_MODE =
{
  row: "row",
  file: "file"
}

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from DependencyHelper

#depends_on

Constructor Details

This class inherits a constructor from Langchain::Processors::Base

Instance Method Details

#parse(data) ⇒ String

Parse the document and return the text

Parameters:

  • data (File)

Returns:

  • (String)


20
21
22
23
24
25
26
27
28
29
# File 'lib/langchain/processors/csv.rb', line 20

def parse(data)
  case chunk_mode
  when CHUNK_MODE[:row]
    chunk_row(data)
  when CHUNK_MODE[:file]
    chunk_file(data)
  else
    raise InvalidChunkMode
  end
end