Agent Zero AI framework
Expose unified model calls to extensions
Alessandrodc7004462efc
diff --git a/models.py b/models.pyindex 811fa31e0..057aa1129 100644--- a/models.py+++ b/models.py@@ -524,6 +524,7 @@ class LiteLLMChatWrapper(SimpleChatModel):message=AIMessageChunk(content=output["response_delta"]))+ @extensibleasync def unified_call(self,system_message="",@@ -637,6 +638,7 @@ class LiteLLMChatWrapper(SimpleChatModel):attempt += 1await asyncio.sleep(retry_delay_s)+ @extensibleasync def unified_turn(self,system_message="",diff --git a/tests/test_model_call_extensions.py b/tests/test_model_call_extensions.pynew file mode 100644index 000000000..41bdd1212--- /dev/null+++ b/tests/test_model_call_extensions.py@@ -0,0 +1,34 @@+import pytest++from helpers import extension+from helpers.llm_result import LLMResult+from models import LiteLLMChatWrapper+++ ("method_name", "result"),+ [+ ("unified_call", ("response", "reasoning")),+ ("unified_turn", LLMResult(response="response")),+ ],+)+async def test_unified_model_calls_expose_function_extensions(+ monkeypatch, method_name, result+):+ points = []++ async def call_extensions(point, agent=None, **kwargs):+ points.append(point)+ if point.endswith("/start"):+ kwargs["data"]["result"] = result++ monkeypatch.setattr(extension, "call_extensions_async", call_extensions)++ actual = await getattr(LiteLLMChatWrapper, method_name)(object())++ assert actual is result+ assert points == [+ f"_functions/models/LiteLLMChatWrapper/{method_name}/start",+ f"_functions/models/LiteLLMChatWrapper/{method_name}/end",+ ]