kaxil commented on code in PR #76974:
URL: https://github.com/apache/airflow/pull/76974#discussion_r4622880694


##########
providers/common/ai/docs/features.rst:
##########
@@ -58,7 +58,7 @@ Run a model or an agent
      - Compares table schemas across databases and files and grades each 
mismatch.
      - ``common.sql``; for files, 
``apache-airflow-providers-common-sql[datafusion]``
    * - :doc:`@task.llm_batch <operators/llm_batch>`
-     - Sends many prompts through the OpenAI or Anthropic batch API at about 
half the
+     - Sends many prompts through the OpenAI, Anthropic or Gemini batch API at 
about half the

Review Comment:
   Fixed in all four places.



##########
providers/common/ai/src/airflow/providers/common/ai/operators/llm_batch.py:
##########
@@ -525,14 +551,23 @@ def _resolve_reattach_target(
         return None, None
 
     def _cancel_recorded_batch(
-        self, record: BatchStateRecord, adapter: BatchAdapter, adapter_name: 
str
+        self, record: BatchStateRecord, adapter: BatchAdapter, adapter_name: 
str, model_id: str | None
     ) -> None:
-        """Cancel a stale batch through the connection that owns it, which may 
differ from the current one."""
+        """Cancel a stale batch through the connection and model that own it, 
which may differ from the current ones."""
         owner: BatchAdapter = adapter
         own_adapter = False
-        if record.llm_conn_id and (record.llm_conn_id != self.llm_conn_id or 
record.adapter != adapter_name):
+        if record.llm_conn_id and (
+            record.llm_conn_id != self.llm_conn_id
+            or record.adapter != adapter_name
+            or (record.model_id and record.model_id != model_id)

Review Comment:
   You're right, it was redundant. Removed it, and the test now shows a stale 
batch under a different model is cancelled through the handle's model without 
building a second adapter.



-- 
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]

Reply via email to