langfuse-java icon indicating copy to clipboard operation
langfuse-java copied to clipboard

Handle prompt variables

Open marcjaner opened this issue 2 months ago • 1 comments

The Java client documentation shows how to fetch prompts but doesn't include examples or documentation on how to compile prompts with variable values after fetching them.

Current Behavior

The current documentation demonstrates fetching prompts:

import com.langfuse.client.LangfuseClient;
import com.langfuse.client.resources.prompts.types.PromptMetaListResponse;

LangfuseClient client = LangfuseClient.builder()
    .url("https://cloud.langfuse.com")
    .credentials("pk-lf-...", "sk-lf-...")
    .build();

PromptMetaListResponse prompts = client.prompts().list();

However, there's no documentation on how to pass variable values to compile the prompt template after fetching it.

Expected Behavior

Similar to the Python and JS/TS SDKs, I would expect the Java client to support compiling prompts with variables. For example, in Python you can do:

prompt = langfuse.get_prompt("prompt-name")
compiled = prompt.compile(variable_name="value")

Use Case

I need to fetch a prompt with placeholders (e.g., {{user_name}}, {{context}}) and compile it with actual values before sending it to the LLM.

Questions

  • Does the Java client support prompt variable compilation?
  • If yes, could you provide documentation or examples?
  • If not, are there plans to add this feature?

marcjaner avatar Oct 24 '25 17:10 marcjaner

@marcjaner As of now, the langfuse-java client is a pure implementation of our API routes with no additional logic. This includes that there is no support for prompt compilation. You'll need to do this yourself.

Right now, there are no plans to expand the feature set here unless they are being contributed by the community. Any patches will need to be compatible with the automatic code generation, though.

Steffen911 avatar Oct 27 '25 08:10 Steffen911