pankajkoti commented on code in PR #74470:
URL: https://github.com/apache/airflow/pull/74470#discussion_r4223036999
##########
providers/common/ai/src/airflow/providers/common/ai/decorators/agent.py:
##########
@@ -98,7 +98,6 @@ def execute(self, context: Context) -> Any:
feature_enabled=self.enable_hitl_review,
)
- self.render_template_fields(context)
Review Comment:
Thanks @kaxil, that matches what I found, and you are right that `{{ ds }}`
returned from the function now reaches the model literally with no warning.
There was no user report. I reproduced it with a ticket-triage Dag against a
model. Ticket text that quotes template syntax is rewritten before it reaches
the model (`{{ 100 * 3 }}` arrives as `300`), and an unbalanced `{% raw %}`
fails the task with a `TemplateSyntaxError` on `prompt`.
I do see this as a deliberate departure from `@task.bash` and `@task.sql`. A
command is written by the Dag author, while a prompt is usually built from text
the author did not write. The function also already receives the task context,
so dynamic values can be plain Python:
@task.llm(llm_conn_id="openai", system_prompt="You are a data analyst.")
def summarize_daily_events(ds, params):
return f"Summarize the events for {ds} in region {params['region']}."
It also matches `@task.llm_batch`, which does not render the returned text
either.
I will update the description to state the behaviour change and that it is
intentional.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]