Lee-W commented on code in PR #72151:
URL: https://github.com/apache/airflow/pull/72151#discussion_r4034388187
##########
providers/openai/src/airflow/providers/openai/operators/openai.py:
##########
@@ -134,9 +137,23 @@ class OpenAIResponseOperator(BaseOperator):
:ref:`howto/operator:OpenAIResponseOperator`
For possible options, see:
https://platform.openai.com/docs/api-reference/responses/create
+
+ ``execute`` also pushes two XCom keys: ``response_id`` (the response's ID,
usable as
+ a downstream call's ``previous_response_id``) and ``usage`` (the
response's token
+ usage, or ``None`` when the API omits it). ``usage`` is the nested dict
returned by
+ ``ResponseUsage.model_dump()``: top-level ``input_tokens``,
``output_tokens`` and
+ ``total_tokens`` counts, plus the nested ``input_tokens_details`` and
+ ``output_tokens_details`` dicts. ``input_tokens_details.cached_tokens`` is
part of
+ the ``input_tokens`` total, not additional to it, so pricing a run
correctly means
+ reading the breakdown rather than treating ``input_tokens`` as a single
uniformly
+ priced count -- see OpenAI's `prompt caching guide
+ <https://platform.openai.com/docs/guides/prompt-caching>`_ for how cached
tokens are
+ priced. Beyond that, ``usage`` reports token counts only -- the OpenAI
response
+ carries no cost field, so turning any of these counts into a price means
multiplying
+ by your own per-token rate.
"""
- template_fields: Sequence[str] = ("input_text", "max_output_tokens",
"max_tool_calls")
+ template_fields: Sequence[str] = ("input_text", "response_kwargs",
"max_output_tokens", "max_tool_calls")
Review Comment:
`_build_response_kwargs()` now applies the same coercion and blank-as-unset
rules to a ceiling key placed directly in `response_kwargs`, not just when
supplied as an operator argument.
blank values are popped, `None` raises, and a literal invalid value (e.g.
`0`) now raises at construction time.
--
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]