kiln_ai

Kiln AI Core Library

Kiln AI Logo

PyPI - Version PyPI - Python Version Docs


Installation

pip install kiln_ai

About

This package is the Kiln AI core library. There is also a separate desktop application and server package. Learn more about Kiln AI at getkiln.ai

Quick Start

from kiln_ai.datamodel import Project

print("Reading Kiln project")
project = Project.load_from_file("path/to/project.kiln")
print("Project: ", project.name, " - ", project.description)

task = project.tasks()[0]
print("Task: ", task.name, " - ", task.description)
print("Total dataset size:", len(task.runs()))

# ... app specific code using the typed kiln datamodel

# Alternatively, load data into pandas or a similar tool:
import glob
import json
import pandas as pd
from pathlib import Path

dataitem_glob = str(task.path.parent) + "/runs/*/task_run.kiln"

dfs = []
for file in glob.glob(dataitem_glob):
    js = json.loads(Path(file).read_text())
    df = pd.json_normalize(js)
    dfs.append(df)
final_df = pd.concat(dfs, ignore_index=True)
print(final_df)
1"""
2.. include:: ../README.md
3"""