potiuk commented on code in PR #76244:
URL: https://github.com/apache/airflow/pull/76244#discussion_r4437780451
##########
providers/common/ai/docs/operators/llm.rst:
##########
@@ -206,6 +206,19 @@ With structured output:
:start-after: [START howto_decorator_llm_structured]
:end-before: [END howto_decorator_llm_structured]
+The returned prompt is rendered as a Jinja template, like the operator's
``prompt``
+argument, so ``{{ ds }}`` and other template variables work in it. Text you
insert into
+the returned string yourself, for example with an f-string, is rendered as
part of the
+template too. To include text that comes from a function argument, such as a
document or
+an upstream task's output, reference the argument by name in the template
instead of
+formatting it into the string. The function's arguments are available when the
prompt is
Review Comment:
Good catch, thanks. I went with merging the bound call: the six common.ai
decorators now add
`inspect.signature(self.python_callable).bind_partial(*self.op_args,
**self.op_kwargs).arguments` to the context just before rendering the returned
prompt, without `apply_defaults()`, so a `ti=None` default can't shadow the
context's `ti`. So `summarize("...")` with `{{ text }}` works now, and a
parameter left at its default is not available, which the docs now say. The
`example_llm.py` examples and the Usage docstrings in `llm.py`, `agent.py` and
`llm_branch.py` reference the argument by name instead of using f-strings, and
there are tests for the positional call and the `ti=None` default.
--
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]