Skip to main content

tidylinq

A set of utilities I've found useful when developing LLM tooling.

Usage:

from pydantic import BaseModel, Field
from textwrap import dedent
from tidylinq import from_iterable, completion_with_schema, retry

class Translation(BaseModel):
    term_source: str = Field(description="The source language term")
    term_target: str = Field(description="The term translated to the target language.")
    example_source: str = Field(description="Example of using the term in the source language.")
    example_target: str = Field(description="Example sentence target to the target language.")

messages = [
    {
        "role": "system",
        "content": dedent("""
            You are an expert translator. Output a structured Japanese response in JSON format for the provided English words.
        """).strip(),
    },
]

translations = (
    from_iterable(["cat", "dog", "hyena"])
    .select(
        lambda w: retry(completion_with_schema, backoff=1.0)(
            model="gemini/gemini-2.5-flash",
            messages=messages + [{"role": "user", "content": w}],
            response_schema=Translation,
        ),
        parallelism=4,
    )
    .with_progress("Translating words")
)

results = translations.to_list()
for translation in results:
    print(f"English: {translation.term_source}")
    print(f"Japanese: {translation.term_target}")
    print(f"Example (EN): {translation.example_source}")
    print(f"Example (JP): {translation.example_target}")

Metadata

Release files for tidylinq 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tidylinq 0.2.0
File Size Uploaded
tidylinq-0.2.0.tar.gz 113.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tidylinq 0.2.0
File Interpreter ABI Platform
tidylinq-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 125.4 kB

Release files / tidylinq-0.2.0.tar.gz

Download URL tidylinq-0.2.0.tar.gz
Size 113.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7513148a25bf5f47ed82e09b5fefd99fa4781383dcc2ef3510e12d01c1868bde
BLAKE2b-256 checksum
How to use checksums
0b70cdeae7a3ccdacb341f298c5c6a6116df361c7051e6f02af1c44ef31e349d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.0

Release files / tidylinq-0.2.0-py3-none-any.whl

Download URL tidylinq-0.2.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c576724fca59539b7fd86c0850033538848000901ed7f7f206acaa2274197c0
BLAKE2b-256 checksum
How to use checksums
ffbd085b3dfc9377b73dc191ad7783933ca0081eda78233ea019c3d4bb6ab3c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page