Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion langfuse/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def _get_langchain_prompt_string(content: str):
return re.sub(r"\{\{(.*?)\}\}", r"{\g<1>}", content)

@staticmethod
def _compile_template_string(content: str, **kwargs) -> str:
def _compile_template_string(*args, **kwargs) -> str:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure at all about the way I fixed this since I'm new to Python, I let you handle it if there's a better way 😃

content = args[0]
opening = "{{"
closing = "}}"

Expand Down
10 changes: 10 additions & 0 deletions tests/test_prompt_compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,13 @@ def test_unescaped_JSON_variable_value():
)
def test_various_templates(template, kwargs, expected):
assert BasePromptClient._compile_template_string(template, **kwargs) == expected


def test_content_var():
template = "Hello, {{content}}!"
expected = "Hello, Thomas!"

assert (
BasePromptClient._compile_template_string(template, content="Thomas")
== expected
)