Skip to main content

SilkLoom Core: DataFrame-first batch runner for LLM and VLM workloads

Project description

SilkLoom Core

SilkLoom Core is a DataFrame-first batch runner for OpenAI-compatible LLM and VLM workloads.

Its core shape is:

indexed data -> selected input columns -> model calls -> repaired JSON -> wider DataFrame

Install

pip install silkloom-core

Quick Start

import pandas as pd
from silkloom_core import Loom

df = pd.read_csv("papers.csv")

loom = Loom(
    model="gpt-4o-mini",
    prompt="""
Analyze this paper and return JSON only.

Title: {{ title }}
Abstract: {{ abstract }}

Return keys: sentiment, summary, keywords.
""",
)

df = loom(
    df,
    input=["title", "abstract"],
    resume="paper_analysis_v1",
    concurrency=10,
)

df.to_csv("papers_with_analysis.csv", index=False)

The returned DataFrame keeps the original index and columns, then appends model output columns.

Inputs

Use a pandas DataFrame:

out = loom(df, input=["title", "abstract"])

Or a sequence of row mappings:

out = loom(
    [
        {"text": "The experiment is promising."},
        {"text": "The evaluation is incomplete."},
    ],
    input="text",
)

The output is always a pandas DataFrame.

Output

By default, SilkLoom expects JSON object output and expands its keys into columns.

loom = Loom(
    model="gpt-4o-mini",
    prompt="Classify this text and return JSON with keys label and score: {{ text }}",
)

out = loom(df, input="text")

If the model returns:

{"label": "positive", "score": 0.92}

SilkLoom appends:

label | score

Malformed JSON is repaired with json_repair.repair_json(..., return_objects=True).

Status Columns

SilkLoom appends status columns by default:

_loom_ok
_loom_error
_loom_checkpoint
_loom_attempts

You can also include raw model output and extracted reasoning:

out = loom(
    df,
    input="text",
    include_output=True,
    include_reasoning=True,
)

This adds:

_loom_output
_loom_reasoning

Disable status columns with:

out = loom(df, input="text", status=False)

Resumable Runs

Pass resume to enable SQLite checkpointing. SQLite is the default checkpoint backend.

out = loom(
    df,
    input=["title", "abstract"],
    resume="paper_analysis_v1",
    concurrency=10,
)

The checkpoint fingerprint includes the selected row input, model, prompt, system message, output schema, and model parameters.

Each SQLite row stores a self-describing JSON payload with:

  • SilkLoom version
  • resume namespace
  • model, prompt, system message, model parameters, retry settings, and JSON repair setting
  • selected input columns and image columns
  • normalized row input, including resolved images
  • rendered OpenAI-compatible message payload
  • parsed JSON result
  • raw model output, extracted reasoning, error trace, attempt count, and checkpoint status

To disable checkpointing:

loom = Loom(..., checkpoint=None)

Column Conflicts

If model output columns conflict with existing DataFrame columns, SilkLoom raises. Use prefix when you want to keep both.

out = loom(df, input="text", prefix="llm_")

Images

If an input row contains an images column, SilkLoom builds a multimodal OpenAI-compatible message. HTTP(S) and data:image/... URLs are passed through. Local files are converted to base64 data URLs.

df = pd.DataFrame(
    {
        "instruction": ["Extract menu item names and prices."],
        "images": [["./receipt.jpg"]],
    }
)

out = loom(df, input="instruction", images="images")

You can also pass multiple image columns:

out = loom(df, input="instruction", images=["front_image", "back_image"])

Custom Clients

By default, Loom creates OpenAI SDK clients. You can also pass an existing OpenAI-compatible client:

from openai import OpenAI
from silkloom_core import Loom

client = OpenAI(base_url="https://api.example.com/v1", api_key="...")

loom = Loom(
    model="provider-model",
    prompt="{{ text }}",
    client=client,
)

For full control, pass an object that implements:

class MyClient:
    def complete(self, *, model, messages, params) -> str: ...
    async def acomplete(self, *, model, messages, params) -> str: ...
    def close(self) -> None: ...
    async def aclose(self) -> None: ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

silkloom_core-5.0.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

silkloom_core-5.0.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file silkloom_core-5.0.0.tar.gz.

File metadata

  • Download URL: silkloom_core-5.0.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for silkloom_core-5.0.0.tar.gz
Algorithm Hash digest
SHA256 e5792bfe66c3c5c2bd75670c479ba7ddc80a1484a57867cf87848d2b39adc7e6
MD5 17c061ca7f402d0ae079692a75fc96bf
BLAKE2b-256 0c9fcee1d99f7e8e967c5f4c6cd057643f19871e7a7f2b3e18c0295b887a72aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for silkloom_core-5.0.0.tar.gz:

Publisher: publish.yml on LeLiu-GeoAI/silkloom-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file silkloom_core-5.0.0-py3-none-any.whl.

File metadata

  • Download URL: silkloom_core-5.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for silkloom_core-5.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8131fda42e462a18fb7d2dbf3675ec4463ee018c904ec6e4f1e3f0e44decda12
MD5 5c44c2530ecf81a94630cf98587ce2ce
BLAKE2b-256 cf15806830e293651b05d38f56135297bfdce6b08bb147740b38a602e35118e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for silkloom_core-5.0.0-py3-none-any.whl:

Publisher: publish.yml on LeLiu-GeoAI/silkloom-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page