This is an automated email from the ASF dual-hosted git repository.

gopidesupavan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 30e6372af49 Guard code_mode example DAG on SQLToolset import (#69677)
30e6372af49 is described below

commit 30e6372af494a0d1f333633e97ee3794102fcdfd
Author: Zach Liu <[email protected]>
AuthorDate: Fri Jul 10 11:58:56 2026 -0400

    Guard code_mode example DAG on SQLToolset import (#69677)
---
 .../common/ai/example_dags/example_agent.py        | 29 +++++++++++-----------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git 
a/providers/common/ai/src/airflow/providers/common/ai/example_dags/example_agent.py
 
b/providers/common/ai/src/airflow/providers/common/ai/example_dags/example_agent.py
index e294260ca31..79a0c5fe333 100644
--- 
a/providers/common/ai/src/airflow/providers/common/ai/example_dags/example_agent.py
+++ 
b/providers/common/ai/src/airflow/providers/common/ai/example_dags/example_agent.py
@@ -230,23 +230,24 @@ example_agent_operator_hitl_review()
 
 
 # [START howto_operator_agent_code_mode]
-@dag(tags=["example"])
-def example_agent_operator_code_mode():
-    AgentOperator(
-        task_id="code_mode_analyst",
-        prompt="For the top 3 customers by order count, what was each one's 
total spend?",
-        llm_conn_id="pydanticai_default",
-        system_prompt="You are a SQL analyst. Write Python that calls the 
tools to answer.",
-        toolsets=[SQLToolset(db_conn_id="postgres_default", 
allowed_tables=["customers", "orders"])],
-        # Requires the `code-mode` extra:
-        #   pip install "apache-airflow-providers-common-ai[code-mode]"
-        code_mode=True,
-    )
+if SQLToolset is not None:
 
+    @dag(tags=["example"])
+    def example_agent_operator_code_mode():
+        AgentOperator(
+            task_id="code_mode_analyst",
+            prompt="For the top 3 customers by order count, what was each 
one's total spend?",
+            llm_conn_id="pydanticai_default",
+            system_prompt="You are a SQL analyst. Write Python that calls the 
tools to answer.",
+            toolsets=[SQLToolset(db_conn_id="postgres_default", 
allowed_tables=["customers", "orders"])],
+            # Requires the `code-mode` extra:
+            #   pip install "apache-airflow-providers-common-ai[code-mode]"
+            code_mode=True,
+        )
 
-# [END howto_operator_agent_code_mode]
+    # [END howto_operator_agent_code_mode]
 
-example_agent_operator_code_mode()
+    example_agent_operator_code_mode()
 
 
 # ---------------------------------------------------------------------------

Reply via email to