LeXtract.FormatType (lextract v0.1.2)

View Source

Enumeration of supported format types for parsing LLM outputs.

Supports JSON and YAML formats for structured data extraction.

Examples

iex> LeXtract.FormatType.from_string("json")
{:ok, :json}

iex> LeXtract.FormatType.to_string(:yaml)
"yaml"

iex> LeXtract.FormatType.all()
[:json, :yaml]

Summary

Functions

Returns a list of all supported format types.

Converts a string to a format type atom.

Converts a format type atom to its string representation.

Types

t()

@type t() :: :json | :yaml

Functions

all()

@spec all() :: [t()]

Returns a list of all supported format types.

Examples

iex> LeXtract.FormatType.all()
[:json, :yaml]

from_string(other)

@spec from_string(String.t()) :: {:ok, t()} | {:error, Exception.t()}

Converts a string to a format type atom.

Accepts "json", "yaml", and "yml" as valid format strings.

Examples

iex> LeXtract.FormatType.from_string("json")
{:ok, :json}

iex> LeXtract.FormatType.from_string("yaml")
{:ok, :yaml}

iex> LeXtract.FormatType.from_string("yml")
{:ok, :yaml}

iex> {:error, error} = LeXtract.FormatType.from_string("invalid")
iex> is_exception(error)
true

to_string(atom)

@spec to_string(t()) :: String.t()

Converts a format type atom to its string representation.

Examples

iex> LeXtract.FormatType.to_string(:json)
"json"

iex> LeXtract.FormatType.to_string(:yaml)
"yaml"