module RubyLLM::FileStore::Converters

Converters turn files into text the model can read and search. A converter is any object that answers call with an Attachment and returns the file’s text, or nil when it cannot read that file, so the next converter gets a turn. FileStore#text tries the converters in Configuration#file_converters first, then reads text files, including source code, CSV, JSON, and Markdown, as they are.

The OCR converter reads PDFs, scans, and photos with RubyLLM.ocr. It costs a request per file, so it only runs where you register it. RubyLLM.file_store.converter returns the converters RubyLLM ships (see Converters::Factory):

RubyLLM.configure do |config|
  config.file_converters["image/*"] = RubyLLM.file_store.converter.ocr
  config.file_converters["application/pdf"] = RubyLLM.file_store.converter.ocr
  config.file_converters["application/vnd.oasis.opendocument.text"] = ->(file) { OdtText.call(file.content) }
end

Converters for other formats can ship as gems named ruby_llm-converters-NAME, like provider gems.