Skip to content

Conversation

gael-ft
Copy link

@gael-ft gael-ft commented Sep 12, 2025

Hello,

Little PR to allow applications to easily add variables in jinja prompt templates.

Currenly, if we look at the planning for example, the method is quite big.
But at the same time, I think adding/updating templates and their variables is a very common usecase.

from smolagents import CodeAgent

class MyAgent(CodeAgent):
  # ...
  
  # Assuming I added a jinja block using {{client_info}}
  @override
  def _populate_planning_initial_plan_template(self, task: str, step: int) -> str:
    variables = {"client_info": self.client_info, "task": task, "tools": self.tools, "managed_agents": self.managed_agents}
    return populate_template(
            self.prompt_templates["planning"]["initial_plan"],
            variables=variables,
        )

@aymeric-roucher
Copy link
Collaborator

Hi @gael-ft, thank you for adressing this enhancement!
These changes adds a lot of code - isn't there a way to make this method more generic to fit in a few lines only?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants