mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Make powerfx import conditional in _declarative_base.py
Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
This commit is contained in:
+16
-1
@@ -37,7 +37,14 @@ from agent_framework._workflows import (
|
||||
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
|
||||
Engine = None # type: ignore[assignment, misc]
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import TypedDict # type: ignore # pragma: no cover
|
||||
@@ -363,6 +370,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:
|
||||
|
||||
Reference in New Issue
Block a user