Skip to content

Jev directory

typesafeify (DSPy decorator)

A DSPy fork whose @typesafeify decorator routes decision-shaped signature fields to Jev, so bool, Literal, and scored outputs come back typed while freeform fields still use the LM.
Stars
66
Language
Python
License
MIT
Reading time
3 min
Published by
Community
Author
typesafeainate
Last verified
Sep 2026

Add a decorator for dspy Signatures that automatically uses TypeSafe where relevant

Forks
3
Last pushed
Updated Oct 2026

Repo stats from the GitHub API, cached Oct 2026.

About this project

This is a deliberately stripped-down proof-of-concept fork of DSPy. It exists to test one idea in isolation: can a normal DSPy signature opt into Typesafe's typed inference path with one decorator, while application code keeps constructing and calling dspy.Predict exactly as before? The meaningful integration diff is intentionally tiny: The caller does not learn a new predictor API: @typesafeify(...) reads the signature's output annotations and builds a hybrid execution plan.

Quoted from the project's README. Read the full README.

Highlights

  • One decorator turns bool, Literal, and configured score fields into a single Jev request, while string fields stay with DSPy's LM.
  • Across three observed tickets the decorated run averaged 1.958s versus 2.329s for plain DSPy, 15.9% faster.
  • Modeled cost fell from $0.000377 to $0.000263 per ticket, a 30.1% reduction.
  • The demo checks field and instruction parity between the baseline and decorated signatures before either request runs.

Quickstart

python
from typesafe_dspy import typesafeify

@typesafeify(score_fields={"severity_score": [1, 5]})
class SupportTicketTriage(dspy.Signature):
    ticket: dict = dspy.InputField()
    customer_impacting: bool = dspy.OutputField()
    owner_team: Literal["api-platform", "billing"] = dspy.OutputField()
    severity_score: float = dspy.OutputField()

Watch out

MIT-licensed, but a deliberately stripped-down proof-of-concept fork rather than a replacement for upstream DSPy; needs both OpenAI and TypeSafe keys.

Questions about this entry

Short answers drawn from the linked project or page.

From the Jev guides

Original write-ups on what this entry is for.

From the Jev AI model community

Posts from builders shipping with Jev right now.

Follow @typesafeai