fix(tracing): use Langfuse compile_prompt with {{variable}} syntax
- tracing.py: add compile_prompt() that uses Langfuse .compile(**vars)
for {{variable}} substitution, falls back to Python .format() for
hardcoded {variable} templates
- agent_runner.py: replace _get_system_prompt().format() with
tracing.compile_prompt() for batch_file_classifier, batch_processing,
batch_cloud_processing prompts
- journey.py: replace get_prompt + .format() with compile_prompt()
for journey_system prompt
- chat tracing.py: add compile_prompt() for parity (chat prompts
currently have no variables, but ready for future use)
- Remove unused _get_system_prompt helper
This commit is contained in:
@@ -145,15 +145,17 @@ def _build_system_prompt(
|
||||
if existing_template
|
||||
else ""
|
||||
)
|
||||
# Try Langfuse-managed prompt first, fall back to hardcoded template
|
||||
managed = tracing.get_prompt("journey_system", fallback=None)
|
||||
template = managed if managed is not None else _SYSTEM_PROMPT_TEMPLATE
|
||||
return template.format(
|
||||
directory=directory,
|
||||
data_types=", ".join(data_types),
|
||||
template_start=_TEMPLATE_START,
|
||||
template_end=_TEMPLATE_END,
|
||||
existing_section=existing_section,
|
||||
# Use Langfuse compile_prompt ({{variable}} syntax) with Python .format() fallback
|
||||
return tracing.compile_prompt(
|
||||
"journey_system",
|
||||
fallback=_SYSTEM_PROMPT_TEMPLATE,
|
||||
variables={
|
||||
"directory": directory,
|
||||
"data_types": ", ".join(data_types),
|
||||
"template_start": _TEMPLATE_START,
|
||||
"template_end": _TEMPLATE_END,
|
||||
"existing_section": existing_section,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user