Skip to content

Handle prompt variables #13

@marcjaner

Description

@marcjaner

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions