API#

The main Kor API is shown here:

create_extraction_chain(llm, node, *[, ...])

Create an extraction chain.

from_pydantic(model_class, *[, description, ...])

Convert a pydantic model to Kor internal representation.

Schema#

Kor has its own internal representation of a schema. The schema is pretty minimal and does not do much except for helping to produce type descriptions for the prompts.

Instead of using the internal representation it may be more convenient to use from_pydantic to convert a pydantic schema into internal representation automatically.

Note

It may be that the internal schema will be removed in the future in favor of just using pydantic schema.

Object(*, id[, description, many, examples])

Built-in representation for an object.

Text(*, id[, description, many, examples])

Built-in text input.

Number(*, id[, description, many, examples])

Built-in number input.

Bool(*, id[, description, many, examples])

Built-in bool input.

Selection(*, id[, description, many, ...])

Built-in selection node (aka Enum).

Option(*, id[, description, many, examples])

Built-in option input must be part of a selection input.

Encoders#

Encoders are used to specify how we want the extracted content to be encoded. At the moment, JSONEncoder is the most flexible, the CSVEncoder may be the most accurate, while the XMLEncoder may be neither.

create_extraction_chain accepts an encoder as named argument allowing a user to provide their own custom way to encode the input.

JSONEncoder([use_tags, ensure_ascii])

JSON encoder and decoder.

CSVEncoder(node[, use_tags])

CSV encoder.

XMLEncoder()

Experimental XML encoder to encode and decode data.

Base class:

encoders.Encoder()

Abstract interface for an encoder.

encoders.SchemaBasedEncoder(node, **kwargs)

Abstract interface for an encoder that has the data schema.

TypeDescriptors#

TypeScriptDescriptor()

Generate a typescript style schema description.

BulletPointDescriptor()

Generate a bullet point style schema description.

Base class:

TypeDescriptor()

Abstract interface for a type-descriptor.

Index#