Compare commits

...
@@ -30,14 +30,22 @@ import sys
from collections.abc import Mapping
from dataclasses import dataclass
from decimal import Decimal as _Decimal
from typing import Any, Literal, cast
from typing import TYPE_CHECKING, Any, Literal, cast
from agent_framework._workflows import (
Executor,
WorkflowContext,
)
from agent_framework._workflows._state import State
from powerfx import Engine
try:
from powerfx import Engine
_powerfx_available = True
except (ImportError, RuntimeError):
_powerfx_available = False
if TYPE_CHECKING:
from powerfx import Engine # type: ignore[assignment]
if sys.version_info >= (3, 11):
from typing import TypedDict # type: ignore # pragma: no cover
@@ -363,6 +371,14 @@ class DeclarativeWorkflowState:
# Replace them with their evaluated results before sending to PowerFx
formula = self._preprocess_custom_functions(formula)
# Check if powerfx is available
if not _powerfx_available:
raise ImportError(
"The 'powerfx' package is required to evaluate PowerFx expressions. "
"Please install .NET and the 'powerfx' package to use PowerFx expressions. "
"See https://github.com/microsoft/agent-framework for installation instructions."
)
engine = Engine()
symbols = self._to_powerfx_symbols()
try: