[Enhancement] Better templating
Motivation
Since we override prompts for various generation schemas, we decided that we would offload prompt construction entirely to Jinja templating.
Overriding Parlant classes' prompt sections is very error prone, since prompts are scattered and hardcoded inside the functions, instead of clear separation.
Thus, we started writing and overriding prompts, creating entire folder of schemas (not all schemas, just the ones we use in the project):
src/templates/
├── AgentIntentionProposerSchema.jinja
├── CannedResponseDraftSchema.jinja
├── CannedResponsePreambleSchema.jinja
├── CannedResponseRevisionSchema.jinja
├── CannedResponseSelectionSchema.jinja
...Solution Proposal
Maybe the framework would benefit from separating prompts from classes that use them? Jinja is very flexible in terms of constructing complex logic. The user would not have to touch the class that uses the prompt, only the prompt file (some overrides too).
The only problem I encountered was with journey-related prompts (step selection, backtrack etc), because the Python logic for writing prompts is very complicated. Fortunately though, we do not use journeys for now.
Discussion
This may be an overkill, but some elements of the codebase would get simpler imo. For example, there is inconsistent wording in system introduction ("In our system...") and there is prompt section duplication. Also, sometimes PromptBuilder sections receive entirely rendered substrings as props, and sometimes more atomic entities, this also breaks consistency.
Source: emcie-co/parlant