MediaExtractor

org.llm4s.extract.MediaExtractor

Media-aware extraction: reads a file and returns it as text, an image, audio samples or video frames, discriminated by the MIME type Tika sniffs from its content.

Kept separate from DocumentExtractor on purpose. Document loading wants text and metadata from anything text-bearing; multimodal embedding wants the decoded media itself. The two share only the initial Tika sniff, and the audio and video cases overlap llm4s-speech and llm4s-image rather than RAG, so this may not stay here.

The sniff stays here because it needs Tika; the vocabulary it resolves to (org.llm4s.media.MediaCategory) lives in llm4s-media, so the modules that would consume audio and video branches can name the same categories without inheriting Tika.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final case class AudioContent(samples: Array[Float], sampleRate: Int) extends Extracted

Extracted audio content as mono PCM samples with a sample rate.

Extracted audio content as mono PCM samples with a sample rate.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Extracted
class Object
trait Matchable
class Any
Show all
sealed trait Extracted

Extracted content from a file, discriminated by media type.

Extracted content from a file, discriminated by media type.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
final case class ImageContent(image: BufferedImage) extends Extracted

Extracted image content.

Extracted image content.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Extracted
class Object
trait Matchable
class Any
Show all
final case class TextContent(text: String) extends Extracted

Extracted text content (from PDF, DOCX, plain text, etc.).

Extracted text content (from PDF, DOCX, plain text, etc.).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Extracted
class Object
trait Matchable
class Any
Show all
final case class VideoContent(frames: Seq[BufferedImage], fps: Int) extends Extracted

Extracted video content as a sequence of frames at a given frame rate.

Extracted video content as a sequence of frames at a given frame rate.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Extracted
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def extractAny(inputPath: String): Result[Extracted]

Extract content from a file, returning the Extracted variant matching its media type.

Extract content from a file, returning the Extracted variant matching its media type.

Value parameters

inputPath

path to the file (surrounding whitespace and quotes are stripped)

Attributes

Returns

the extracted content, or a org.llm4s.error.ProcessingError