gopidesupavan commented on code in PR #67438:
URL: https://github.com/apache/airflow/pull/67438#discussion_r3309371384


##########
providers/common/ai/src/airflow/providers/common/ai/operators/llm.py:
##########
@@ -108,19 +107,9 @@ def __init__(
         self.allow_modifications = allow_modifications
 
     @cached_property
-    def llm_hook(self) -> PydanticAIHook:
-        """
-        Return the correct PydanticAIHook subclass for the configured 
connection.
-
-        Delegates to :meth:`~PydanticAIHook.get_hook` which looks up
-        the connection's ``conn_type`` and instantiates the matching subclass
-        (e.g. 
:class:`~airflow.providers.common.ai.hooks.pydantic_ai.PydanticAIAzureHook`
-        for ``pydanticai-azure`` connections).
-        """
-        hook_params = {
-            "model_id": self.model_id,
-        }
-        return PydanticAIHook.get_hook(self.llm_conn_id, 
hook_params=hook_params)
+    def llm_hook(self) -> BaseAIHook:
+        """Return the agent hook for the configured connection."""
+        return BaseAIHook.get_agent_hook(self.llm_conn_id, 
hook_params={"model_id": self.model_id})
 
     def execute(self, context: Context) -> Any:

Review Comment:
   Yes moved this check to basehook



##########
providers/common/ai/src/airflow/providers/common/ai/hooks/base_ai.py:
##########
@@ -0,0 +1,399 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Shared contract for agent-framework hooks used by 
:class:`~airflow.providers.common.ai.operators.agent.AgentOperator`."""
+
+from __future__ import annotations
+
+import functools
+import inspect
+import json
+import time
+from abc import ABCMeta, abstractmethod
+from collections.abc import Callable, Sequence
+from dataclasses import dataclass, field
+from typing import Any, ClassVar
+
+from airflow.providers.common.compat.sdk import BaseHook
+
+_EMPTY_OBJECT_SCHEMA: dict[str, Any] = {"type": "object", "properties": {}}
+
+# Durable storage/counter pairs keyed by ``id(agent)``.
+# pydantic-ai ``Agent`` is not hashable, so ``WeakKeyDictionary`` cannot be 
used.
+# ``create_agent`` and ``run_agent`` run synchronously in the same task, so 
``id()``
+# is stable until ``_pop_agent_durable`` removes the entry.
+_AGENT_DURABLE: dict[int, tuple[Any, Any]] = {}

Review Comment:
   agree :)



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