fix(message-placeholders): use plain text langchain format for placeh… #616
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes langfuse/langfuse#9097
Important
ChatPromptClient
now uses a plain text format for unresolved placeholders compatible with LangChain, with updated tests to verify this behavior.ChatPromptClient
inpromptClients.ts
now converts unresolved placeholders to a plain text format compatible with LangChain, avoiding direct dependency on LangChain.getLangchainPrompt()
to return placeholders as tuples like["placeholder", "{name}"]
.prompts.e2e.test.ts
to verify new placeholder format ingetLangchainPrompt()
.ChatPromptTemplate.fromMessages()
for unresolved placeholders.This description was created by
for cf67c43. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Summary
Updated On: 2025-09-16 14:27:48 UTC
This PR fixes the format of unresolved message placeholders when converting Langfuse chat prompts to LangChain format. The core change addresses compatibility issues between Langfuse's
getLangchainPrompt()
method and LangChain'sChatPromptTemplate.fromMessages()
functionality.What Changed:
The PR modifies how unresolved placeholders are represented in the LangChain format conversion. Previously, placeholders were returned as objects with
variableName
andoptional
properties:Now they are returned as simple tuples matching LangChain's native format:
Integration with Codebase:
This change is part of the prompt management system in the
packages/client/src/prompt/promptClients.ts
file, specifically within theChatPromptClient.getLangchainPrompt()
method. The fix ensures that when users call this method to get LangChain-compatible prompts, the output can be directly consumed by LangChain'sChatPromptTemplate.fromMessages()
without requiring additional transformation logic.The change maintains Langfuse's independence from LangChain as a direct dependency while ensuring proper interoperability. The E2E tests were updated to reflect this new tuple format and include a new test case that verifies direct compatibility with
ChatPromptTemplate.fromMessages()
.PR Description Notes:
Confidence score: 4/5
Context used:
Rule - Open a GitHub issue or discussion first before submitting PRs to explain the rationale and necessity of the proposed changes, as required by the contributing guide. (link)