Convenient LINQ-style table functions.
Project description
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"])
.pselect(
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}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tidylinq-0.1.0.tar.gz
(113.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
tidylinq-0.1.0-py3-none-any.whl
(11.7 kB
view details)
File details
Details for the file tidylinq-0.1.0.tar.gz.
File metadata
- Download URL: tidylinq-0.1.0.tar.gz
- Upload date:
- Size: 113.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d09e001edb968bd67f63e3ca4af9a58756d78cb283dffba56bf156af0e0d34ec
|
|
| MD5 |
41c02ab05271f77221a466251b716999
|
|
| BLAKE2b-256 |
724b3bace1c79744aa457bcdc053cc13c90657d605625b7d94a9951d62ec2017
|
File details
Details for the file tidylinq-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tidylinq-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
454d6e84e5f8aa679a6eb498143188e70c69d10a0cd5069cfaa21f922fb89ca4
|
|
| MD5 |
c31c1925ae8e0c56468f2420f8efe8de
|
|
| BLAKE2b-256 |
9d5959f438920ddffa62e1ee79f9081e24e09cebf142e5ca6596f26ceaafc63d
|