Skip to content

Add PromptTemplate class with client-side variable interpolation #13

Description

@isaka1022

What

Introduce a Langfuse::PromptTemplate class that wraps a fetched prompt and provides a typed compile(variables: {}) method for {{variable}}-style interpolation on the client side.

Why

Currently, callers must implement variable substitution themselves after calling client.prompts.get. A typed wrapper improves ergonomics, catches missing variable errors early, and makes prompt usage consistent. The current prompts.compile method calls POST /v2/prompts/compile, which is a non-standard endpoint not present in the official Langfuse API spec — replacing it with client-side interpolation removes this dependency.

Effort estimate

M (2–3 days) — implement the class, handle both text and chat prompt types, add validation for missing/extra variables, and write specs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    laterLong-termroadmapPlanned roadmap item

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions